Commit 4e3dfaca authored by Matthias Kaehlcke's avatar Matthias Kaehlcke Committed by Linus Torvalds

use mutex instead of semaphore in isdn subsystem common functions

The ISDN subsystem common functions use a semaphore as mutex. Use the
mutex API instead of the (binary) semaphore.
Signed-off-by: default avatarMatthias Kaehlcke <matthias.kaehlcke@gmail.com>
Acked-by: default avatarKarsten Keil <kkeil@suse.de>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 4d1ff582
...@@ -1365,7 +1365,7 @@ isdn_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg) ...@@ -1365,7 +1365,7 @@ isdn_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg)
} else { } else {
s = NULL; s = NULL;
} }
ret = down_interruptible(&dev->sem); ret = mutex_lock_interruptible(&dev->mtx);
if( ret ) return ret; if( ret ) return ret;
if ((s = isdn_net_new(s, NULL))) { if ((s = isdn_net_new(s, NULL))) {
if (copy_to_user(argp, s, strlen(s) + 1)){ if (copy_to_user(argp, s, strlen(s) + 1)){
...@@ -1375,7 +1375,7 @@ isdn_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg) ...@@ -1375,7 +1375,7 @@ isdn_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg)
} }
} else } else
ret = -ENODEV; ret = -ENODEV;
up(&dev->sem); mutex_unlock(&dev->mtx);
return ret; return ret;
case IIOCNETASL: case IIOCNETASL:
/* Add a slave to a network-interface */ /* Add a slave to a network-interface */
...@@ -1384,7 +1384,7 @@ isdn_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg) ...@@ -1384,7 +1384,7 @@ isdn_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg)
return -EFAULT; return -EFAULT;
} else } else
return -EINVAL; return -EINVAL;
ret = down_interruptible(&dev->sem); ret = mutex_lock_interruptible(&dev->mtx);
if( ret ) return ret; if( ret ) return ret;
if ((s = isdn_net_newslave(bname))) { if ((s = isdn_net_newslave(bname))) {
if (copy_to_user(argp, s, strlen(s) + 1)){ if (copy_to_user(argp, s, strlen(s) + 1)){
...@@ -1394,17 +1394,17 @@ isdn_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg) ...@@ -1394,17 +1394,17 @@ isdn_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg)
} }
} else } else
ret = -ENODEV; ret = -ENODEV;
up(&dev->sem); mutex_unlock(&dev->mtx);
return ret; return ret;
case IIOCNETDIF: case IIOCNETDIF:
/* Delete a network-interface */ /* Delete a network-interface */
if (arg) { if (arg) {
if (copy_from_user(name, argp, sizeof(name))) if (copy_from_user(name, argp, sizeof(name)))
return -EFAULT; return -EFAULT;
ret = down_interruptible(&dev->sem); ret = mutex_lock_interruptible(&dev->mtx);
if( ret ) return ret; if( ret ) return ret;
ret = isdn_net_rm(name); ret = isdn_net_rm(name);
up(&dev->sem); mutex_unlock(&dev->mtx);
return ret; return ret;
} else } else
return -EINVAL; return -EINVAL;
...@@ -1433,10 +1433,10 @@ isdn_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg) ...@@ -1433,10 +1433,10 @@ isdn_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg)
if (arg) { if (arg) {
if (copy_from_user(&phone, argp, sizeof(phone))) if (copy_from_user(&phone, argp, sizeof(phone)))
return -EFAULT; return -EFAULT;
ret = down_interruptible(&dev->sem); ret = mutex_lock_interruptible(&dev->mtx);
if( ret ) return ret; if( ret ) return ret;
ret = isdn_net_addphone(&phone); ret = isdn_net_addphone(&phone);
up(&dev->sem); mutex_unlock(&dev->mtx);
return ret; return ret;
} else } else
return -EINVAL; return -EINVAL;
...@@ -1445,10 +1445,10 @@ isdn_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg) ...@@ -1445,10 +1445,10 @@ isdn_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg)
if (arg) { if (arg) {
if (copy_from_user(&phone, argp, sizeof(phone))) if (copy_from_user(&phone, argp, sizeof(phone)))
return -EFAULT; return -EFAULT;
ret = down_interruptible(&dev->sem); ret = mutex_lock_interruptible(&dev->mtx);
if( ret ) return ret; if( ret ) return ret;
ret = isdn_net_getphones(&phone, argp); ret = isdn_net_getphones(&phone, argp);
up(&dev->sem); mutex_unlock(&dev->mtx);
return ret; return ret;
} else } else
return -EINVAL; return -EINVAL;
...@@ -1457,10 +1457,10 @@ isdn_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg) ...@@ -1457,10 +1457,10 @@ isdn_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg)
if (arg) { if (arg) {
if (copy_from_user(&phone, argp, sizeof(phone))) if (copy_from_user(&phone, argp, sizeof(phone)))
return -EFAULT; return -EFAULT;
ret = down_interruptible(&dev->sem); ret = mutex_lock_interruptible(&dev->mtx);
if( ret ) return ret; if( ret ) return ret;
ret = isdn_net_delphone(&phone); ret = isdn_net_delphone(&phone);
up(&dev->sem); mutex_unlock(&dev->mtx);
return ret; return ret;
} else } else
return -EINVAL; return -EINVAL;
...@@ -2304,7 +2304,7 @@ static int __init isdn_init(void) ...@@ -2304,7 +2304,7 @@ static int __init isdn_init(void)
#ifdef MODULE #ifdef MODULE
dev->owner = THIS_MODULE; dev->owner = THIS_MODULE;
#endif #endif
init_MUTEX(&dev->sem); mutex_init(&dev->mtx);
init_waitqueue_head(&dev->info_waitq); init_waitqueue_head(&dev->info_waitq);
for (i = 0; i < ISDN_MAX_CHANNELS; i++) { for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
dev->drvmap[i] = -1; dev->drvmap[i] = -1;
......
...@@ -167,6 +167,7 @@ typedef struct { ...@@ -167,6 +167,7 @@ typedef struct {
#include <linux/etherdevice.h> #include <linux/etherdevice.h>
#include <linux/skbuff.h> #include <linux/skbuff.h>
#include <linux/tcp.h> #include <linux/tcp.h>
#include <linux/mutex.h>
#define ISDN_TTY_MAJOR 43 #define ISDN_TTY_MAJOR 43
#define ISDN_TTYAUX_MAJOR 44 #define ISDN_TTYAUX_MAJOR 44
...@@ -616,7 +617,7 @@ typedef struct isdn_devt { ...@@ -616,7 +617,7 @@ typedef struct isdn_devt {
int v110emu[ISDN_MAX_CHANNELS]; /* V.110 emulator-mode 0=none */ int v110emu[ISDN_MAX_CHANNELS]; /* V.110 emulator-mode 0=none */
atomic_t v110use[ISDN_MAX_CHANNELS]; /* Usage-Semaphore for stream */ atomic_t v110use[ISDN_MAX_CHANNELS]; /* Usage-Semaphore for stream */
isdn_v110_stream *v110[ISDN_MAX_CHANNELS]; /* V.110 private data */ isdn_v110_stream *v110[ISDN_MAX_CHANNELS]; /* V.110 private data */
struct semaphore sem; /* serialize list access*/ struct mutex mtx; /* serialize list access*/
unsigned long global_features; unsigned long global_features;
} isdn_dev; } isdn_dev;
......
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