]> err.no Git - linux-2.6/commitdiff
PCI: Create alloc_pci_dev(), the one true way to create a struct pci_dev
authorMichael Ellerman <michael@ellerman.id.au>
Thu, 5 Apr 2007 07:19:08 +0000 (17:19 +1000)
committerGreg Kroah-Hartman <gregkh@suse.de>
Thu, 3 May 2007 02:02:37 +0000 (19:02 -0700)
There are currently several places in the kernel where we kmalloc()
a struct pci_dev and start initialising it. It'd be preferable to
have an allocator so we can ensure the pci_dev is correctly initialised
in one place.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/pci/probe.c
include/linux/pci.h

index 629edf39a07dc6d526301a37a9582c6927437955..70d37bbf09bb8399205a2d7a459ef81deb9eae4d 100644 (file)
@@ -846,6 +846,21 @@ static void pci_release_bus_bridge_dev(struct device *dev)
        kfree(dev);
 }
 
+struct pci_dev *alloc_pci_dev(void)
+{
+       struct pci_dev *dev;
+
+       dev = kzalloc(sizeof(struct pci_dev), GFP_KERNEL);
+       if (!dev)
+               return NULL;
+
+       INIT_LIST_HEAD(&dev->global_list);
+       INIT_LIST_HEAD(&dev->bus_list);
+
+       return dev;
+}
+EXPORT_SYMBOL(alloc_pci_dev);
+
 /*
  * Read the config data for a PCI device, sanity-check it
  * and fill in the dev structure...
index 99d45751830ca41838e735d80ad1361d07de3620..c02074785d4098cb053ae390e144595ef6d6f18f 100644 (file)
@@ -193,6 +193,8 @@ struct pci_dev {
 #endif
 };
 
+extern struct pci_dev *alloc_pci_dev(void);
+
 #define pci_dev_g(n) list_entry(n, struct pci_dev, global_list)
 #define pci_dev_b(n) list_entry(n, struct pci_dev, bus_list)
 #define        to_pci_dev(n) container_of(n, struct pci_dev, dev)