Skip to contentSkip to conversation

ACPI / hotplug / PCI: Eliminate acpiphp_dev_to_bridge()

PATCH In review Rafael J. Wysocki 2 participants 2 messages Jul 14, 2014 – Jul 15, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ACPI / hotplug / PCI: Eliminate acpiphp_dev_to_bridge()

From: Rafael J. Wysocki <[email protected]>

Since acpiphp_dev_to_bridge() is only called by acpiphp_check_host_bridge(), move the code from it to that function directly which reduces the call chain depth and makes the code slightly easier to follow.

---
 drivers/pci/hotplug/acpiphp_glue.c |   24 ++++++++----------------
 1 file changed, 8 insertions(+), 16 deletions(-)
drivers/pci/hotplug/acpiphp_glue.c +8 -16
Index: linux-pm/drivers/pci/hotplug/acpiphp_glue.c
===================================================================
@@ -369,20 +369,6 @@ static acpi_status acpiphp_add_context(a
 	return AE_OK;
 }
 
-static struct acpiphp_bridge *acpiphp_dev_to_bridge(struct acpi_device *adev)
-{
-	struct acpiphp_bridge *bridge = NULL;
-
-	acpi_lock_hp_context();
-	if (adev->hp) {
-		bridge = to_acpiphp_root_context(adev->hp)->root_bridge;
-		if (bridge)
-			get_bridge(bridge);
-	}
-	acpi_unlock_hp_context();
-	return bridge;
-}
-
 static void cleanup_bridge(struct acpiphp_bridge *bridge)
 {
 	struct acpiphp_slot *slot;
@@ -753,9 +739,15 @@ static void acpiphp_sanitize_bus(struct
 
 void acpiphp_check_host_bridge(struct acpi_device *adev)
 {
-	struct acpiphp_bridge *bridge;
+	struct acpiphp_bridge *bridge = NULL;
 
-	bridge = acpiphp_dev_to_bridge(adev);
+	acpi_lock_hp_context();
+	if (adev->hp) {
+		bridge = to_acpiphp_root_context(adev->hp)->root_bridge;
+		if (bridge)
+			get_bridge(bridge);
+	}
+	acpi_unlock_hp_context();
 	if (bridge) {
 		pci_lock_rescan_remove();
 
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines · Rafael J. Wysocki

From: Rafael J. Wysocki <[email protected]>

Since acpiphp_dev_to_bridge() is only called by acpiphp_check_host_bridge(), move the code from it to that function directly which reduces the call chain depth and makes the code slightly easier to follow.

Quoted 48 lines
---
 drivers/pci/hotplug/acpiphp_glue.c |   24 ++++++++----------------
 1 file changed, 8 insertions(+), 16 deletions(-)

Index: linux-pm/drivers/pci/hotplug/acpiphp_glue.c
===================================================================

drivers/pci/hotplug/acpiphp_glue.c +8 -16
@@ -369,20 +369,6 @@ static acpi_status acpiphp_add_context(a
        return AE_OK;
 }
 
-static struct acpiphp_bridge *acpiphp_dev_to_bridge(struct acpi_device *adev)
-{
-       struct acpiphp_bridge *bridge = NULL;
-
-       acpi_lock_hp_context();
-       if (adev->hp) {
-               bridge = to_acpiphp_root_context(adev->hp)->root_bridge;
-               if (bridge)
-                       get_bridge(bridge);
-       }
-       acpi_unlock_hp_context();
-       return bridge;
-}
-
 static void cleanup_bridge(struct acpiphp_bridge *bridge)
 {
        struct acpiphp_slot *slot;
@@ -753,9 +739,15 @@ static void acpiphp_sanitize_bus(struct
 
 void acpiphp_check_host_bridge(struct acpi_device *adev)
 {
-       struct acpiphp_bridge *bridge;
+       struct acpiphp_bridge *bridge = NULL;
 
-       bridge = acpiphp_dev_to_bridge(adev);
+       acpi_lock_hp_context();
+       if (adev->hp) {
+               bridge = to_acpiphp_root_context(adev->hp)->root_bridge;
+               if (bridge)
+                       get_bridge(bridge);
+       }
+       acpi_unlock_hp_context();
        if (bridge) {
                pci_lock_rescan_remove();