aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/pci_bind.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/pci_bind.c')
-rw-r--r--drivers/acpi/pci_bind.c90
1 files changed, 38 insertions, 52 deletions
diff --git a/drivers/acpi/pci_bind.c b/drivers/acpi/pci_bind.c
index 4b252ea0e952..95650f83ce2e 100644
--- a/drivers/acpi/pci_bind.c
+++ b/drivers/acpi/pci_bind.c
@@ -99,7 +99,7 @@ acpi_status acpi_get_pci_id(acpi_handle handle, struct acpi_pci_id *id)
99 */ 99 */
100 100
101 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 101 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
102 "Device %s has PCI address %02x:%02x:%02x.%02x\n", 102 "Device %s has PCI address %04x:%02x:%02x.%d\n",
103 acpi_device_bid(device), id->segment, id->bus, 103 acpi_device_bid(device), id->segment, id->bus,
104 id->device, id->function)); 104 id->device, id->function));
105 105
@@ -111,12 +111,11 @@ EXPORT_SYMBOL(acpi_get_pci_id);
111int acpi_pci_bind(struct acpi_device *device) 111int acpi_pci_bind(struct acpi_device *device)
112{ 112{
113 int result = 0; 113 int result = 0;
114 acpi_status status = AE_OK; 114 acpi_status status;
115 struct acpi_pci_data *data = NULL; 115 struct acpi_pci_data *data;
116 struct acpi_pci_data *pdata = NULL; 116 struct acpi_pci_data *pdata;
117 char *pathname = NULL; 117 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
118 struct acpi_buffer buffer = { 0, NULL }; 118 acpi_handle handle;
119 acpi_handle handle = NULL;
120 struct pci_dev *dev; 119 struct pci_dev *dev;
121 struct pci_bus *bus; 120 struct pci_bus *bus;
122 121
@@ -124,21 +123,18 @@ int acpi_pci_bind(struct acpi_device *device)
124 if (!device || !device->parent) 123 if (!device || !device->parent)
125 return -EINVAL; 124 return -EINVAL;
126 125
127 pathname = kzalloc(ACPI_PATHNAME_MAX, GFP_KERNEL);
128 if (!pathname)
129 return -ENOMEM;
130 buffer.length = ACPI_PATHNAME_MAX;
131 buffer.pointer = pathname;
132
133 data = kzalloc(sizeof(struct acpi_pci_data), GFP_KERNEL); 126 data = kzalloc(sizeof(struct acpi_pci_data), GFP_KERNEL);
134 if (!data) { 127 if (!data)
135 kfree(pathname);
136 return -ENOMEM; 128 return -ENOMEM;
129
130 status = acpi_get_name(device->handle, ACPI_FULL_PATHNAME, &buffer);
131 if (ACPI_FAILURE(status)) {
132 kfree(data);
133 return -ENODEV;
137 } 134 }
138 135
139 acpi_get_name(device->handle, ACPI_FULL_PATHNAME, &buffer);
140 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Binding PCI device [%s]...\n", 136 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Binding PCI device [%s]...\n",
141 pathname)); 137 (char *)buffer.pointer));
142 138
143 /* 139 /*
144 * Segment & Bus 140 * Segment & Bus
@@ -166,7 +162,7 @@ int acpi_pci_bind(struct acpi_device *device)
166 data->id.device = device->pnp.bus_address >> 16; 162 data->id.device = device->pnp.bus_address >> 16;
167 data->id.function = device->pnp.bus_address & 0xFFFF; 163 data->id.function = device->pnp.bus_address & 0xFFFF;
168 164
169 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "...to %02x:%02x:%02x.%02x\n", 165 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "...to %04x:%02x:%02x.%d\n",
170 data->id.segment, data->id.bus, data->id.device, 166 data->id.segment, data->id.bus, data->id.device,
171 data->id.function)); 167 data->id.function));
172 168
@@ -196,7 +192,7 @@ int acpi_pci_bind(struct acpi_device *device)
196 } 192 }
197 if (!data->dev) { 193 if (!data->dev) {
198 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 194 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
199 "Device %02x:%02x:%02x.%02x not present in PCI namespace\n", 195 "Device %04x:%02x:%02x.%d not present in PCI namespace\n",
200 data->id.segment, data->id.bus, 196 data->id.segment, data->id.bus,
201 data->id.device, data->id.function)); 197 data->id.device, data->id.function));
202 result = -ENODEV; 198 result = -ENODEV;
@@ -204,7 +200,7 @@ int acpi_pci_bind(struct acpi_device *device)
204 } 200 }
205 if (!data->dev->bus) { 201 if (!data->dev->bus) {
206 printk(KERN_ERR PREFIX 202 printk(KERN_ERR PREFIX
207 "Device %02x:%02x:%02x.%02x has invalid 'bus' field\n", 203 "Device %04x:%02x:%02x.%d has invalid 'bus' field\n",
208 data->id.segment, data->id.bus, 204 data->id.segment, data->id.bus,
209 data->id.device, data->id.function); 205 data->id.device, data->id.function);
210 result = -ENODEV; 206 result = -ENODEV;
@@ -219,7 +215,7 @@ int acpi_pci_bind(struct acpi_device *device)
219 */ 215 */
220 if (data->dev->subordinate) { 216 if (data->dev->subordinate) {
221 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 217 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
222 "Device %02x:%02x:%02x.%02x is a PCI bridge\n", 218 "Device %04x:%02x:%02x.%d is a PCI bridge\n",
223 data->id.segment, data->id.bus, 219 data->id.segment, data->id.bus,
224 data->id.device, data->id.function)); 220 data->id.device, data->id.function));
225 data->bus = data->dev->subordinate; 221 data->bus = data->dev->subordinate;
@@ -262,7 +258,7 @@ int acpi_pci_bind(struct acpi_device *device)
262 } 258 }
263 259
264 end: 260 end:
265 kfree(pathname); 261 kfree(buffer.pointer);
266 if (result) 262 if (result)
267 kfree(data); 263 kfree(data);
268 264
@@ -272,25 +268,21 @@ int acpi_pci_bind(struct acpi_device *device)
272static int acpi_pci_unbind(struct acpi_device *device) 268static int acpi_pci_unbind(struct acpi_device *device)
273{ 269{
274 int result = 0; 270 int result = 0;
275 acpi_status status = AE_OK; 271 acpi_status status;
276 struct acpi_pci_data *data = NULL; 272 struct acpi_pci_data *data;
277 char *pathname = NULL; 273 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
278 struct acpi_buffer buffer = { 0, NULL };
279 274
280 275
281 if (!device || !device->parent) 276 if (!device || !device->parent)
282 return -EINVAL; 277 return -EINVAL;
283 278
284 pathname = kzalloc(ACPI_PATHNAME_MAX, GFP_KERNEL); 279 status = acpi_get_name(device->handle, ACPI_FULL_PATHNAME, &buffer);
285 if (!pathname) 280 if (ACPI_FAILURE(status))
286 return -ENOMEM; 281 return -ENODEV;
287 282
288 buffer.length = ACPI_PATHNAME_MAX;
289 buffer.pointer = pathname;
290 acpi_get_name(device->handle, ACPI_FULL_PATHNAME, &buffer);
291 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Unbinding PCI device [%s]...\n", 283 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Unbinding PCI device [%s]...\n",
292 pathname)); 284 (char *) buffer.pointer));
293 kfree(pathname); 285 kfree(buffer.pointer);
294 286
295 status = 287 status =
296 acpi_get_data(device->handle, acpi_pci_data_handler, 288 acpi_get_data(device->handle, acpi_pci_data_handler,
@@ -322,50 +314,44 @@ acpi_pci_bind_root(struct acpi_device *device,
322 struct acpi_pci_id *id, struct pci_bus *bus) 314 struct acpi_pci_id *id, struct pci_bus *bus)
323{ 315{
324 int result = 0; 316 int result = 0;
325 acpi_status status = AE_OK; 317 acpi_status status;
326 struct acpi_pci_data *data = NULL; 318 struct acpi_pci_data *data = NULL;
327 char *pathname = NULL; 319 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
328 struct acpi_buffer buffer = { 0, NULL };
329
330 pathname = kzalloc(ACPI_PATHNAME_MAX, GFP_KERNEL);
331 if (!pathname)
332 return -ENOMEM;
333
334 buffer.length = ACPI_PATHNAME_MAX;
335 buffer.pointer = pathname;
336 320
337 if (!device || !id || !bus) { 321 if (!device || !id || !bus) {
338 kfree(pathname);
339 return -EINVAL; 322 return -EINVAL;
340 } 323 }
341 324
342 data = kzalloc(sizeof(struct acpi_pci_data), GFP_KERNEL); 325 data = kzalloc(sizeof(struct acpi_pci_data), GFP_KERNEL);
343 if (!data) { 326 if (!data)
344 kfree(pathname);
345 return -ENOMEM; 327 return -ENOMEM;
346 }
347 328
348 data->id = *id; 329 data->id = *id;
349 data->bus = bus; 330 data->bus = bus;
350 device->ops.bind = acpi_pci_bind; 331 device->ops.bind = acpi_pci_bind;
351 device->ops.unbind = acpi_pci_unbind; 332 device->ops.unbind = acpi_pci_unbind;
352 333
353 acpi_get_name(device->handle, ACPI_FULL_PATHNAME, &buffer); 334 status = acpi_get_name(device->handle, ACPI_FULL_PATHNAME, &buffer);
335 if (ACPI_FAILURE(status)) {
336 kfree (data);
337 return -ENODEV;
338 }
354 339
355 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Binding PCI root bridge [%s] to " 340 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Binding PCI root bridge [%s] to "
356 "%02x:%02x\n", pathname, id->segment, id->bus)); 341 "%04x:%02x\n", (char *)buffer.pointer,
342 id->segment, id->bus));
357 343
358 status = acpi_attach_data(device->handle, acpi_pci_data_handler, data); 344 status = acpi_attach_data(device->handle, acpi_pci_data_handler, data);
359 if (ACPI_FAILURE(status)) { 345 if (ACPI_FAILURE(status)) {
360 ACPI_EXCEPTION((AE_INFO, status, 346 ACPI_EXCEPTION((AE_INFO, status,
361 "Unable to attach ACPI-PCI context to device %s", 347 "Unable to attach ACPI-PCI context to device %s",
362 pathname)); 348 (char *)buffer.pointer));
363 result = -ENODEV; 349 result = -ENODEV;
364 goto end; 350 goto end;
365 } 351 }
366 352
367 end: 353 end:
368 kfree(pathname); 354 kfree(buffer.pointer);
369 if (result != 0) 355 if (result != 0)
370 kfree(data); 356 kfree(data);
371 357