Commit 9717fb8b authored by Jan Kiszka's avatar Jan Kiszka Committed by David S. Miller

CAPI: Convert capi drivers rwlock into mutex

Turn the lock protecting registered capi drivers into a mutex and apply
it consistently.
Signed-off-by: default avatarJan Kiszka <jan.kiszka@web.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 52253031
...@@ -61,7 +61,7 @@ static char capi_manufakturer[64] = "AVM Berlin"; ...@@ -61,7 +61,7 @@ static char capi_manufakturer[64] = "AVM Berlin";
#define NCCI2CTRL(ncci) (((ncci) >> 24) & 0x7f) #define NCCI2CTRL(ncci) (((ncci) >> 24) & 0x7f)
LIST_HEAD(capi_drivers); LIST_HEAD(capi_drivers);
DEFINE_RWLOCK(capi_drivers_list_lock); DEFINE_MUTEX(capi_drivers_lock);
static DEFINE_RWLOCK(application_lock); static DEFINE_RWLOCK(application_lock);
static DEFINE_MUTEX(controller_mutex); static DEFINE_MUTEX(controller_mutex);
...@@ -540,11 +540,9 @@ EXPORT_SYMBOL(detach_capi_ctr); ...@@ -540,11 +540,9 @@ EXPORT_SYMBOL(detach_capi_ctr);
void register_capi_driver(struct capi_driver *driver) void register_capi_driver(struct capi_driver *driver)
{ {
unsigned long flags; mutex_lock(&capi_drivers_lock);
write_lock_irqsave(&capi_drivers_list_lock, flags);
list_add_tail(&driver->list, &capi_drivers); list_add_tail(&driver->list, &capi_drivers);
write_unlock_irqrestore(&capi_drivers_list_lock, flags); mutex_unlock(&capi_drivers_lock);
} }
EXPORT_SYMBOL(register_capi_driver); EXPORT_SYMBOL(register_capi_driver);
...@@ -558,11 +556,9 @@ EXPORT_SYMBOL(register_capi_driver); ...@@ -558,11 +556,9 @@ EXPORT_SYMBOL(register_capi_driver);
void unregister_capi_driver(struct capi_driver *driver) void unregister_capi_driver(struct capi_driver *driver)
{ {
unsigned long flags; mutex_lock(&capi_drivers_lock);
write_lock_irqsave(&capi_drivers_list_lock, flags);
list_del(&driver->list); list_del(&driver->list);
write_unlock_irqrestore(&capi_drivers_list_lock, flags); mutex_unlock(&capi_drivers_lock);
} }
EXPORT_SYMBOL(unregister_capi_driver); EXPORT_SYMBOL(unregister_capi_driver);
...@@ -899,7 +895,6 @@ static int old_capi_manufacturer(unsigned int cmd, void __user *data) ...@@ -899,7 +895,6 @@ static int old_capi_manufacturer(unsigned int cmd, void __user *data)
struct capi_driver *driver = NULL; struct capi_driver *driver = NULL;
capiloaddata ldata; capiloaddata ldata;
struct list_head *l; struct list_head *l;
unsigned long flags;
int retval; int retval;
switch (cmd) { switch (cmd) {
...@@ -919,7 +914,8 @@ static int old_capi_manufacturer(unsigned int cmd, void __user *data) ...@@ -919,7 +914,8 @@ static int old_capi_manufacturer(unsigned int cmd, void __user *data)
cparams.irq = cdef.irq; cparams.irq = cdef.irq;
cparams.cardnr = cdef.cardnr; cparams.cardnr = cdef.cardnr;
read_lock_irqsave(&capi_drivers_list_lock, flags); mutex_lock(&capi_drivers_lock);
switch (cdef.cardtype) { switch (cdef.cardtype) {
case AVM_CARDTYPE_B1: case AVM_CARDTYPE_B1:
list_for_each(l, &capi_drivers) { list_for_each(l, &capi_drivers) {
...@@ -940,18 +936,15 @@ static int old_capi_manufacturer(unsigned int cmd, void __user *data) ...@@ -940,18 +936,15 @@ static int old_capi_manufacturer(unsigned int cmd, void __user *data)
break; break;
} }
if (!driver) { if (!driver) {
read_unlock_irqrestore(&capi_drivers_list_lock, flags);
printk(KERN_ERR "kcapi: driver not loaded.\n"); printk(KERN_ERR "kcapi: driver not loaded.\n");
return -EIO; retval = -EIO;
} } else if (!driver->add_card) {
if (!driver->add_card) {
read_unlock_irqrestore(&capi_drivers_list_lock, flags);
printk(KERN_ERR "kcapi: driver has no add card function.\n"); printk(KERN_ERR "kcapi: driver has no add card function.\n");
return -EIO; retval = -EIO;
} } else
retval = driver->add_card(driver, &cparams); retval = driver->add_card(driver, &cparams);
read_unlock_irqrestore(&capi_drivers_list_lock, flags);
mutex_unlock(&capi_drivers_lock);
return retval; return retval;
case AVMB1_LOAD: case AVMB1_LOAD:
...@@ -1107,6 +1100,8 @@ int capi20_manufacturer(unsigned int cmd, void __user *data) ...@@ -1107,6 +1100,8 @@ int capi20_manufacturer(unsigned int cmd, void __user *data)
cparams.cardtype = 0; cparams.cardtype = 0;
cdef.driver[sizeof(cdef.driver)-1] = 0; cdef.driver[sizeof(cdef.driver)-1] = 0;
mutex_lock(&capi_drivers_lock);
list_for_each(l, &capi_drivers) { list_for_each(l, &capi_drivers) {
driver = list_entry(l, struct capi_driver, list); driver = list_entry(l, struct capi_driver, list);
if (strcmp(driver->name, cdef.driver) == 0) if (strcmp(driver->name, cdef.driver) == 0)
...@@ -1115,15 +1110,15 @@ int capi20_manufacturer(unsigned int cmd, void __user *data) ...@@ -1115,15 +1110,15 @@ int capi20_manufacturer(unsigned int cmd, void __user *data)
if (driver == NULL) { if (driver == NULL) {
printk(KERN_ERR "kcapi: driver \"%s\" not loaded.\n", printk(KERN_ERR "kcapi: driver \"%s\" not loaded.\n",
cdef.driver); cdef.driver);
return -ESRCH; retval = -ESRCH;
} } else if (!driver->add_card) {
if (!driver->add_card) {
printk(KERN_ERR "kcapi: driver \"%s\" has no add card function.\n", cdef.driver); printk(KERN_ERR "kcapi: driver \"%s\" has no add card function.\n", cdef.driver);
return -EIO; retval = -EIO;
} } else
retval = driver->add_card(driver, &cparams);
return driver->add_card(driver, &cparams); mutex_unlock(&capi_drivers_lock);
return retval;
} }
default: default:
......
...@@ -30,7 +30,7 @@ enum { ...@@ -30,7 +30,7 @@ enum {
}; };
extern struct list_head capi_drivers; extern struct list_head capi_drivers;
extern rwlock_t capi_drivers_list_lock; extern struct mutex capi_drivers_lock;
extern struct capi20_appl *capi_applications[CAPI_MAXAPPL]; extern struct capi20_appl *capi_applications[CAPI_MAXAPPL];
extern struct capi_ctr *capi_controller[CAPI_MAXCONTR]; extern struct capi_ctr *capi_controller[CAPI_MAXCONTR];
......
...@@ -238,9 +238,9 @@ static const struct file_operations proc_applstats_ops = { ...@@ -238,9 +238,9 @@ static const struct file_operations proc_applstats_ops = {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
static void *capi_driver_start(struct seq_file *seq, loff_t *pos) static void *capi_driver_start(struct seq_file *seq, loff_t *pos)
__acquires(&capi_drivers_list_lock) __acquires(&capi_drivers_lock)
{ {
read_lock(&capi_drivers_list_lock); mutex_lock(&capi_drivers_lock);
return seq_list_start(&capi_drivers, *pos); return seq_list_start(&capi_drivers, *pos);
} }
...@@ -250,9 +250,9 @@ static void *capi_driver_next(struct seq_file *seq, void *v, loff_t *pos) ...@@ -250,9 +250,9 @@ static void *capi_driver_next(struct seq_file *seq, void *v, loff_t *pos)
} }
static void capi_driver_stop(struct seq_file *seq, void *v) static void capi_driver_stop(struct seq_file *seq, void *v)
__releases(&capi_drivers_list_lock) __releases(&capi_drivers_lock)
{ {
read_unlock(&capi_drivers_list_lock); mutex_unlock(&capi_drivers_lock);
} }
static int capi_driver_show(struct seq_file *seq, void *v) static int capi_driver_show(struct seq_file *seq, void *v)
......
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