Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Yu Zhao and committed by
Jesse Barnes
3fa16fdb 613e7ed6

+27 -26
+27 -26
drivers/pci/bus.c
··· 71 71 } 72 72 73 73 /** 74 - * add a single device 74 + * pci_bus_add_device - add a single device 75 75 * @dev: device to add 76 76 * 77 77 * This adds a single pci device to the global ··· 105 105 void pci_bus_add_devices(struct pci_bus *bus) 106 106 { 107 107 struct pci_dev *dev; 108 - struct pci_bus *child_bus; 108 + struct pci_bus *child; 109 109 int retval; 110 110 111 111 list_for_each_entry(dev, &bus->devices, bus_list) { ··· 120 120 list_for_each_entry(dev, &bus->devices, bus_list) { 121 121 BUG_ON(!dev->is_added); 122 122 123 + child = dev->subordinate; 123 124 /* 124 125 * If there is an unattached subordinate bus, attach 125 126 * it and then scan for unattached PCI devices. 126 127 */ 127 - if (dev->subordinate) { 128 - if (list_empty(&dev->subordinate->node)) { 129 - down_write(&pci_bus_sem); 130 - list_add_tail(&dev->subordinate->node, 131 - &dev->bus->children); 132 - up_write(&pci_bus_sem); 133 - } 134 - pci_bus_add_devices(dev->subordinate); 128 + if (!child) 129 + continue; 130 + if (list_empty(&child->node)) { 131 + down_write(&pci_bus_sem); 132 + list_add_tail(&child->node, &dev->bus->children); 133 + up_write(&pci_bus_sem); 134 + } 135 + pci_bus_add_devices(child); 135 136 136 - /* register the bus with sysfs as the parent is now 137 - * properly registered. */ 138 - child_bus = dev->subordinate; 139 - if (child_bus->is_added) 140 - continue; 141 - child_bus->dev.parent = child_bus->bridge; 142 - retval = device_register(&child_bus->dev); 143 - if (retval) 144 - dev_err(&dev->dev, "Error registering pci_bus," 145 - " continuing...\n"); 146 - else { 147 - child_bus->is_added = 1; 148 - retval = device_create_file(&child_bus->dev, 149 - &dev_attr_cpuaffinity); 150 - } 137 + /* 138 + * register the bus with sysfs as the parent is now 139 + * properly registered. 140 + */ 141 + if (child->is_added) 142 + continue; 143 + child->dev.parent = child->bridge; 144 + retval = device_register(&child->dev); 145 + if (retval) 146 + dev_err(&dev->dev, "Error registering pci_bus," 147 + " continuing...\n"); 148 + else { 149 + child->is_added = 1; 150 + retval = device_create_file(&child->dev, 151 + &dev_attr_cpuaffinity); 151 152 if (retval) 152 153 dev_err(&dev->dev, "Error creating cpuaffinity" 153 154 " file, continuing...\n"); 154 155 155 - retval = device_create_file(&child_bus->dev, 156 + retval = device_create_file(&child->dev, 156 157 &dev_attr_cpulistaffinity); 157 158 if (retval) 158 159 dev_err(&dev->dev,