diff options
author | Jan Kiszka <jan.kiszka@web.de> | 2010-02-08 05:12:11 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-02-16 19:01:20 -0500 |
commit | 9717fb8b64ed41be9dd074bc8010bafd33046f1a (patch) | |
tree | fb188fea58e7626b3046950de44fb7c551ee00f3 /drivers/isdn/capi | |
parent | 522530311b35ec8fc4785062441dd2d63967ac55 (diff) |
CAPI: Convert capi drivers rwlock into mutex
Turn the lock protecting registered capi drivers into a mutex and apply
it consistently.
Signed-off-by: Jan Kiszka <jan.kiszka@web.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/isdn/capi')
-rw-r--r-- | drivers/isdn/capi/kcapi.c | 49 | ||||
-rw-r--r-- | drivers/isdn/capi/kcapi.h | 2 | ||||
-rw-r--r-- | drivers/isdn/capi/kcapi_proc.c | 8 |
3 files changed, 27 insertions, 32 deletions
diff --git a/drivers/isdn/capi/kcapi.c b/drivers/isdn/capi/kcapi.c index f37c13b4ddc7..c46964fc17c7 100644 --- a/drivers/isdn/capi/kcapi.c +++ b/drivers/isdn/capi/kcapi.c | |||
@@ -61,7 +61,7 @@ static char capi_manufakturer[64] = "AVM Berlin"; | |||
61 | #define NCCI2CTRL(ncci) (((ncci) >> 24) & 0x7f) | 61 | #define NCCI2CTRL(ncci) (((ncci) >> 24) & 0x7f) |
62 | 62 | ||
63 | LIST_HEAD(capi_drivers); | 63 | LIST_HEAD(capi_drivers); |
64 | DEFINE_RWLOCK(capi_drivers_list_lock); | 64 | DEFINE_MUTEX(capi_drivers_lock); |
65 | 65 | ||
66 | static DEFINE_RWLOCK(application_lock); | 66 | static DEFINE_RWLOCK(application_lock); |
67 | static DEFINE_MUTEX(controller_mutex); | 67 | static DEFINE_MUTEX(controller_mutex); |
@@ -540,11 +540,9 @@ EXPORT_SYMBOL(detach_capi_ctr); | |||
540 | 540 | ||
541 | void register_capi_driver(struct capi_driver *driver) | 541 | void register_capi_driver(struct capi_driver *driver) |
542 | { | 542 | { |
543 | unsigned long flags; | 543 | mutex_lock(&capi_drivers_lock); |
544 | |||
545 | write_lock_irqsave(&capi_drivers_list_lock, flags); | ||
546 | list_add_tail(&driver->list, &capi_drivers); | 544 | list_add_tail(&driver->list, &capi_drivers); |
547 | write_unlock_irqrestore(&capi_drivers_list_lock, flags); | 545 | mutex_unlock(&capi_drivers_lock); |
548 | } | 546 | } |
549 | 547 | ||
550 | EXPORT_SYMBOL(register_capi_driver); | 548 | EXPORT_SYMBOL(register_capi_driver); |
@@ -558,11 +556,9 @@ EXPORT_SYMBOL(register_capi_driver); | |||
558 | 556 | ||
559 | void unregister_capi_driver(struct capi_driver *driver) | 557 | void unregister_capi_driver(struct capi_driver *driver) |
560 | { | 558 | { |
561 | unsigned long flags; | 559 | mutex_lock(&capi_drivers_lock); |
562 | |||
563 | write_lock_irqsave(&capi_drivers_list_lock, flags); | ||
564 | list_del(&driver->list); | 560 | list_del(&driver->list); |
565 | write_unlock_irqrestore(&capi_drivers_list_lock, flags); | 561 | mutex_unlock(&capi_drivers_lock); |
566 | } | 562 | } |
567 | 563 | ||
568 | EXPORT_SYMBOL(unregister_capi_driver); | 564 | EXPORT_SYMBOL(unregister_capi_driver); |
@@ -899,7 +895,6 @@ static int old_capi_manufacturer(unsigned int cmd, void __user *data) | |||
899 | struct capi_driver *driver = NULL; | 895 | struct capi_driver *driver = NULL; |
900 | capiloaddata ldata; | 896 | capiloaddata ldata; |
901 | struct list_head *l; | 897 | struct list_head *l; |
902 | unsigned long flags; | ||
903 | int retval; | 898 | int retval; |
904 | 899 | ||
905 | switch (cmd) { | 900 | switch (cmd) { |
@@ -919,7 +914,8 @@ static int old_capi_manufacturer(unsigned int cmd, void __user *data) | |||
919 | cparams.irq = cdef.irq; | 914 | cparams.irq = cdef.irq; |
920 | cparams.cardnr = cdef.cardnr; | 915 | cparams.cardnr = cdef.cardnr; |
921 | 916 | ||
922 | read_lock_irqsave(&capi_drivers_list_lock, flags); | 917 | mutex_lock(&capi_drivers_lock); |
918 | |||
923 | switch (cdef.cardtype) { | 919 | switch (cdef.cardtype) { |
924 | case AVM_CARDTYPE_B1: | 920 | case AVM_CARDTYPE_B1: |
925 | list_for_each(l, &capi_drivers) { | 921 | list_for_each(l, &capi_drivers) { |
@@ -940,18 +936,15 @@ static int old_capi_manufacturer(unsigned int cmd, void __user *data) | |||
940 | break; | 936 | break; |
941 | } | 937 | } |
942 | if (!driver) { | 938 | if (!driver) { |
943 | read_unlock_irqrestore(&capi_drivers_list_lock, flags); | ||
944 | printk(KERN_ERR "kcapi: driver not loaded.\n"); | 939 | printk(KERN_ERR "kcapi: driver not loaded.\n"); |
945 | return -EIO; | 940 | retval = -EIO; |
946 | } | 941 | } else if (!driver->add_card) { |
947 | if (!driver->add_card) { | ||
948 | read_unlock_irqrestore(&capi_drivers_list_lock, flags); | ||
949 | printk(KERN_ERR "kcapi: driver has no add card function.\n"); | 942 | printk(KERN_ERR "kcapi: driver has no add card function.\n"); |
950 | return -EIO; | 943 | retval = -EIO; |
951 | } | 944 | } else |
945 | retval = driver->add_card(driver, &cparams); | ||
952 | 946 | ||
953 | retval = driver->add_card(driver, &cparams); | 947 | mutex_unlock(&capi_drivers_lock); |
954 | read_unlock_irqrestore(&capi_drivers_list_lock, flags); | ||
955 | return retval; | 948 | return retval; |
956 | 949 | ||
957 | case AVMB1_LOAD: | 950 | case AVMB1_LOAD: |
@@ -1107,6 +1100,8 @@ int capi20_manufacturer(unsigned int cmd, void __user *data) | |||
1107 | cparams.cardtype = 0; | 1100 | cparams.cardtype = 0; |
1108 | cdef.driver[sizeof(cdef.driver)-1] = 0; | 1101 | cdef.driver[sizeof(cdef.driver)-1] = 0; |
1109 | 1102 | ||
1103 | mutex_lock(&capi_drivers_lock); | ||
1104 | |||
1110 | list_for_each(l, &capi_drivers) { | 1105 | list_for_each(l, &capi_drivers) { |
1111 | driver = list_entry(l, struct capi_driver, list); | 1106 | driver = list_entry(l, struct capi_driver, list); |
1112 | if (strcmp(driver->name, cdef.driver) == 0) | 1107 | if (strcmp(driver->name, cdef.driver) == 0) |
@@ -1115,15 +1110,15 @@ int capi20_manufacturer(unsigned int cmd, void __user *data) | |||
1115 | if (driver == NULL) { | 1110 | if (driver == NULL) { |
1116 | printk(KERN_ERR "kcapi: driver \"%s\" not loaded.\n", | 1111 | printk(KERN_ERR "kcapi: driver \"%s\" not loaded.\n", |
1117 | cdef.driver); | 1112 | cdef.driver); |
1118 | return -ESRCH; | 1113 | retval = -ESRCH; |
1119 | } | 1114 | } else if (!driver->add_card) { |
1120 | |||
1121 | if (!driver->add_card) { | ||
1122 | printk(KERN_ERR "kcapi: driver \"%s\" has no add card function.\n", cdef.driver); | 1115 | printk(KERN_ERR "kcapi: driver \"%s\" has no add card function.\n", cdef.driver); |
1123 | return -EIO; | 1116 | retval = -EIO; |
1124 | } | 1117 | } else |
1118 | retval = driver->add_card(driver, &cparams); | ||
1125 | 1119 | ||
1126 | return driver->add_card(driver, &cparams); | 1120 | mutex_unlock(&capi_drivers_lock); |
1121 | return retval; | ||
1127 | } | 1122 | } |
1128 | 1123 | ||
1129 | default: | 1124 | default: |
diff --git a/drivers/isdn/capi/kcapi.h b/drivers/isdn/capi/kcapi.h index f62c53bd6a97..07c58500fe48 100644 --- a/drivers/isdn/capi/kcapi.h +++ b/drivers/isdn/capi/kcapi.h | |||
@@ -30,7 +30,7 @@ enum { | |||
30 | }; | 30 | }; |
31 | 31 | ||
32 | extern struct list_head capi_drivers; | 32 | extern struct list_head capi_drivers; |
33 | extern rwlock_t capi_drivers_list_lock; | 33 | extern struct mutex capi_drivers_lock; |
34 | 34 | ||
35 | extern struct capi20_appl *capi_applications[CAPI_MAXAPPL]; | 35 | extern struct capi20_appl *capi_applications[CAPI_MAXAPPL]; |
36 | extern struct capi_ctr *capi_controller[CAPI_MAXCONTR]; | 36 | extern struct capi_ctr *capi_controller[CAPI_MAXCONTR]; |
diff --git a/drivers/isdn/capi/kcapi_proc.c b/drivers/isdn/capi/kcapi_proc.c index 59fd16a4ad8e..71b07610ff31 100644 --- a/drivers/isdn/capi/kcapi_proc.c +++ b/drivers/isdn/capi/kcapi_proc.c | |||
@@ -238,9 +238,9 @@ static const struct file_operations proc_applstats_ops = { | |||
238 | // --------------------------------------------------------------------------- | 238 | // --------------------------------------------------------------------------- |
239 | 239 | ||
240 | static void *capi_driver_start(struct seq_file *seq, loff_t *pos) | 240 | static void *capi_driver_start(struct seq_file *seq, loff_t *pos) |
241 | __acquires(&capi_drivers_list_lock) | 241 | __acquires(&capi_drivers_lock) |
242 | { | 242 | { |
243 | read_lock(&capi_drivers_list_lock); | 243 | mutex_lock(&capi_drivers_lock); |
244 | return seq_list_start(&capi_drivers, *pos); | 244 | return seq_list_start(&capi_drivers, *pos); |
245 | } | 245 | } |
246 | 246 | ||
@@ -250,9 +250,9 @@ static void *capi_driver_next(struct seq_file *seq, void *v, loff_t *pos) | |||
250 | } | 250 | } |
251 | 251 | ||
252 | static void capi_driver_stop(struct seq_file *seq, void *v) | 252 | static void capi_driver_stop(struct seq_file *seq, void *v) |
253 | __releases(&capi_drivers_list_lock) | 253 | __releases(&capi_drivers_lock) |
254 | { | 254 | { |
255 | read_unlock(&capi_drivers_list_lock); | 255 | mutex_unlock(&capi_drivers_lock); |
256 | } | 256 | } |
257 | 257 | ||
258 | static int capi_driver_show(struct seq_file *seq, void *v) | 258 | static int capi_driver_show(struct seq_file *seq, void *v) |