lkml.org 
[lkml]   [2009]   [Aug]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] ACPI: some issues managing the linked list in acpi_pci_register/unregister_driver
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;
--

\
 
 \ /
  Last update: 2009-08-06 00:13    [W:0.018 / U:0.016 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site