PCI: Convert alloc_pci_dev(void) to pci_alloc_dev(bus)
[firefly-linux-kernel-4.4.55.git] / drivers / pci / probe.c
index 631aeb7d2d2dd548d7db2ccfeae6b7518f0fc483..ed5ce185eed99fac256e7bcec3600ab1ee92ecf9 100644 (file)
@@ -1132,6 +1132,7 @@ static void pci_release_dev(struct device *dev)
        pci_dev = to_pci_dev(dev);
        pci_release_capabilities(pci_dev);
        pci_release_of_node(pci_dev);
+       pci_bus_put(pci_dev->bus);
        kfree(pci_dev);
 }
 
@@ -1200,7 +1201,7 @@ static void pci_release_bus_bridge_dev(struct device *dev)
        kfree(bridge);
 }
 
-struct pci_dev *alloc_pci_dev(void)
+struct pci_dev *pci_alloc_dev(struct pci_bus *bus)
 {
        struct pci_dev *dev;
 
@@ -1210,9 +1211,16 @@ struct pci_dev *alloc_pci_dev(void)
 
        INIT_LIST_HEAD(&dev->bus_list);
        dev->dev.type = &pci_dev_type;
+       dev->bus = pci_bus_get(bus);
 
        return dev;
 }
+EXPORT_SYMBOL(pci_alloc_dev);
+
+struct pci_dev *alloc_pci_dev(void)
+{
+       return pci_alloc_dev(NULL);
+}
 EXPORT_SYMBOL(alloc_pci_dev);
 
 bool pci_bus_read_dev_vendor_id(struct pci_bus *bus, int devfn, u32 *l,
@@ -1263,11 +1271,10 @@ static struct pci_dev *pci_scan_device(struct pci_bus *bus, int devfn)
        if (!pci_bus_read_dev_vendor_id(bus, devfn, &l, 60*1000))
                return NULL;
 
-       dev = alloc_pci_dev();
+       dev = pci_alloc_dev(bus);
        if (!dev)
                return NULL;
 
-       dev->bus = bus;
        dev->devfn = devfn;
        dev->vendor = l & 0xffff;
        dev->device = (l >> 16) & 0xffff;
@@ -1275,6 +1282,7 @@ static struct pci_dev *pci_scan_device(struct pci_bus *bus, int devfn)
        pci_set_of_node(dev);
 
        if (pci_setup_device(dev)) {
+               pci_bus_put(dev->bus);
                kfree(dev);
                return NULL;
        }
@@ -1341,7 +1349,6 @@ void pci_device_add(struct pci_dev *dev, struct pci_bus *bus)
        list_add_tail(&dev->bus_list, &bus->devices);
        up_write(&pci_bus_sem);
 
-       pci_fixup_device(pci_fixup_final, dev);
        ret = pcibios_add_device(dev);
        WARN_ON(ret < 0);