aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorMatthias Kaehlcke <matthias.kaehlcke@gmail.com>2007-05-08 03:32:43 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-08 14:15:17 -0400
commit9ea6e5d8088096aeba29b6778c3d3d82fb495e9f (patch)
treee348ee1acd60db62dfb95de8b99a11de20ce3ce6 /drivers
parenta7e27d5dd396419dc6d6288db6a6d86cf3a94ba5 (diff)
use mutex instead of semaphore in CAPI 2.0 interface
The CAPI 2.0 interface uses a semaphore as mutex. Use the mutex API instead of the (binary) semaphore. Signed-off-by: Matthias Kaehlcke <matthias.kaehlcke@gmail.com> Cc: Karsten Keil <kkeil@suse.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/isdn/capi/capi.c33
1 files changed, 17 insertions, 16 deletions
diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
index 484745e30119..81661b8bd3a8 100644
--- a/drivers/isdn/capi/capi.c
+++ b/drivers/isdn/capi/capi.c
@@ -18,6 +18,7 @@
18#include <linux/fcntl.h> 18#include <linux/fcntl.h>
19#include <linux/fs.h> 19#include <linux/fs.h>
20#include <linux/signal.h> 20#include <linux/signal.h>
21#include <linux/mutex.h>
21#include <linux/mm.h> 22#include <linux/mm.h>
22#include <linux/timer.h> 23#include <linux/timer.h>
23#include <linux/wait.h> 24#include <linux/wait.h>
@@ -146,7 +147,7 @@ struct capidev {
146 147
147 struct capincci *nccis; 148 struct capincci *nccis;
148 149
149 struct semaphore ncci_list_sem; 150 struct mutex ncci_list_mtx;
150}; 151};
151 152
152/* -------- global variables ---------------------------------------- */ 153/* -------- global variables ---------------------------------------- */
@@ -394,7 +395,7 @@ static struct capidev *capidev_alloc(void)
394 if (!cdev) 395 if (!cdev)
395 return NULL; 396 return NULL;
396 397
397 init_MUTEX(&cdev->ncci_list_sem); 398 mutex_init(&cdev->ncci_list_mtx);
398 skb_queue_head_init(&cdev->recvqueue); 399 skb_queue_head_init(&cdev->recvqueue);
399 init_waitqueue_head(&cdev->recvwait); 400 init_waitqueue_head(&cdev->recvwait);
400 write_lock_irqsave(&capidev_list_lock, flags); 401 write_lock_irqsave(&capidev_list_lock, flags);
@@ -413,9 +414,9 @@ static void capidev_free(struct capidev *cdev)
413 } 414 }
414 skb_queue_purge(&cdev->recvqueue); 415 skb_queue_purge(&cdev->recvqueue);
415 416
416 down(&cdev->ncci_list_sem); 417 mutex_lock(&cdev->ncci_list_mtx);
417 capincci_free(cdev, 0xffffffff); 418 capincci_free(cdev, 0xffffffff);
418 up(&cdev->ncci_list_sem); 419 mutex_unlock(&cdev->ncci_list_mtx);
419 420
420 write_lock_irqsave(&capidev_list_lock, flags); 421 write_lock_irqsave(&capidev_list_lock, flags);
421 list_del(&cdev->list); 422 list_del(&cdev->list);
@@ -602,15 +603,15 @@ static void capi_recv_message(struct capi20_appl *ap, struct sk_buff *skb)
602 if (CAPIMSG_CMD(skb->data) == CAPI_CONNECT_B3_CONF) { 603 if (CAPIMSG_CMD(skb->data) == CAPI_CONNECT_B3_CONF) {
603 u16 info = CAPIMSG_U16(skb->data, 12); // Info field 604 u16 info = CAPIMSG_U16(skb->data, 12); // Info field
604 if (info == 0) { 605 if (info == 0) {
605 down(&cdev->ncci_list_sem); 606 mutex_lock(&cdev->ncci_list_mtx);
606 capincci_alloc(cdev, CAPIMSG_NCCI(skb->data)); 607 capincci_alloc(cdev, CAPIMSG_NCCI(skb->data));
607 up(&cdev->ncci_list_sem); 608 mutex_unlock(&cdev->ncci_list_mtx);
608 } 609 }
609 } 610 }
610 if (CAPIMSG_CMD(skb->data) == CAPI_CONNECT_B3_IND) { 611 if (CAPIMSG_CMD(skb->data) == CAPI_CONNECT_B3_IND) {
611 down(&cdev->ncci_list_sem); 612 mutex_lock(&cdev->ncci_list_mtx);
612 capincci_alloc(cdev, CAPIMSG_NCCI(skb->data)); 613 capincci_alloc(cdev, CAPIMSG_NCCI(skb->data));
613 up(&cdev->ncci_list_sem); 614 mutex_unlock(&cdev->ncci_list_mtx);
614 } 615 }
615 spin_lock_irqsave(&workaround_lock, flags); 616 spin_lock_irqsave(&workaround_lock, flags);
616 if (CAPIMSG_COMMAND(skb->data) != CAPI_DATA_B3) { 617 if (CAPIMSG_COMMAND(skb->data) != CAPI_DATA_B3) {
@@ -751,9 +752,9 @@ capi_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos
751 CAPIMSG_SETAPPID(skb->data, cdev->ap.applid); 752 CAPIMSG_SETAPPID(skb->data, cdev->ap.applid);
752 753
753 if (CAPIMSG_CMD(skb->data) == CAPI_DISCONNECT_B3_RESP) { 754 if (CAPIMSG_CMD(skb->data) == CAPI_DISCONNECT_B3_RESP) {
754 down(&cdev->ncci_list_sem); 755 mutex_lock(&cdev->ncci_list_mtx);
755 capincci_free(cdev, CAPIMSG_NCCI(skb->data)); 756 capincci_free(cdev, CAPIMSG_NCCI(skb->data));
756 up(&cdev->ncci_list_sem); 757 mutex_unlock(&cdev->ncci_list_mtx);
757 } 758 }
758 759
759 cdev->errcode = capi20_put_message(&cdev->ap, skb); 760 cdev->errcode = capi20_put_message(&cdev->ap, skb);
@@ -938,9 +939,9 @@ capi_ioctl(struct inode *inode, struct file *file,
938 if (copy_from_user(&ncci, argp, sizeof(ncci))) 939 if (copy_from_user(&ncci, argp, sizeof(ncci)))
939 return -EFAULT; 940 return -EFAULT;
940 941
941 down(&cdev->ncci_list_sem); 942 mutex_lock(&cdev->ncci_list_mtx);
942 if ((nccip = capincci_find(cdev, (u32) ncci)) == 0) { 943 if ((nccip = capincci_find(cdev, (u32) ncci)) == 0) {
943 up(&cdev->ncci_list_sem); 944 mutex_unlock(&cdev->ncci_list_mtx);
944 return 0; 945 return 0;
945 } 946 }
946#ifdef CONFIG_ISDN_CAPI_MIDDLEWARE 947#ifdef CONFIG_ISDN_CAPI_MIDDLEWARE
@@ -948,7 +949,7 @@ capi_ioctl(struct inode *inode, struct file *file,
948 count += atomic_read(&mp->ttyopencount); 949 count += atomic_read(&mp->ttyopencount);
949 } 950 }
950#endif /* CONFIG_ISDN_CAPI_MIDDLEWARE */ 951#endif /* CONFIG_ISDN_CAPI_MIDDLEWARE */
951 up(&cdev->ncci_list_sem); 952 mutex_unlock(&cdev->ncci_list_mtx);
952 return count; 953 return count;
953 } 954 }
954 return 0; 955 return 0;
@@ -963,14 +964,14 @@ capi_ioctl(struct inode *inode, struct file *file,
963 if (copy_from_user(&ncci, argp, 964 if (copy_from_user(&ncci, argp,
964 sizeof(ncci))) 965 sizeof(ncci)))
965 return -EFAULT; 966 return -EFAULT;
966 down(&cdev->ncci_list_sem); 967 mutex_lock(&cdev->ncci_list_mtx);
967 nccip = capincci_find(cdev, (u32) ncci); 968 nccip = capincci_find(cdev, (u32) ncci);
968 if (!nccip || (mp = nccip->minorp) == 0) { 969 if (!nccip || (mp = nccip->minorp) == 0) {
969 up(&cdev->ncci_list_sem); 970 mutex_unlock(&cdev->ncci_list_mtx);
970 return -ESRCH; 971 return -ESRCH;
971 } 972 }
972 unit = mp->minor; 973 unit = mp->minor;
973 up(&cdev->ncci_list_sem); 974 mutex_unlock(&cdev->ncci_list_mtx);
974 return unit; 975 return unit;
975 } 976 }
976 return 0; 977 return 0;