Commit 056c58e8eb4d6765214757e541b68095e2eb2bd2
Committed by
Jesse Barnes
1 parent
e0d94beead
Exists in
master
and in
7 other branches
PCI: add acpi_find_root_bridge_handle
Consolidate finding of a root bridge and getting its handle to the one inline function. It's cut & pasted on multiple places. Use this new inline in those. Cc: kristen.c.accardi@intel.com Acked-by: Alex Chiang <achiang@hp.com> Signed-off-by: Jiri Slaby <jirislaby@gmail.com> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Showing 3 changed files with 13 additions and 10 deletions Side-by-side Diff
drivers/pci/hotplug/acpi_pcihp.c
... | ... | @@ -404,10 +404,7 @@ |
404 | 404 | * OSHP within the scope of the hotplug controller and its parents, |
405 | 405 | * upto the host bridge under which this controller exists. |
406 | 406 | */ |
407 | - while (pdev->bus->self) | |
408 | - pdev = pdev->bus->self; | |
409 | - handle = acpi_get_pci_rootbridge_handle(pci_domain_nr(pdev->bus), | |
410 | - pdev->bus->number); | |
407 | + handle = acpi_find_root_bridge_handle(pdev); | |
411 | 408 | if (handle) { |
412 | 409 | acpi_get_name(handle, ACPI_FULL_PATHNAME, &string); |
413 | 410 | dbg("Trying to get hotplug control for %s\n", |
drivers/pci/pcie/aer/aerdrv_acpi.c
... | ... | @@ -36,12 +36,7 @@ |
36 | 36 | if (acpi_pci_disabled) |
37 | 37 | return -1; |
38 | 38 | |
39 | - /* Find root host bridge */ | |
40 | - while (pdev->bus->self) | |
41 | - pdev = pdev->bus->self; | |
42 | - handle = acpi_get_pci_rootbridge_handle( | |
43 | - pci_domain_nr(pdev->bus), pdev->bus->number); | |
44 | - | |
39 | + handle = acpi_find_root_bridge_handle(pdev); | |
45 | 40 | if (handle) { |
46 | 41 | pcie_osc_support_set(OSC_EXT_PCI_CONFIG_SUPPORT); |
47 | 42 | status = pci_osc_control_set(handle, |
include/linux/pci-acpi.h
... | ... | @@ -57,6 +57,15 @@ |
57 | 57 | { |
58 | 58 | return __pci_osc_support_set(flags, PCI_EXPRESS_ROOT_HID_STRING); |
59 | 59 | } |
60 | +static inline acpi_handle acpi_find_root_bridge_handle(struct pci_dev *pdev) | |
61 | +{ | |
62 | + /* Find root host bridge */ | |
63 | + while (pdev->bus->self) | |
64 | + pdev = pdev->bus->self; | |
65 | + | |
66 | + return acpi_get_pci_rootbridge_handle(pci_domain_nr(pdev->bus), | |
67 | + pdev->bus->number); | |
68 | +} | |
60 | 69 | #else |
61 | 70 | #if !defined(AE_ERROR) |
62 | 71 | typedef u32 acpi_status; |
... | ... | @@ -66,6 +75,8 @@ |
66 | 75 | {return AE_ERROR;} |
67 | 76 | static inline acpi_status pci_osc_support_set(u32 flags) {return AE_ERROR;} |
68 | 77 | static inline acpi_status pcie_osc_support_set(u32 flags) {return AE_ERROR;} |
78 | +static inline acpi_handle acpi_find_root_bridge_handle(struct pci_dev *pdev) | |
79 | +{ return NULL; } | |
69 | 80 | #endif |
70 | 81 | |
71 | 82 | #endif /* _PCI_ACPI_H_ */ |