aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/bus.c
diff options
context:
space:
mode:
authorYu Zhao <yu.zhao@intel.com>2008-11-21 13:41:45 -0500
committerJesse Barnes <jbarnes@virtuousgeek.org>2009-01-07 14:13:05 -0500
commit3fa16fdb48e0d83c2acf46e357548c89891df58b (patch)
tree7a4403f0aeddc2b0399ba1f8a01e28669c95f608 /drivers/pci/bus.c
parent613e7ed6f72b1a115f7ece8ce1b66cf095de1348 (diff)
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: Yu Zhao <yu.zhao@intel.com> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Diffstat (limited to 'drivers/pci/bus.c')
-rw-r--r--drivers/pci/bus.c55
1 files changed, 28 insertions, 27 deletions
diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c
index 3e1c135b174a..1b6de1b565aa 100644
--- a/drivers/pci/bus.c
+++ b/drivers/pci/bus.c
@@ -71,7 +71,7 @@ pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res,
71} 71}
72 72
73/** 73/**
74 * add a single device 74 * pci_bus_add_device - add a single device
75 * @dev: device to add 75 * @dev: device to add
76 * 76 *
77 * This adds a single pci device to the global 77 * This adds a single pci device to the global
@@ -105,7 +105,7 @@ int pci_bus_add_device(struct pci_dev *dev)
105void pci_bus_add_devices(struct pci_bus *bus) 105void pci_bus_add_devices(struct pci_bus *bus)
106{ 106{
107 struct pci_dev *dev; 107 struct pci_dev *dev;
108 struct pci_bus *child_bus; 108 struct pci_bus *child;
109 int retval; 109 int retval;
110 110
111 list_for_each_entry(dev, &bus->devices, bus_list) { 111 list_for_each_entry(dev, &bus->devices, bus_list) {
@@ -120,39 +120,40 @@ void pci_bus_add_devices(struct pci_bus *bus)
120 list_for_each_entry(dev, &bus->devices, bus_list) { 120 list_for_each_entry(dev, &bus->devices, bus_list) {
121 BUG_ON(!dev->is_added); 121 BUG_ON(!dev->is_added);
122 122
123 child = dev->subordinate;
123 /* 124 /*
124 * If there is an unattached subordinate bus, attach 125 * If there is an unattached subordinate bus, attach
125 * it and then scan for unattached PCI devices. 126 * it and then scan for unattached PCI devices.
126 */ 127 */
127 if (dev->subordinate) { 128 if (!child)
128 if (list_empty(&dev->subordinate->node)) { 129 continue;
129 down_write(&pci_bus_sem); 130 if (list_empty(&child->node)) {
130 list_add_tail(&dev->subordinate->node, 131 down_write(&pci_bus_sem);
131 &dev->bus->children); 132 list_add_tail(&child->node, &dev->bus->children);
132 up_write(&pci_bus_sem); 133 up_write(&pci_bus_sem);
133 } 134 }
134 pci_bus_add_devices(dev->subordinate); 135 pci_bus_add_devices(child);
135 136
136 /* register the bus with sysfs as the parent is now 137 /*
137 * properly registered. */ 138 * register the bus with sysfs as the parent is now
138 child_bus = dev->subordinate; 139 * properly registered.
139 if (child_bus->is_added) 140 */
140 continue; 141 if (child->is_added)
141 child_bus->dev.parent = child_bus->bridge; 142 continue;
142 retval = device_register(&child_bus->dev); 143 child->dev.parent = child->bridge;
143 if (retval) 144 retval = device_register(&child->dev);
144 dev_err(&dev->dev, "Error registering pci_bus," 145 if (retval)
145 " continuing...\n"); 146 dev_err(&dev->dev, "Error registering pci_bus,"
146 else { 147 " continuing...\n");
147 child_bus->is_added = 1; 148 else {
148 retval = device_create_file(&child_bus->dev, 149 child->is_added = 1;
149 &dev_attr_cpuaffinity); 150 retval = device_create_file(&child->dev,
150 } 151 &dev_attr_cpuaffinity);
151 if (retval) 152 if (retval)
152 dev_err(&dev->dev, "Error creating cpuaffinity" 153 dev_err(&dev->dev, "Error creating cpuaffinity"
153 " file, continuing...\n"); 154 " file, continuing...\n");
154 155
155 retval = device_create_file(&child_bus->dev, 156 retval = device_create_file(&child->dev,
156 &dev_attr_cpulistaffinity); 157 &dev_attr_cpulistaffinity);
157 if (retval) 158 if (retval)
158 dev_err(&dev->dev, 159 dev_err(&dev->dev,