public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
From: Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>
To: MUNEDA Takahiro <muneda.takahiro@jp.fujitsu.com>
Cc: Kristen Accardi <kristen.c.accardi@intel.com>,
	Greg KH <greg@kroah.com>,
	pavel@ucw.cz, pcihpd-discuss@lists.sourceforge.net,
	linux-acpi@vger.kernel.org, len.brown@intel.com
Subject: Re: [Pcihpd-discuss] [PATCH] acpiphp - slot management fix - V2
Date: Tue, 14 Feb 2006 18:17:20 +0900	[thread overview]
Message-ID: <43F1A020.8040706@jp.fujitsu.com> (raw)
In-Reply-To: <87zmkue7kw.wl%muneda.takahiro@jp.fujitsu.com>

MUNEDA Takahiro wrote:
> -static void __exit cleanup_slots (void)
> +void acpiphp_unregister_hotplug_slot(struct acpiphp_slot *acpiphp_slot)
>  {
>  	struct list_head *tmp, *n;
>  	struct slot *slot;
> +	int retval = 0;
>  
>  	list_for_each_safe (tmp, n, &slot_list) {
>  		/* memory will be freed in release_slot callback */
>  		slot = list_entry(tmp, struct slot, slot_list);
> +		if (slot->acpi_slot->sun != acpiphp_slot->sun)
> +			continue;
> +
> +		spin_lock(&list_lock);
>  		list_del(&slot->slot_list);
> -		pci_hp_deregister(slot->hotplug_slot);
> +		spin_unlock(&list_lock);
> +		info ("Slot [%s] unregistered\n", slot->hotplug_slot->name);
> +
> +		retval = pci_hp_deregister(slot->hotplug_slot);
> +		if (retval)
> +			err("pci_hp_deregister failed with error %d\n", retval);
>  	}
>  }

With your patch, I think this list_for_each_safe() loop becomes
needless and it should be removed. In addition, slot_list is no
longer needed.

Here is a sample patch against your patch. Note that I have not
tested it very much.

Thanks,
Kenji Kaneshige


 drivers/pci/hotplug/acpiphp.h      |    3 +--
 drivers/pci/hotplug/acpiphp_core.c |   32 ++++++++------------------------
 2 files changed, 9 insertions(+), 26 deletions(-)

Index: linux-2.6.16-rc2-mm1/drivers/pci/hotplug/acpiphp.h
===================================================================
--- linux-2.6.16-rc2-mm1.orig/drivers/pci/hotplug/acpiphp.h	2006-02-14 17:05:47.000000000 +0900
+++ linux-2.6.16-rc2-mm1/drivers/pci/hotplug/acpiphp.h	2006-02-14 18:02:38.000000000 +0900
@@ -61,8 +61,6 @@
  */
 struct slot {
 	struct hotplug_slot	*hotplug_slot;
-	struct list_head	slot_list;
-
 	struct acpiphp_slot	*acpi_slot;
 };
 
@@ -118,6 +116,7 @@
 	struct acpiphp_bridge *bridge;	/* parent */
 	struct list_head funcs;		/* one slot may have different
 					   objects (i.e. for each function) */
+	struct slot *slot;
 	struct mutex crit_sect;
 
 	u8		device;		/* pci device# */
Index: linux-2.6.16-rc2-mm1/drivers/pci/hotplug/acpiphp_core.c
===================================================================
--- linux-2.6.16-rc2-mm1.orig/drivers/pci/hotplug/acpiphp_core.c	2006-02-14 17:05:47.000000000 +0900
+++ linux-2.6.16-rc2-mm1/drivers/pci/hotplug/acpiphp_core.c	2006-02-14 18:02:50.000000000 +0900
@@ -44,9 +44,6 @@
 #include "pci_hotplug.h"
 #include "acpiphp.h"
 
-static LIST_HEAD(slot_list);
-static DEFINE_SPINLOCK(list_lock);
-
 #define MY_NAME	"acpiphp"
 
 static int debug;
@@ -379,6 +376,8 @@
 	slot->hotplug_slot->info->max_bus_speed = PCI_SPEED_UNKNOWN;
 	slot->hotplug_slot->info->cur_bus_speed = PCI_SPEED_UNKNOWN;
 
+	acpiphp_slot->slot = slot;
+
 	make_slot_name(slot);
 
 	retval = pci_hp_register(slot->hotplug_slot);
@@ -387,10 +386,6 @@
 		goto error_name;
  	}
 
-	/* add slot to our internal list */
-	spin_lock(&list_lock);
-	list_add(&slot->slot_list, &slot_list);
-	spin_unlock(&list_lock);
 	info("Slot [%s] registered\n", slot->hotplug_slot->name);
 
 	return 0;
@@ -409,25 +404,14 @@
 
 void acpiphp_unregister_hotplug_slot(struct acpiphp_slot *acpiphp_slot)
 {
-	struct list_head *tmp, *n;
-	struct slot *slot;
+	struct slot *slot = acpiphp_slot->slot;
 	int retval = 0;
 
-	list_for_each_safe (tmp, n, &slot_list) {
-		/* memory will be freed in release_slot callback */
-		slot = list_entry(tmp, struct slot, slot_list);
-		if (slot->acpi_slot->sun != acpiphp_slot->sun)
-			continue;
-
-		spin_lock(&list_lock);
-		list_del(&slot->slot_list);
-		spin_unlock(&list_lock);
-		info ("Slot [%s] unregistered\n", slot->hotplug_slot->name);
-
-		retval = pci_hp_deregister(slot->hotplug_slot);
-		if (retval)
-			err("pci_hp_deregister failed with error %d\n", retval);
-	}
+	info ("Slot [%s] unregistered\n", slot->hotplug_slot->name);
+
+	retval = pci_hp_deregister(slot->hotplug_slot);
+	if (retval)
+		err("pci_hp_deregister failed with error %d\n", retval);
 }
 
 


  reply	other threads:[~2006-02-14  9:19 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-01-20 10:08 [PATCH 0/7] acpiphp - slots management fix MUNEDA Takahiro
2006-01-20 11:30 ` Pavel Machek
2006-01-23  0:37   ` [Pcihpd-discuss] " MUNEDA Takahiro
2006-01-27  4:14 ` Greg KH
2006-01-29  3:34   ` [Pcihpd-discuss] " MUNEDA Takahiro
2006-01-29  3:45     ` Greg KH
2006-01-31 18:20       ` Kristen Accardi
2006-02-07 20:13         ` Greg KH
2006-02-10 19:28           ` Kristen Accardi
2006-02-13  2:27             ` MUNEDA Takahiro
2006-02-14  7:13               ` [PATCH] acpiphp - slot management fix - V2 MUNEDA Takahiro
2006-02-14  9:17                 ` Kenji Kaneshige [this message]
2006-02-15  9:26                   ` [PATCH] acpiphp - slot management fix - V3 MUNEDA Takahiro

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=43F1A020.8040706@jp.fujitsu.com \
    --to=kaneshige.kenji@jp.fujitsu.com \
    --cc=greg@kroah.com \
    --cc=kristen.c.accardi@intel.com \
    --cc=len.brown@intel.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=muneda.takahiro@jp.fujitsu.com \
    --cc=pavel@ucw.cz \
    --cc=pcihpd-discuss@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox