Commit 3fa16fdb authored by Yu Zhao's avatar Yu Zhao Committed by Jesse Barnes

PCI: cleanup pci_bus_add_devices()

Cleanup pci_bus_add_devices() by negating the conditional and
continuing, rather than having a single conditional take up the whole
body.
Signed-off-by: default avatarYu Zhao <yu.zhao@intel.com>
Signed-off-by: default avatarJesse Barnes <jbarnes@virtuousgeek.org>
parent 613e7ed6
...@@ -71,7 +71,7 @@ pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res, ...@@ -71,7 +71,7 @@ pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res,
} }
/** /**
* add a single device * pci_bus_add_device - add a single device
* @dev: device to add * @dev: device to add
* *
* This adds a single pci device to the global * This adds a single pci device to the global
...@@ -105,7 +105,7 @@ int pci_bus_add_device(struct pci_dev *dev) ...@@ -105,7 +105,7 @@ int pci_bus_add_device(struct pci_dev *dev)
void pci_bus_add_devices(struct pci_bus *bus) void pci_bus_add_devices(struct pci_bus *bus)
{ {
struct pci_dev *dev; struct pci_dev *dev;
struct pci_bus *child_bus; struct pci_bus *child;
int retval; int retval;
list_for_each_entry(dev, &bus->devices, bus_list) { list_for_each_entry(dev, &bus->devices, bus_list) {
...@@ -120,39 +120,40 @@ void pci_bus_add_devices(struct pci_bus *bus) ...@@ -120,39 +120,40 @@ void pci_bus_add_devices(struct pci_bus *bus)
list_for_each_entry(dev, &bus->devices, bus_list) { list_for_each_entry(dev, &bus->devices, bus_list) {
BUG_ON(!dev->is_added); BUG_ON(!dev->is_added);
child = dev->subordinate;
/* /*
* If there is an unattached subordinate bus, attach * If there is an unattached subordinate bus, attach
* it and then scan for unattached PCI devices. * it and then scan for unattached PCI devices.
*/ */
if (dev->subordinate) { if (!child)
if (list_empty(&dev->subordinate->node)) { continue;
down_write(&pci_bus_sem); if (list_empty(&child->node)) {
list_add_tail(&dev->subordinate->node, down_write(&pci_bus_sem);
&dev->bus->children); list_add_tail(&child->node, &dev->bus->children);
up_write(&pci_bus_sem); up_write(&pci_bus_sem);
} }
pci_bus_add_devices(dev->subordinate); pci_bus_add_devices(child);
/* register the bus with sysfs as the parent is now /*
* properly registered. */ * register the bus with sysfs as the parent is now
child_bus = dev->subordinate; * properly registered.
if (child_bus->is_added) */
continue; if (child->is_added)
child_bus->dev.parent = child_bus->bridge; continue;
retval = device_register(&child_bus->dev); child->dev.parent = child->bridge;
if (retval) retval = device_register(&child->dev);
dev_err(&dev->dev, "Error registering pci_bus," if (retval)
" continuing...\n"); dev_err(&dev->dev, "Error registering pci_bus,"
else { " continuing...\n");
child_bus->is_added = 1; else {
retval = device_create_file(&child_bus->dev, child->is_added = 1;
&dev_attr_cpuaffinity); retval = device_create_file(&child->dev,
} &dev_attr_cpuaffinity);
if (retval) if (retval)
dev_err(&dev->dev, "Error creating cpuaffinity" dev_err(&dev->dev, "Error creating cpuaffinity"
" file, continuing...\n"); " file, continuing...\n");
retval = device_create_file(&child_bus->dev, retval = device_create_file(&child->dev,
&dev_attr_cpulistaffinity); &dev_attr_cpulistaffinity);
if (retval) if (retval)
dev_err(&dev->dev, dev_err(&dev->dev,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment