PCI: Create alloc_pci_dev(), the one true way to create a struct pci_dev
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>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
c9953a73e9
commit
65891215e6
@@ -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...
|
||||
|
Reference in New Issue
Block a user