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)
}
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)
......
......@@ -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
......
......@@ -818,10 +818,9 @@ static void cq_detach(struct parport *port)
}
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)
......
......@@ -803,10 +803,9 @@ static void cpia_pp_attach (struct parport *port)
}
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)
......
......@@ -959,10 +959,9 @@ static void w9966_detach(struct parport *port)
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
......
......@@ -48,7 +48,7 @@ static spinlock_t parportlist_lock = SPIN_LOCK_UNLOCKED;
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 parport *port)
{
/* 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 parport_driver *drv)
down(&registration_lock);
list_for_each_entry(port, &portlist, list)
drv->attach(port);
drv->next = driver_chain;
driver_chain = drv;
list_add(&drv->list, &drivers);
up(&registration_lock);
return 0;
......@@ -185,28 +184,12 @@ int parport_register_driver (struct parport_driver *drv)
* 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(&registration_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(&registration_lock);
......
......@@ -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
......
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