diff options
author | Yinghai Lu <yinghai@kernel.org> | 2012-04-02 21:31:53 -0400 |
---|---|---|
committer | Bjorn Helgaas <bhelgaas@google.com> | 2012-04-30 16:52:43 -0400 |
commit | 9a03d28d9490b5a04f8b1d98fc08067c6f4f6189 (patch) | |
tree | 36449cd061e0db5ae75c6cb620f386739bc2feb8 /arch/x86 | |
parent | 4fa2649a01a4357a82dcc60ef8fb7b8c441e64ed (diff) |
x86/PCI: refactor get_current_resources()
Rename get_current_resources() to probe_pci_root_info.
1. Remove resource list head from pci_root_info
2. Make get_current_resources() not pass resources
3. Rename get_current_resources() to probe_pci_root_info()
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Diffstat (limited to 'arch/x86')
-rw-r--r-- | arch/x86/pci/acpi.c | 34 |
1 files changed, 13 insertions, 21 deletions
diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c index a99b7d75f5ca..a858c1d9af53 100644 --- a/arch/x86/pci/acpi.c +++ b/arch/x86/pci/acpi.c | |||
@@ -12,7 +12,6 @@ struct pci_root_info { | |||
12 | char *name; | 12 | char *name; |
13 | unsigned int res_num; | 13 | unsigned int res_num; |
14 | struct resource *res; | 14 | struct resource *res; |
15 | struct list_head *resources; | ||
16 | int busnum; | 15 | int busnum; |
17 | }; | 16 | }; |
18 | 17 | ||
@@ -287,7 +286,8 @@ static void coalesce_windows(struct pci_root_info *info, unsigned long type) | |||
287 | } | 286 | } |
288 | } | 287 | } |
289 | 288 | ||
290 | static void add_resources(struct pci_root_info *info) | 289 | static void add_resources(struct pci_root_info *info, |
290 | struct list_head *resources) | ||
291 | { | 291 | { |
292 | int i; | 292 | int i; |
293 | struct resource *res, *root, *conflict; | 293 | struct resource *res, *root, *conflict; |
@@ -311,7 +311,7 @@ static void add_resources(struct pci_root_info *info) | |||
311 | "ignoring host bridge window %pR (conflicts with %s %pR)\n", | 311 | "ignoring host bridge window %pR (conflicts with %s %pR)\n", |
312 | res, conflict->name, conflict); | 312 | res, conflict->name, conflict); |
313 | else | 313 | else |
314 | pci_add_resource(info->resources, res); | 314 | pci_add_resource(resources, res); |
315 | } | 315 | } |
316 | } | 316 | } |
317 | 317 | ||
@@ -323,41 +323,30 @@ static void free_pci_root_info(struct pci_root_info *info) | |||
323 | } | 323 | } |
324 | 324 | ||
325 | static void | 325 | static void |
326 | get_current_resources(struct pci_root_info *info, | 326 | probe_pci_root_info(struct pci_root_info *info, struct acpi_device *device, |
327 | struct acpi_device *device, int busnum, | 327 | int busnum, int domain) |
328 | int domain, struct list_head *resources) | ||
329 | { | 328 | { |
330 | size_t size; | 329 | size_t size; |
331 | 330 | ||
332 | info->bridge = device; | 331 | info->bridge = device; |
333 | info->res_num = 0; | 332 | info->res_num = 0; |
334 | info->resources = resources; | ||
335 | acpi_walk_resources(device->handle, METHOD_NAME__CRS, count_resource, | 333 | acpi_walk_resources(device->handle, METHOD_NAME__CRS, count_resource, |
336 | info); | 334 | info); |
337 | if (!info->res_num) | 335 | if (!info->res_num) |
338 | return; | 336 | return; |
339 | 337 | ||
340 | size = sizeof(*info->res) * info->res_num; | 338 | size = sizeof(*info->res) * info->res_num; |
339 | info->res_num = 0; | ||
341 | info->res = kmalloc(size, GFP_KERNEL); | 340 | info->res = kmalloc(size, GFP_KERNEL); |
342 | if (!info->res) | 341 | if (!info->res) |
343 | return; | 342 | return; |
344 | 343 | ||
345 | info->name = kasprintf(GFP_KERNEL, "PCI Bus %04x:%02x", domain, busnum); | 344 | info->name = kasprintf(GFP_KERNEL, "PCI Bus %04x:%02x", domain, busnum); |
346 | if (!info->name) | 345 | if (!info->name) |
347 | goto name_alloc_fail; | 346 | return; |
348 | 347 | ||
349 | info->res_num = 0; | ||
350 | acpi_walk_resources(device->handle, METHOD_NAME__CRS, setup_resource, | 348 | acpi_walk_resources(device->handle, METHOD_NAME__CRS, setup_resource, |
351 | info); | 349 | info); |
352 | |||
353 | if (pci_use_crs) { | ||
354 | add_resources(info); | ||
355 | |||
356 | return; | ||
357 | } | ||
358 | |||
359 | name_alloc_fail: | ||
360 | free_pci_root_info(info); | ||
361 | } | 350 | } |
362 | 351 | ||
363 | struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_pci_root *root) | 352 | struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_pci_root *root) |
@@ -422,15 +411,18 @@ struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_pci_root *root) | |||
422 | memcpy(bus->sysdata, sd, sizeof(*sd)); | 411 | memcpy(bus->sysdata, sd, sizeof(*sd)); |
423 | kfree(sd); | 412 | kfree(sd); |
424 | } else { | 413 | } else { |
425 | get_current_resources(&info, device, busnum, domain, | 414 | probe_pci_root_info(&info, device, busnum, domain); |
426 | &resources); | ||
427 | 415 | ||
428 | /* | 416 | /* |
429 | * _CRS with no apertures is normal, so only fall back to | 417 | * _CRS with no apertures is normal, so only fall back to |
430 | * defaults or native bridge info if we're ignoring _CRS. | 418 | * defaults or native bridge info if we're ignoring _CRS. |
431 | */ | 419 | */ |
432 | if (!pci_use_crs) | 420 | if (pci_use_crs) |
421 | add_resources(&info, &resources); | ||
422 | else { | ||
423 | free_pci_root_info(&info); | ||
433 | x86_pci_root_bus_resources(busnum, &resources); | 424 | x86_pci_root_bus_resources(busnum, &resources); |
425 | } | ||
434 | bus = pci_create_root_bus(NULL, busnum, &pci_root_ops, sd, | 426 | bus = pci_create_root_bus(NULL, busnum, &pci_root_ops, sd, |
435 | &resources); | 427 | &resources); |
436 | if (bus) | 428 | if (bus) |