ACPI / hotplug / PCI: Rework acpiphp_check_host_bridge()
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Mon, 3 Feb 2014 23:45:13 +0000 (00:45 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 6 Feb 2014 16:31:52 +0000 (17:31 +0100)
Since the only existing caller of acpiphp_check_host_bridge(),
which is acpi_pci_root_scan_dependent(), already has a struct
acpi_device pointer needed to obtain the ACPIPHP context, it
doesn't make sense to execute acpi_bus_get_device() on its
handle in acpiphp_handle_to_bridge() just in order to get that
pointer back.

For this reason, modify acpiphp_check_host_bridge() to take
a struct acpi_device pointer as its argument and rearrange the
code accordingly.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Tested-by: Mika Westerberg <mika.westerberg@linux.intel.com>
drivers/acpi/pci_root.c
drivers/pci/hotplug/acpiphp_glue.c
include/linux/pci-acpi.h

index c1c4102e647898717fb8e3c7acc440561d608d8a..c288ff3c6998c76962394439ca5e9aa9da441263 100644 (file)
@@ -51,7 +51,7 @@ static void acpi_pci_root_remove(struct acpi_device *device);
 
 static int acpi_pci_root_scan_dependent(struct acpi_device *adev)
 {
-       acpiphp_check_host_bridge(adev->handle);
+       acpiphp_check_host_bridge(adev);
        return 0;
 }
 
index b7342d2e819bef277de78a11d9cb2b4a3cd2bb9c..11a6117fb358df93d90a44da828b80145f71ae51 100644 (file)
@@ -382,15 +382,11 @@ static acpi_status register_slot(acpi_handle handle, u32 lvl, void *data,
        return AE_OK;
 }
 
-static struct acpiphp_bridge *acpiphp_handle_to_bridge(acpi_handle handle)
+static struct acpiphp_bridge *acpiphp_dev_to_bridge(struct acpi_device *adev)
 {
-       struct acpi_device *adev = acpi_bus_get_acpi_device(handle);
        struct acpiphp_context *context;
        struct acpiphp_bridge *bridge = NULL;
 
-       if (!adev)
-               return NULL;
-
        acpi_lock_hp_context();
        context = acpiphp_get_context(adev);
        if (context) {
@@ -401,7 +397,6 @@ static struct acpiphp_bridge *acpiphp_handle_to_bridge(acpi_handle handle)
                acpiphp_put_context(context);
        }
        acpi_unlock_hp_context();
-       acpi_bus_put_acpi_device(adev);
        return bridge;
 }
 
@@ -768,11 +763,11 @@ static void acpiphp_sanitize_bus(struct pci_bus *bus)
  * ACPI event handlers
  */
 
-void acpiphp_check_host_bridge(acpi_handle handle)
+void acpiphp_check_host_bridge(struct acpi_device *adev)
 {
        struct acpiphp_bridge *bridge;
 
-       bridge = acpiphp_handle_to_bridge(handle);
+       bridge = acpiphp_dev_to_bridge(adev);
        if (bridge) {
                pci_lock_rescan_remove();
 
index 5a462c4e5009d68960525d2167728d59ee75e33b..637a608ded0b0091503db1ac4aaa04cf7155823c 100644 (file)
@@ -59,12 +59,12 @@ static inline void acpi_pci_slot_remove(struct pci_bus *bus) { }
 void acpiphp_init(void);
 void acpiphp_enumerate_slots(struct pci_bus *bus);
 void acpiphp_remove_slots(struct pci_bus *bus);
-void acpiphp_check_host_bridge(acpi_handle handle);
+void acpiphp_check_host_bridge(struct acpi_device *adev);
 #else
 static inline void acpiphp_init(void) { }
 static inline void acpiphp_enumerate_slots(struct pci_bus *bus) { }
 static inline void acpiphp_remove_slots(struct pci_bus *bus) { }
-static inline void acpiphp_check_host_bridge(acpi_handle handle) { }
+static inline void acpiphp_check_host_bridge(struct acpi_device *adev) { }
 #endif
 
 #else  /* CONFIG_ACPI */