Commit 460070ce authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] parport: list cleanups

	parport driver list turned into list.h one; parport/share.c code that
works with that list got cleaned up.
parent 50f734ef
...@@ -862,10 +862,9 @@ static void lp_detach (struct parport *port) ...@@ -862,10 +862,9 @@ static void lp_detach (struct parport *port)
} }
static struct parport_driver lp_driver = { static struct parport_driver lp_driver = {
"lp", .name = "lp",
lp_attach, .attach = lp_attach,
lp_detach, .detach = lp_detach,
NULL
}; };
int __init lp_init (void) int __init lp_init (void)
......
...@@ -463,10 +463,9 @@ tipar_detach(struct parport *port) ...@@ -463,10 +463,9 @@ tipar_detach(struct parport *port)
} }
static struct parport_driver tipar_driver = { static struct parport_driver tipar_driver = {
"tipar", .name = "tipar",
tipar_attach, .attach = tipar_attach,
tipar_detach, .detach = tipar_detach,
NULL
}; };
int __init int __init
......
...@@ -818,10 +818,9 @@ static void cq_detach(struct parport *port) ...@@ -818,10 +818,9 @@ static void cq_detach(struct parport *port)
} }
static struct parport_driver cqcam_driver = { static struct parport_driver cqcam_driver = {
"cqcam", .name = "cqcam",
cq_attach, .attach = cq_attach,
cq_detach, .detach = cq_detach,
NULL
}; };
static int __init cqcam_init (void) static int __init cqcam_init (void)
......
...@@ -803,10 +803,9 @@ static void cpia_pp_attach (struct parport *port) ...@@ -803,10 +803,9 @@ static void cpia_pp_attach (struct parport *port)
} }
static struct parport_driver cpia_pp_driver = { static struct parport_driver cpia_pp_driver = {
"cpia_pp", .name = "cpia_pp",
cpia_pp_attach, .attach = cpia_pp_attach,
cpia_pp_detach, .detach = cpia_pp_detach,
NULL
}; };
int cpia_pp_init(void) int cpia_pp_init(void)
......
...@@ -959,10 +959,9 @@ static void w9966_detach(struct parport *port) ...@@ -959,10 +959,9 @@ static void w9966_detach(struct parport *port)
static struct parport_driver w9966_ppd = { static struct parport_driver w9966_ppd = {
W9966_DRIVERNAME, .name = W9966_DRIVERNAME,
w9966_attach, .attach = w9966_attach,
w9966_detach, .detach = w9966_detach,
NULL
}; };
// Module entry point // Module entry point
......
...@@ -48,7 +48,7 @@ static spinlock_t parportlist_lock = SPIN_LOCK_UNLOCKED; ...@@ -48,7 +48,7 @@ static spinlock_t parportlist_lock = SPIN_LOCK_UNLOCKED;
static LIST_HEAD(all_ports); static LIST_HEAD(all_ports);
static spinlock_t full_list_lock = SPIN_LOCK_UNLOCKED; 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); static DECLARE_MUTEX(registration_lock);
...@@ -105,16 +105,16 @@ static void attach_driver_chain(struct parport *port) ...@@ -105,16 +105,16 @@ static void attach_driver_chain(struct parport *port)
{ {
/* caller has exclusive registration_lock */ /* caller has exclusive registration_lock */
struct parport_driver *drv; struct parport_driver *drv;
for (drv = driver_chain; drv; drv = drv->next) list_for_each_entry(drv, &drivers, list)
drv->attach(port); drv->attach(port);
} }
/* Call detach(port) for each registered driver. */ /* Call detach(port) for each registered driver. */
static void detach_driver_chain(struct parport *port) static void detach_driver_chain(struct parport *port)
{ {
/* caller has exclusive registration_lock */
struct parport_driver *drv; 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); drv->detach (port);
} }
...@@ -161,8 +161,7 @@ int parport_register_driver (struct parport_driver *drv) ...@@ -161,8 +161,7 @@ int parport_register_driver (struct parport_driver *drv)
down(&registration_lock); down(&registration_lock);
list_for_each_entry(port, &portlist, list) list_for_each_entry(port, &portlist, list)
drv->attach(port); drv->attach(port);
drv->next = driver_chain; list_add(&drv->list, &drivers);
driver_chain = drv;
up(&registration_lock); up(&registration_lock);
return 0; return 0;
...@@ -185,28 +184,12 @@ int parport_register_driver (struct parport_driver *drv) ...@@ -185,28 +184,12 @@ int parport_register_driver (struct parport_driver *drv)
* finished by the time this function returns. * 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; struct parport *port;
down(&registration_lock); down(&registration_lock);
drv = driver_chain; list_del_init(&drv->list);
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_for_each_entry(port, &portlist, list) list_for_each_entry(port, &portlist, list)
drv->detach(port); drv->detach(port);
up(&registration_lock); up(&registration_lock);
......
...@@ -322,7 +322,7 @@ struct parport_driver { ...@@ -322,7 +322,7 @@ struct parport_driver {
const char *name; const char *name;
void (*attach) (struct parport *); void (*attach) (struct parport *);
void (*detach) (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 /* parport_register_port registers a new parallel port at the given
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment