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

PCI: factor pci_bus_add_child() from pci_bus_add_devices()

This patch splits a new function, pci_bus_add_child(), from
pci_bus_add_devices(). The new function can be used to register PCI
buses to the device core.

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
876e501a 3fa16fdb

+34 -23
+33 -23
drivers/pci/bus.c
··· 91 91 } 92 92 93 93 /** 94 + * pci_bus_add_child - add a child bus 95 + * @bus: bus to add 96 + * 97 + * This adds sysfs entries for a single bus 98 + */ 99 + int pci_bus_add_child(struct pci_bus *bus) 100 + { 101 + int retval; 102 + 103 + if (bus->bridge) 104 + bus->dev.parent = bus->bridge; 105 + 106 + retval = device_register(&bus->dev); 107 + if (retval) 108 + return retval; 109 + 110 + bus->is_added = 1; 111 + 112 + retval = device_create_file(&bus->dev, &dev_attr_cpuaffinity); 113 + if (retval) 114 + return retval; 115 + 116 + retval = device_create_file(&bus->dev, &dev_attr_cpulistaffinity); 117 + 118 + /* Create legacy_io and legacy_mem files for this bus */ 119 + pci_create_legacy_files(bus); 120 + 121 + return retval; 122 + } 123 + 124 + /** 94 125 * pci_bus_add_devices - insert newly discovered PCI devices 95 126 * @bus: bus to check for new devices 96 127 * ··· 171 140 */ 172 141 if (child->is_added) 173 142 continue; 174 - child->dev.parent = child->bridge; 175 - retval = device_register(&child->dev); 143 + retval = pci_bus_add_child(child); 176 144 if (retval) 177 - dev_err(&dev->dev, "Error registering pci_bus," 178 - " continuing...\n"); 179 - else { 180 - child->is_added = 1; 181 - retval = device_create_file(&child->dev, 182 - &dev_attr_cpuaffinity); 183 - if (retval) 184 - dev_err(&dev->dev, "Error creating cpuaffinity" 185 - " file, continuing...\n"); 186 - 187 - retval = device_create_file(&child->dev, 188 - &dev_attr_cpulistaffinity); 189 - if (retval) 190 - dev_err(&dev->dev, 191 - "Error creating cpulistaffinity" 192 - " file, continuing...\n"); 193 - 194 - /* Create legacy_io and legacy_mem files for this bus */ 195 - pci_create_legacy_files(child_bus); 196 - 197 - } 145 + dev_err(&dev->dev, "Error adding bus, continuing\n"); 198 146 } 199 147 } 200 148
+1
drivers/pci/pci.h
··· 173 173 struct resource *res, unsigned int reg); 174 174 extern int pci_resource_bar(struct pci_dev *dev, int resno, 175 175 enum pci_bar_type *type); 176 + extern int pci_bus_add_child(struct pci_bus *bus); 176 177 extern void pci_enable_ari(struct pci_dev *dev); 177 178 /** 178 179 * pci_ari_enabled - query ARI forwarding status