* [PATCH] acpi: fix single linked list manipulation
@ 2006-10-28 18:53 Akinobu Mita
2006-10-28 19:02 ` Christoph Hellwig
0 siblings, 1 reply; 4+ messages in thread
From: Akinobu Mita @ 2006-10-28 18:53 UTC (permalink / raw)
To: linux-kernel, linux-acpi; +Cc: Len Brown
This patch fixes single linked list manipulation for sub_driver.
If the remving entry is not on the head of the sub_driver list,
it goes into infinate loop.
Though that infinate loop doesn't happen. Because the only user of
acpi_pci_register_dirver() is acpiphp.
Cc: Len Brown <len.brown@intel.com>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
drivers/acpi/pci_root.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
Index: work-fault-inject/drivers/acpi/pci_root.c
===================================================================
--- work-fault-inject.orig/drivers/acpi/pci_root.c
+++ work-fault-inject/drivers/acpi/pci_root.c
@@ -98,11 +98,12 @@ void acpi_pci_unregister_driver(struct a
struct acpi_pci_driver **pptr = &sub_driver;
while (*pptr) {
- if (*pptr != driver)
- continue;
- *pptr = (*pptr)->next;
- break;
+ if (*pptr == driver)
+ break;
+ pptr = &(*pptr)->next;
}
+ BUG_ON(!*pptr);
+ *pptr = (*pptr)->next;
if (!driver->remove)
return;
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] acpi: fix single linked list manipulation 2006-10-28 18:53 [PATCH] acpi: fix single linked list manipulation Akinobu Mita @ 2006-10-28 19:02 ` Christoph Hellwig 2006-10-29 13:40 ` [PATCH -mm] acpi: use list.h API for sub_driver list Akinobu Mita 0 siblings, 1 reply; 4+ messages in thread From: Christoph Hellwig @ 2006-10-28 19:02 UTC (permalink / raw) To: Akinobu Mita, linux-kernel, linux-acpi, Len Brown On Sun, Oct 29, 2006 at 03:53:13AM +0900, Akinobu Mita wrote: > This patch fixes single linked list manipulation for sub_driver. > If the remving entry is not on the head of the sub_driver list, > it goes into infinate loop. > > Though that infinate loop doesn't happen. Because the only user of > acpi_pci_register_dirver() is acpiphp. Any chance to just switch the driver to use the list.h APIs instead of opencoding lists? ^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH -mm] acpi: use list.h API for sub_driver list 2006-10-28 19:02 ` Christoph Hellwig @ 2006-10-29 13:40 ` Akinobu Mita 2006-10-29 13:42 ` Christoph Hellwig 0 siblings, 1 reply; 4+ messages in thread From: Akinobu Mita @ 2006-10-29 13:40 UTC (permalink / raw) To: Christoph Hellwig, linux-kernel, linux-acpi, Len Brown On Sat, Oct 28, 2006 at 08:02:54PM +0100, Christoph Hellwig wrote: > Any chance to just switch the driver to use the list.h APIs instead > of opencoding lists? Subject: [PATCH -mm] acpi: use list.h API for sub_driver list Use the list.h APIs instead of opencoding lists. Cc: Len Brown <len.brown@intel.com> Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Index: work-fault-inject/drivers/acpi/pci_root.c =================================================================== --- work-fault-inject.orig/drivers/acpi/pci_root.c +++ work-fault-inject/drivers/acpi/pci_root.c @@ -65,17 +65,14 @@ struct acpi_pci_root { static LIST_HEAD(acpi_pci_roots); -static struct acpi_pci_driver *sub_driver; +static LIST_HEAD(sub_driver); int acpi_pci_register_driver(struct acpi_pci_driver *driver) { int n = 0; struct list_head *entry; - struct acpi_pci_driver **pptr = &sub_driver; - while (*pptr) - pptr = &(*pptr)->next; - *pptr = driver; + list_add_tail(&driver->list, &sub_driver); if (!driver->add) return 0; @@ -96,14 +93,7 @@ void acpi_pci_unregister_driver(struct a { struct list_head *entry; - struct acpi_pci_driver **pptr = &sub_driver; - while (*pptr) { - if (*pptr == driver) - break; - pptr = &(*pptr)->next; - } - BUG_ON(!*pptr); - *pptr = (*pptr)->next; + list_del(&driver->list); if (!driver->remove) return; Index: work-fault-inject/include/linux/acpi.h =================================================================== --- work-fault-inject.orig/include/linux/acpi.h +++ work-fault-inject/include/linux/acpi.h @@ -480,7 +480,7 @@ void acpi_penalize_isa_irq(int irq, int void acpi_pci_irq_disable (struct pci_dev *dev); struct acpi_pci_driver { - struct acpi_pci_driver *next; + struct list_head list; int (*add)(acpi_handle handle); void (*remove)(acpi_handle handle); }; ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH -mm] acpi: use list.h API for sub_driver list 2006-10-29 13:40 ` [PATCH -mm] acpi: use list.h API for sub_driver list Akinobu Mita @ 2006-10-29 13:42 ` Christoph Hellwig 0 siblings, 0 replies; 4+ messages in thread From: Christoph Hellwig @ 2006-10-29 13:42 UTC (permalink / raw) To: Akinobu Mita, Christoph Hellwig, linux-kernel, linux-acpi, Len Brown On Sun, Oct 29, 2006 at 10:40:03PM +0900, Akinobu Mita wrote: > On Sat, Oct 28, 2006 at 08:02:54PM +0100, Christoph Hellwig wrote: > > Any chance to just switch the driver to use the list.h APIs instead > > of opencoding lists? > > Subject: [PATCH -mm] acpi: use list.h API for sub_driver list > > Use the list.h APIs instead of opencoding lists. Maybe it's just me but I don't see a place where we actually ever iterate this list. Len, do you plan to introduce users of the list anytime soon? In that case the patch below looks good to me, else we should just rip it out completely. > Cc: Len Brown <len.brown@intel.com> > Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> > > Index: work-fault-inject/drivers/acpi/pci_root.c > =================================================================== > --- work-fault-inject.orig/drivers/acpi/pci_root.c > +++ work-fault-inject/drivers/acpi/pci_root.c > @@ -65,17 +65,14 @@ struct acpi_pci_root { > > static LIST_HEAD(acpi_pci_roots); > > -static struct acpi_pci_driver *sub_driver; > +static LIST_HEAD(sub_driver); > > int acpi_pci_register_driver(struct acpi_pci_driver *driver) > { > int n = 0; > struct list_head *entry; > > - struct acpi_pci_driver **pptr = &sub_driver; > - while (*pptr) > - pptr = &(*pptr)->next; > - *pptr = driver; > + list_add_tail(&driver->list, &sub_driver); > > if (!driver->add) > return 0; > @@ -96,14 +93,7 @@ void acpi_pci_unregister_driver(struct a > { > struct list_head *entry; > > - struct acpi_pci_driver **pptr = &sub_driver; > - while (*pptr) { > - if (*pptr == driver) > - break; > - pptr = &(*pptr)->next; > - } > - BUG_ON(!*pptr); > - *pptr = (*pptr)->next; > + list_del(&driver->list); > > if (!driver->remove) > return; > Index: work-fault-inject/include/linux/acpi.h > =================================================================== > --- work-fault-inject.orig/include/linux/acpi.h > +++ work-fault-inject/include/linux/acpi.h > @@ -480,7 +480,7 @@ void acpi_penalize_isa_irq(int irq, int > void acpi_pci_irq_disable (struct pci_dev *dev); > > struct acpi_pci_driver { > - struct acpi_pci_driver *next; > + struct list_head list; > int (*add)(acpi_handle handle); > void (*remove)(acpi_handle handle); > }; ---end quoted text--- ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2006-10-29 13:42 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2006-10-28 18:53 [PATCH] acpi: fix single linked list manipulation Akinobu Mita 2006-10-28 19:02 ` Christoph Hellwig 2006-10-29 13:40 ` [PATCH -mm] acpi: use list.h API for sub_driver list Akinobu Mita 2006-10-29 13:42 ` Christoph Hellwig
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox