This patch splits a new function from pci_bus_add_devices(). The new function can be used to register PCI bus to the device core and create its sysfs entries. Cc: Alex Chiang <achiang@xxxxxx> Cc: Grant Grundler <grundler@xxxxxxxxxxxxxxxx> Cc: Greg KH <greg@xxxxxxxxx> Cc: Ingo Molnar <mingo@xxxxxxx> Cc: Jesse Barnes <jbarnes@xxxxxxxxxxxxxxxx> Cc: Matthew Wilcox <matthew@xxxxxx> Cc: Randy Dunlap <randy.dunlap@xxxxxxxxxx> Cc: Roland Dreier <rdreier@xxxxxxxxx> Signed-off-by: Yu Zhao <yu.zhao@xxxxxxxxx> --- drivers/pci/bus.c | 47 ++++++++++++++++++++++++++++------------------- include/linux/pci.h | 1 + 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c index 7a21602..1713c35 100644 --- a/drivers/pci/bus.c +++ b/drivers/pci/bus.c @@ -91,6 +91,32 @@ int pci_bus_add_device(struct pci_dev *dev) } /** + * pci_bus_add_child - add a child bus + * @bus: bus to add + * + * This adds sysfs entries for a single bus + */ +int pci_bus_add_child(struct pci_bus *bus) +{ + int retval; + + if (bus->bridge) + bus->dev.parent = bus->bridge; + + retval = device_register(&bus->dev); + if (retval) + return retval; + + bus->is_added = 1; + + retval = device_create_file(&bus->dev, &dev_attr_cpuaffinity); + if (retval) + return retval; + + return device_create_file(&bus->dev, &dev_attr_cpulistaffinity); +} + +/** * pci_bus_add_devices - insert newly discovered PCI devices * @bus: bus to check for new devices * @@ -141,26 +167,9 @@ void pci_bus_add_devices(struct pci_bus *bus) */ if (child->is_added) continue; - child->dev.parent = child->bridge; - retval = device_register(&child->dev); + retval = pci_bus_add_child(child); if (retval) - dev_err(&dev->dev, "Error registering pci_bus," - " continuing...\n"); - else { - child->is_added = 1; - retval = device_create_file(&child->dev, - &dev_attr_cpuaffinity); - if (retval) - dev_err(&dev->dev, "Error creating cpuaffinity" - " file, continuing...\n"); - - retval = device_create_file(&child->dev, - &dev_attr_cpulistaffinity); - if (retval) - dev_err(&dev->dev, - "Error creating cpulistaffinity" - " file, continuing...\n"); - } + dev_err(&dev->dev, "Error adding bus, continuing\n"); } } diff --git a/include/linux/pci.h b/include/linux/pci.h index 6ac69af..80d88f8 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -528,6 +528,7 @@ struct pci_dev *pci_scan_single_device(struct pci_bus *bus, int devfn); void pci_device_add(struct pci_dev *dev, struct pci_bus *bus); unsigned int pci_scan_child_bus(struct pci_bus *bus); int __must_check pci_bus_add_device(struct pci_dev *dev); +int pci_bus_add_child(struct pci_bus *bus); void pci_read_bridge_bases(struct pci_bus *child); struct resource *pci_find_parent_resource(const struct pci_dev *dev, struct resource *res); -- 1.5.6.4 -- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html