Linux PCI subsystem development
 help / color / mirror / Atom feed
* [PATCH] ACPI / hotplug / PCI: Eliminate acpiphp_dev_to_bridge()
@ 2014-07-14 20:34 Rafael J. Wysocki
  2014-07-15 20:54 ` Bjorn Helgaas
  0 siblings, 1 reply; 2+ messages in thread
From: Rafael J. Wysocki @ 2014-07-14 20:34 UTC (permalink / raw)
  To: ACPI Devel Maling List
  Cc: Linux Kernel Mailing List, Linux PCI, Bjorn Helgaas,
	Mika Westerberg

From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

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.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/pci/hotplug/acpiphp_glue.c |   24 ++++++++----------------
 1 file changed, 8 insertions(+), 16 deletions(-)

Index: linux-pm/drivers/pci/hotplug/acpiphp_glue.c
===================================================================
--- linux-pm.orig/drivers/pci/hotplug/acpiphp_glue.c
+++ 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();
 


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] ACPI / hotplug / PCI: Eliminate acpiphp_dev_to_bridge()
  2014-07-14 20:34 [PATCH] ACPI / hotplug / PCI: Eliminate acpiphp_dev_to_bridge() Rafael J. Wysocki
@ 2014-07-15 20:54 ` Bjorn Helgaas
  0 siblings, 0 replies; 2+ messages in thread
From: Bjorn Helgaas @ 2014-07-15 20:54 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: ACPI Devel Maling List, Linux Kernel Mailing List, Linux PCI,
	Mika Westerberg

On Mon, Jul 14, 2014 at 2:34 PM, Rafael J. Wysocki <rjw@rjwysocki.net> wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>
> 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.
>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

Acked-by: Bjorn Helgaas <bhelgaas@google.com>

> ---
>  drivers/pci/hotplug/acpiphp_glue.c |   24 ++++++++----------------
>  1 file changed, 8 insertions(+), 16 deletions(-)
>
> Index: linux-pm/drivers/pci/hotplug/acpiphp_glue.c
> ===================================================================
> --- linux-pm.orig/drivers/pci/hotplug/acpiphp_glue.c
> +++ 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();
>
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-07-15 20:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-14 20:34 [PATCH] ACPI / hotplug / PCI: Eliminate acpiphp_dev_to_bridge() Rafael J. Wysocki
2014-07-15 20:54 ` Bjorn Helgaas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox