diff options
author | Alex Chiang <achiang@hp.com> | 2009-09-10 14:34:09 -0400 |
---|---|---|
committer | Jesse Barnes <jbarnes@virtuousgeek.org> | 2009-09-14 11:46:58 -0400 |
commit | 7f53866932fd08add06ee2f93ead129949158490 (patch) | |
tree | f01520afe3708a3c79233fa67d50124f0dac6335 /drivers/pci | |
parent | 6edd7679db92376ca54f328d6b0f12291c2dab35 (diff) |
PCI Hotplug: convert acpi_pci_detect_ejectable() to take an acpi_handle
acpi_pci_detect_ejectable() goes through effort to convert its
struct pci_bus arg to an acpi_handle, but every time we use this
interface, we already have the handle available.
So let's just use the handle instead of converting back and forth.
Reviewed-by: Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>
Tested-by: Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>
Signed-off-by: Alex Chiang <achiang@hp.com>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Diffstat (limited to 'drivers/pci')
-rw-r--r-- | drivers/pci/hotplug/acpi_pcihp.c | 12 | ||||
-rw-r--r-- | drivers/pci/hotplug/acpiphp_glue.c | 33 | ||||
-rw-r--r-- | drivers/pci/hotplug/pciehp_acpi.c | 7 |
3 files changed, 21 insertions, 31 deletions
diff --git a/drivers/pci/hotplug/acpi_pcihp.c b/drivers/pci/hotplug/acpi_pcihp.c index eb159587d0bf..ec3c039b7ebd 100644 --- a/drivers/pci/hotplug/acpi_pcihp.c +++ b/drivers/pci/hotplug/acpi_pcihp.c | |||
@@ -500,18 +500,18 @@ check_hotplug(acpi_handle handle, u32 lvl, void *context, void **rv) | |||
500 | 500 | ||
501 | /** | 501 | /** |
502 | * acpi_pci_detect_ejectable - check if the PCI bus has ejectable slots | 502 | * acpi_pci_detect_ejectable - check if the PCI bus has ejectable slots |
503 | * @pbus - PCI bus to scan | 503 | * @handle - handle of the PCI bus to scan |
504 | * | 504 | * |
505 | * Returns 1 if the PCI bus has ACPI based ejectable slots, 0 otherwise. | 505 | * Returns 1 if the PCI bus has ACPI based ejectable slots, 0 otherwise. |
506 | */ | 506 | */ |
507 | int acpi_pci_detect_ejectable(struct pci_bus *pbus) | 507 | int acpi_pci_detect_ejectable(acpi_handle handle) |
508 | { | 508 | { |
509 | acpi_handle handle; | ||
510 | int found = 0; | 509 | int found = 0; |
511 | 510 | ||
512 | if (!(handle = acpi_pci_get_bridge_handle(pbus))) | 511 | if (!handle) |
513 | return 0; | 512 | return found; |
514 | acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, (u32)1, | 513 | |
514 | acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, 1, | ||
515 | check_hotplug, (void *)&found, NULL); | 515 | check_hotplug, (void *)&found, NULL); |
516 | return found; | 516 | return found; |
517 | } | 517 | } |
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c index e72e0adc0681..680c33635b6f 100644 --- a/drivers/pci/hotplug/acpiphp_glue.c +++ b/drivers/pci/hotplug/acpiphp_glue.c | |||
@@ -62,22 +62,6 @@ static void acpiphp_sanitize_bus(struct pci_bus *bus); | |||
62 | static void acpiphp_set_hpp_values(acpi_handle handle, struct pci_bus *bus); | 62 | static void acpiphp_set_hpp_values(acpi_handle handle, struct pci_bus *bus); |
63 | static void handle_hotplug_event_func(acpi_handle handle, u32 type, void *context); | 63 | static void handle_hotplug_event_func(acpi_handle handle, u32 type, void *context); |
64 | 64 | ||
65 | static struct pci_bus *pci_bus_from_handle(acpi_handle handle) | ||
66 | { | ||
67 | struct pci_bus *pbus; | ||
68 | struct acpi_pci_root *root; | ||
69 | |||
70 | root = acpi_pci_find_root(handle); | ||
71 | if (root) | ||
72 | pbus = root->bus; | ||
73 | else { | ||
74 | struct pci_dev *pdev = acpi_get_pci_dev(handle); | ||
75 | pbus = pdev->subordinate; | ||
76 | pci_dev_put(pdev); | ||
77 | } | ||
78 | return pbus; | ||
79 | } | ||
80 | |||
81 | /* callback routine to check for the existence of a pci dock device */ | 65 | /* callback routine to check for the existence of a pci dock device */ |
82 | static acpi_status | 66 | static acpi_status |
83 | is_pci_dock_device(acpi_handle handle, u32 lvl, void *context, void **rv) | 67 | is_pci_dock_device(acpi_handle handle, u32 lvl, void *context, void **rv) |
@@ -279,11 +263,7 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv) | |||
279 | /* see if it's worth looking at this bridge */ | 263 | /* see if it's worth looking at this bridge */ |
280 | static int detect_ejectable_slots(acpi_handle handle) | 264 | static int detect_ejectable_slots(acpi_handle handle) |
281 | { | 265 | { |
282 | int found; | 266 | int found = acpi_pci_detect_ejectable(handle); |
283 | struct pci_bus *pbus; | ||
284 | |||
285 | pbus = pci_bus_from_handle(handle); | ||
286 | found = acpi_pci_detect_ejectable(pbus); | ||
287 | if (!found) { | 267 | if (!found) { |
288 | acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, (u32)1, | 268 | acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, (u32)1, |
289 | is_pci_dock_device, (void *)&found, NULL); | 269 | is_pci_dock_device, (void *)&found, NULL); |
@@ -1364,7 +1344,16 @@ static void acpiphp_sanitize_bus(struct pci_bus *bus) | |||
1364 | /* Program resources in newly inserted bridge */ | 1344 | /* Program resources in newly inserted bridge */ |
1365 | static int acpiphp_configure_bridge (acpi_handle handle) | 1345 | static int acpiphp_configure_bridge (acpi_handle handle) |
1366 | { | 1346 | { |
1367 | struct pci_bus *bus = pci_bus_from_handle(handle); | 1347 | struct pci_bus *bus; |
1348 | |||
1349 | if (acpi_is_root_bridge(handle)) { | ||
1350 | struct acpi_pci_root *root = acpi_pci_find_root(handle); | ||
1351 | bus = root->bus; | ||
1352 | } else { | ||
1353 | struct pci_dev *pdev = acpi_get_pci_dev(handle); | ||
1354 | bus = pdev->subordinate; | ||
1355 | pci_dev_put(pdev); | ||
1356 | } | ||
1368 | 1357 | ||
1369 | pci_bus_size_bridges(bus); | 1358 | pci_bus_size_bridges(bus); |
1370 | pci_bus_assign_resources(bus); | 1359 | pci_bus_assign_resources(bus); |
diff --git a/drivers/pci/hotplug/pciehp_acpi.c b/drivers/pci/hotplug/pciehp_acpi.c index 96048010e7d9..7163e6a6cfae 100644 --- a/drivers/pci/hotplug/pciehp_acpi.c +++ b/drivers/pci/hotplug/pciehp_acpi.c | |||
@@ -47,7 +47,7 @@ int pciehp_acpi_slot_detection_check(struct pci_dev *dev) | |||
47 | { | 47 | { |
48 | if (slot_detection_mode != PCIEHP_DETECT_ACPI) | 48 | if (slot_detection_mode != PCIEHP_DETECT_ACPI) |
49 | return 0; | 49 | return 0; |
50 | if (acpi_pci_detect_ejectable(dev->subordinate)) | 50 | if (acpi_pci_detect_ejectable(DEVICE_ACPI_HANDLE(&dev->dev))) |
51 | return 0; | 51 | return 0; |
52 | return -ENODEV; | 52 | return -ENODEV; |
53 | } | 53 | } |
@@ -76,9 +76,9 @@ static int __init dummy_probe(struct pcie_device *dev) | |||
76 | { | 76 | { |
77 | int pos; | 77 | int pos; |
78 | u32 slot_cap; | 78 | u32 slot_cap; |
79 | acpi_handle handle; | ||
79 | struct slot *slot, *tmp; | 80 | struct slot *slot, *tmp; |
80 | struct pci_dev *pdev = dev->port; | 81 | struct pci_dev *pdev = dev->port; |
81 | struct pci_bus *pbus = pdev->subordinate; | ||
82 | /* Note: pciehp_detect_mode != PCIEHP_DETECT_ACPI here */ | 82 | /* Note: pciehp_detect_mode != PCIEHP_DETECT_ACPI here */ |
83 | if (pciehp_get_hp_hw_control_from_firmware(pdev)) | 83 | if (pciehp_get_hp_hw_control_from_firmware(pdev)) |
84 | return -ENODEV; | 84 | return -ENODEV; |
@@ -94,7 +94,8 @@ static int __init dummy_probe(struct pcie_device *dev) | |||
94 | dup_slot_id++; | 94 | dup_slot_id++; |
95 | } | 95 | } |
96 | list_add_tail(&slot->slot_list, &dummy_slots); | 96 | list_add_tail(&slot->slot_list, &dummy_slots); |
97 | if (!acpi_slot_detected && acpi_pci_detect_ejectable(pbus)) | 97 | handle = DEVICE_ACPI_HANDLE(&pdev->dev); |
98 | if (!acpi_slot_detected && acpi_pci_detect_ejectable(handle)) | ||
98 | acpi_slot_detected = 1; | 99 | acpi_slot_detected = 1; |
99 | return -ENODEV; /* dummy driver always returns error */ | 100 | return -ENODEV; /* dummy driver always returns error */ |
100 | } | 101 | } |