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/kcapi.c | |
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/kcapi.c')
-rw-r--r-- | drivers/isdn/capi/kcapi.c | 49 |
1 files changed, 22 insertions, 27 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: |