diff options
Diffstat (limited to 'drivers/pci/bus.c')
-rw-r--r-- | drivers/pci/bus.c | 87 |
1 files changed, 51 insertions, 36 deletions
diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c index 999cc4088b59..52b54f053be0 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 |
@@ -91,6 +91,37 @@ int pci_bus_add_device(struct pci_dev *dev) | |||
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 | * pci_bus_add_devices - insert newly discovered PCI devices | 125 | * pci_bus_add_devices - insert newly discovered PCI devices |
95 | * @bus: bus to check for new devices | 126 | * @bus: bus to check for new devices |
96 | * | 127 | * |
@@ -105,7 +136,7 @@ int pci_bus_add_device(struct pci_dev *dev) | |||
105 | void pci_bus_add_devices(struct pci_bus *bus) | 136 | void pci_bus_add_devices(struct pci_bus *bus) |
106 | { | 137 | { |
107 | struct pci_dev *dev; | 138 | struct pci_dev *dev; |
108 | struct pci_bus *child_bus; | 139 | struct pci_bus *child; |
109 | int retval; | 140 | int retval; |
110 | 141 | ||
111 | list_for_each_entry(dev, &bus->devices, bus_list) { | 142 | list_for_each_entry(dev, &bus->devices, bus_list) { |
@@ -120,45 +151,29 @@ void pci_bus_add_devices(struct pci_bus *bus) | |||
120 | list_for_each_entry(dev, &bus->devices, bus_list) { | 151 | list_for_each_entry(dev, &bus->devices, bus_list) { |
121 | BUG_ON(!dev->is_added); | 152 | BUG_ON(!dev->is_added); |
122 | 153 | ||
154 | child = dev->subordinate; | ||
123 | /* | 155 | /* |
124 | * If there is an unattached subordinate bus, attach | 156 | * If there is an unattached subordinate bus, attach |
125 | * it and then scan for unattached PCI devices. | 157 | * it and then scan for unattached PCI devices. |
126 | */ | 158 | */ |
127 | if (dev->subordinate) { | 159 | if (!child) |
128 | if (list_empty(&dev->subordinate->node)) { | 160 | continue; |
129 | down_write(&pci_bus_sem); | 161 | if (list_empty(&child->node)) { |
130 | list_add_tail(&dev->subordinate->node, | 162 | down_write(&pci_bus_sem); |
131 | &dev->bus->children); | 163 | list_add_tail(&child->node, &dev->bus->children); |
132 | up_write(&pci_bus_sem); | 164 | up_write(&pci_bus_sem); |
133 | } | ||
134 | pci_bus_add_devices(dev->subordinate); | ||
135 | |||
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 | } | ||
151 | if (retval) | ||
152 | dev_err(&dev->dev, "Error creating cpuaffinity" | ||
153 | " file, continuing...\n"); | ||
154 | |||
155 | retval = device_create_file(&child_bus->dev, | ||
156 | &dev_attr_cpulistaffinity); | ||
157 | if (retval) | ||
158 | dev_err(&dev->dev, | ||
159 | "Error creating cpulistaffinity" | ||
160 | " file, continuing...\n"); | ||
161 | } | 165 | } |
166 | pci_bus_add_devices(child); | ||
167 | |||
168 | /* | ||
169 | * register the bus with sysfs as the parent is now | ||
170 | * properly registered. | ||
171 | */ | ||
172 | if (child->is_added) | ||
173 | continue; | ||
174 | retval = pci_bus_add_child(child); | ||
175 | if (retval) | ||
176 | dev_err(&dev->dev, "Error adding bus, continuing\n"); | ||
162 | } | 177 | } |
163 | } | 178 | } |
164 | 179 | ||