From: james puthukattukaran - Sun Microsystems - Burlington United States <James.Puthukattukaran@Sun.COM>
To: lenb@kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] ACPI: some issues managing the linked list in acpi_pci_register/unregister_driver
Date: Wed, 05 Aug 2009 18:10:06 -0400 [thread overview]
Message-ID: <4A7A033E.2010508@sun.com> (raw)
I submitted an earlier patch on this to lkml with just a single line
initializing the sub_driver variable to NULL. This was insufficient.
This patch fixes some link list management issues in adding a new
acpi_pci_driver type to the sub_driver list. This is against 2.6.30
Signed-off-by: James Puthukattukaran <james.puthukattukaran@sun.com>
--- linux-2.6.30/drivers/acpi/pci_root.c.orig 2009-08-05
12:56:01.000000000 -0400
+++ linux-2.6.30/drivers/acpi/pci_root.c 2009-08-05
14:28:01.000000000 -0400
@@ -76,7 +76,7 @@ struct acpi_pci_root {
static LIST_HEAD(acpi_pci_roots);
-static struct acpi_pci_driver *sub_driver;
+static struct acpi_pci_driver *sub_driver = NULL;
static DEFINE_MUTEX(osc_lock);
int acpi_pci_register_driver(struct acpi_pci_driver *driver)
@@ -84,10 +84,9 @@ int acpi_pci_register_driver(struct acpi
int n = 0;
struct list_head *entry;
- struct acpi_pci_driver **pptr = &sub_driver;
- while (*pptr)
- pptr = &(*pptr)->next;
- *pptr = driver;
+ /* Add to the head of the list */
+ driver->next = sub_driver;
+ sub_driver = driver;
if (!driver->add)
return 0;
@@ -107,15 +106,21 @@ EXPORT_SYMBOL(acpi_pci_register_driver);
void acpi_pci_unregister_driver(struct acpi_pci_driver *driver)
{
struct list_head *entry;
+ struct acpi_pci_driver *pptr, *prev;
- struct acpi_pci_driver **pptr = &sub_driver;
- while (*pptr) {
- if (*pptr == driver)
+ /* Remove driver from the sub_driver list */
+ for (prev = NULL, pptr = sub_driver; pptr;
+ prev = pptr, pptr=pptr->next)
+ {
+ if (pptr == driver) {
+ if (!prev)
+ sub_driver = driver->next;
+ else
+ prev->next = pptr->next;
break;
- pptr = &(*pptr)->next;
+ }
}
- BUG_ON(!*pptr);
- *pptr = (*pptr)->next;
+ BUG_ON(!pptr);
if (!driver->remove)
return;
--
reply other threads:[~2009-08-05 22:10 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=4A7A033E.2010508@sun.com \
--to=james.puthukattukaran@sun.com \
--cc=lenb@kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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