diff mbox

[RFC,6/8] ACPI / hotplug / PCI: Drop acpiphp_handle_to_bridge()

Message ID 3804403.VVlzfJfUyu@vostro.rjw.lan (mailing list archive)
State New, archived
Delegated to: Bjorn Helgaas
Headers show

Commit Message

Rafael Wysocki July 9, 2013, 12:20 a.m. UTC
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

Using the hotplug context objects introduced previously rework the
ACPI-based PCI hotplug (acpiphp) core code to get to acpiphp_bridge
objects associated with hotplug bridges from those context objects
rather than from the global list of hotplug bridges.

After that the acpiphp_handle_to_bridge() is not necessary any more,
so drop it.

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


--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Mika Westerberg July 9, 2013, 9:37 a.m. UTC | #1
On Tue, Jul 09, 2013 at 02:20:31AM +0200, Rafael J. Wysocki wrote:
> @@ -953,37 +937,49 @@ static void acpiphp_sanitize_bus(struct
>   * ACPI event handlers
>   */
>  
> -static acpi_status
> -check_sub_bridges(acpi_handle handle, u32 lvl, void *context, void **rv)
> +static acpi_status check_sub_bridges(acpi_handle handle, u32 lvl, void *data,
> +				     void **rv)
>  {
> -	struct acpiphp_bridge *bridge;
> -	char objname[64];
> -	struct acpi_buffer buffer = { .length = sizeof(objname),
> -				      .pointer = objname };
> +	struct acpiphp_context *context = acpiphp_get_context(handle);
> +
> +	if (!context)
> +		return AE_OK;
>  
> -	bridge = acpiphp_handle_to_bridge(handle);
> -	if (bridge) {
> +	if (context->bridge) {
> +		struct acpiphp_bridge *bridge = context->bridge;
> +		char objname[64];
> +		struct acpi_buffer buffer = { .length = sizeof(objname),
> +					      .pointer = objname };
> +
> +		get_bridge(bridge);
>  		acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer);
> -		dbg("%s: re-enumerating slots under %s\n",
> -			__func__, objname);
> +		dbg("%s: re-enumerating slots under %s\n", __func__, objname);

Although not related to this patch directly, how about using
acpi_handle_debug() or similar here?

>  		acpiphp_check_bridge(bridge);
>  		put_bridge(bridge);
>  	}
> +	acpiphp_put_context(context);
>  	return AE_OK ;
>  }
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Rafael Wysocki July 9, 2013, 11:46 p.m. UTC | #2
On Tuesday, July 09, 2013 12:37:26 PM Mika Westerberg wrote:
> On Tue, Jul 09, 2013 at 02:20:31AM +0200, Rafael J. Wysocki wrote:
> > @@ -953,37 +937,49 @@ static void acpiphp_sanitize_bus(struct
> >   * ACPI event handlers
> >   */
> >  
> > -static acpi_status
> > -check_sub_bridges(acpi_handle handle, u32 lvl, void *context, void **rv)
> > +static acpi_status check_sub_bridges(acpi_handle handle, u32 lvl, void *data,
> > +				     void **rv)
> >  {
> > -	struct acpiphp_bridge *bridge;
> > -	char objname[64];
> > -	struct acpi_buffer buffer = { .length = sizeof(objname),
> > -				      .pointer = objname };
> > +	struct acpiphp_context *context = acpiphp_get_context(handle);
> > +
> > +	if (!context)
> > +		return AE_OK;
> >  
> > -	bridge = acpiphp_handle_to_bridge(handle);
> > -	if (bridge) {
> > +	if (context->bridge) {
> > +		struct acpiphp_bridge *bridge = context->bridge;
> > +		char objname[64];
> > +		struct acpi_buffer buffer = { .length = sizeof(objname),
> > +					      .pointer = objname };
> > +
> > +		get_bridge(bridge);
> >  		acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer);
> > -		dbg("%s: re-enumerating slots under %s\n",
> > -			__func__, objname);
> > +		dbg("%s: re-enumerating slots under %s\n", __func__, objname);
> 
> Although not related to this patch directly, how about using
> acpi_handle_debug() or similar here?

Well, we don't have acpi_handle_debug() and I remember there was a reason why,
but I can't recall what the reason was at the moment. :-)

> >  		acpiphp_check_bridge(bridge);
> >  		put_bridge(bridge);
> >  	}
> > +	acpiphp_put_context(context);
> >  	return AE_OK ;
> >  }
diff mbox

Patch

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
@@ -441,22 +441,6 @@  static int detect_ejectable_slots(acpi_h
 	return found;
 }
 
-static struct acpiphp_bridge *acpiphp_handle_to_bridge(acpi_handle handle)
-{
-	struct acpiphp_bridge *bridge;
-
-	mutex_lock(&bridge_mutex);
-	list_for_each_entry(bridge, &bridge_list, list)
-		if (bridge->handle == handle) {
-			get_bridge(bridge);
-			mutex_unlock(&bridge_mutex);
-			return bridge;
-		}
-	mutex_unlock(&bridge_mutex);
-
-	return NULL;
-}
-
 static void cleanup_bridge(struct acpiphp_bridge *bridge)
 {
 	struct acpiphp_slot *slot;
@@ -953,37 +937,49 @@  static void acpiphp_sanitize_bus(struct
  * ACPI event handlers
  */
 
-static acpi_status
-check_sub_bridges(acpi_handle handle, u32 lvl, void *context, void **rv)
+static acpi_status check_sub_bridges(acpi_handle handle, u32 lvl, void *data,
+				     void **rv)
 {
-	struct acpiphp_bridge *bridge;
-	char objname[64];
-	struct acpi_buffer buffer = { .length = sizeof(objname),
-				      .pointer = objname };
+	struct acpiphp_context *context = acpiphp_get_context(handle);
+
+	if (!context)
+		return AE_OK;
 
-	bridge = acpiphp_handle_to_bridge(handle);
-	if (bridge) {
+	if (context->bridge) {
+		struct acpiphp_bridge *bridge = context->bridge;
+		char objname[64];
+		struct acpi_buffer buffer = { .length = sizeof(objname),
+					      .pointer = objname };
+
+		get_bridge(bridge);
 		acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer);
-		dbg("%s: re-enumerating slots under %s\n",
-			__func__, objname);
+		dbg("%s: re-enumerating slots under %s\n", __func__, objname);
 		acpiphp_check_bridge(bridge);
 		put_bridge(bridge);
 	}
+	acpiphp_put_context(context);
 	return AE_OK ;
 }
 
 void acpiphp_check_host_bridge(acpi_handle handle)
 {
-	struct acpiphp_bridge *bridge;
+	struct acpiphp_context *context = acpiphp_get_context(handle);
 
-	bridge = acpiphp_handle_to_bridge(handle);
-	if (bridge) {
+	if (!context)
+		return;
+
+	if (context->bridge) {
+		struct acpiphp_bridge *bridge = context->bridge;
+
+		get_bridge(bridge);
 		acpiphp_check_bridge(bridge);
 		put_bridge(bridge);
 	}
 
 	acpi_walk_namespace(ACPI_TYPE_DEVICE, handle,
 		ACPI_UINT32_MAX, check_sub_bridges, NULL, NULL, NULL);
+
+	acpiphp_put_context(context);
 }
 
 static void _handle_hotplug_event_bridge(struct work_struct *work)