From: parport driver list turned into list.h one; parport/share.c code that works with that list got cleaned up. --- drivers/char/lp.c | 7 +++---- drivers/char/tipar.c | 7 +++---- drivers/media/video/c-qcam.c | 7 +++---- drivers/media/video/cpia_pp.c | 7 +++---- drivers/media/video/w9966.c | 7 +++---- drivers/parport/share.c | 31 +++++++------------------------ include/linux/parport.h | 2 +- 7 files changed, 23 insertions(+), 45 deletions(-) diff -puN drivers/char/lp.c~parport-12-driver-list-cleanup drivers/char/lp.c --- 25/drivers/char/lp.c~parport-12-driver-list-cleanup 2004-02-19 23:25:31.000000000 -0800 +++ 25-akpm/drivers/char/lp.c 2004-02-19 23:25:31.000000000 -0800 @@ -862,10 +862,9 @@ static void lp_detach (struct parport *p } static struct parport_driver lp_driver = { - "lp", - lp_attach, - lp_detach, - NULL + .name = "lp", + .attach = lp_attach, + .detach = lp_detach, }; int __init lp_init (void) diff -puN drivers/char/tipar.c~parport-12-driver-list-cleanup drivers/char/tipar.c --- 25/drivers/char/tipar.c~parport-12-driver-list-cleanup 2004-02-19 23:25:31.000000000 -0800 +++ 25-akpm/drivers/char/tipar.c 2004-02-19 23:25:31.000000000 -0800 @@ -463,10 +463,9 @@ tipar_detach(struct parport *port) } static struct parport_driver tipar_driver = { - "tipar", - tipar_attach, - tipar_detach, - NULL + .name = "tipar", + .attach = tipar_attach, + .detach = tipar_detach, }; int __init diff -puN drivers/media/video/cpia_pp.c~parport-12-driver-list-cleanup drivers/media/video/cpia_pp.c --- 25/drivers/media/video/cpia_pp.c~parport-12-driver-list-cleanup 2004-02-19 23:25:31.000000000 -0800 +++ 25-akpm/drivers/media/video/cpia_pp.c 2004-02-19 23:25:31.000000000 -0800 @@ -803,10 +803,9 @@ static void cpia_pp_attach (struct parpo } static struct parport_driver cpia_pp_driver = { - "cpia_pp", - cpia_pp_attach, - cpia_pp_detach, - NULL + .name = "cpia_pp", + .attach = cpia_pp_attach, + .detach = cpia_pp_detach, }; int cpia_pp_init(void) diff -puN drivers/media/video/c-qcam.c~parport-12-driver-list-cleanup drivers/media/video/c-qcam.c --- 25/drivers/media/video/c-qcam.c~parport-12-driver-list-cleanup 2004-02-19 23:25:31.000000000 -0800 +++ 25-akpm/drivers/media/video/c-qcam.c 2004-02-19 23:25:31.000000000 -0800 @@ -818,10 +818,9 @@ static void cq_detach(struct parport *po } static struct parport_driver cqcam_driver = { - "cqcam", - cq_attach, - cq_detach, - NULL + .name = "cqcam", + .attach = cq_attach, + .detach = cq_detach, }; static int __init cqcam_init (void) diff -puN drivers/media/video/w9966.c~parport-12-driver-list-cleanup drivers/media/video/w9966.c --- 25/drivers/media/video/w9966.c~parport-12-driver-list-cleanup 2004-02-19 23:25:31.000000000 -0800 +++ 25-akpm/drivers/media/video/w9966.c 2004-02-19 23:25:31.000000000 -0800 @@ -959,10 +959,9 @@ static void w9966_detach(struct parport static struct parport_driver w9966_ppd = { - W9966_DRIVERNAME, - w9966_attach, - w9966_detach, - NULL + .name = W9966_DRIVERNAME, + .attach = w9966_attach, + .detach = w9966_detach, }; // Module entry point diff -puN drivers/parport/share.c~parport-12-driver-list-cleanup drivers/parport/share.c --- 25/drivers/parport/share.c~parport-12-driver-list-cleanup 2004-02-19 23:25:31.000000000 -0800 +++ 25-akpm/drivers/parport/share.c 2004-02-19 23:25:31.000000000 -0800 @@ -48,7 +48,7 @@ static spinlock_t parportlist_lock = SPI static LIST_HEAD(all_ports); static spinlock_t full_list_lock = SPIN_LOCK_UNLOCKED; -static struct parport_driver *driver_chain = NULL; +static LIST_HEAD(drivers); static DECLARE_MUTEX(registration_lock); @@ -105,16 +105,16 @@ static void attach_driver_chain(struct p { /* caller has exclusive registration_lock */ struct parport_driver *drv; - for (drv = driver_chain; drv; drv = drv->next) + list_for_each_entry(drv, &drivers, list) drv->attach(port); } /* Call detach(port) for each registered driver. */ static void detach_driver_chain(struct parport *port) { - /* caller has exclusive registration_lock */ struct parport_driver *drv; - for (drv = driver_chain; drv; drv = drv->next) + /* caller has exclusive registration_lock */ + list_for_each_entry(drv, &drivers, list) drv->detach (port); } @@ -161,8 +161,7 @@ int parport_register_driver (struct parp down(®istration_lock); list_for_each_entry(port, &portlist, list) drv->attach(port); - drv->next = driver_chain; - driver_chain = drv; + list_add(&drv->list, &drivers); up(®istration_lock); return 0; @@ -185,28 +184,12 @@ int parport_register_driver (struct parp * finished by the time this function returns. **/ -void parport_unregister_driver (struct parport_driver *arg) +void parport_unregister_driver (struct parport_driver *drv) { - struct parport_driver *drv, *olddrv = NULL; struct parport *port; down(®istration_lock); - drv = driver_chain; - while (drv) { - if (drv == arg) { - if (olddrv) - olddrv->next = drv->next; - else - driver_chain = drv->next; - break; - } - olddrv = drv; - drv = drv->next; - } - - /* Call the driver's detach routine for each - * port to clean up any resources that the - * attach routine acquired. */ + list_del_init(&drv->list); list_for_each_entry(port, &portlist, list) drv->detach(port); up(®istration_lock); diff -puN include/linux/parport.h~parport-12-driver-list-cleanup include/linux/parport.h --- 25/include/linux/parport.h~parport-12-driver-list-cleanup 2004-02-19 23:25:31.000000000 -0800 +++ 25-akpm/include/linux/parport.h 2004-02-19 23:25:31.000000000 -0800 @@ -322,7 +322,7 @@ struct parport_driver { const char *name; void (*attach) (struct parport *); void (*detach) (struct parport *); - struct parport_driver *next; + struct list_head list; }; /* parport_register_port registers a new parallel port at the given _