Commit a6752f3f authored by Daniel Walker's avatar Daniel Walker Committed by Linus Torvalds

unix98 allocated_ptys_lock semaphore to mutex

Convert the unix98 allocated_ptys_lock to a mutex.
Signed-off-by: default avatarDaniel Walker <dwalker@mvista.com>
Acked-by: default avatarIngo Molnar <mingo@elte.hu>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 4749380e
...@@ -138,7 +138,7 @@ EXPORT_SYMBOL(tty_mutex); ...@@ -138,7 +138,7 @@ EXPORT_SYMBOL(tty_mutex);
extern struct tty_driver *ptm_driver; /* Unix98 pty masters; for /dev/ptmx */ extern struct tty_driver *ptm_driver; /* Unix98 pty masters; for /dev/ptmx */
extern int pty_limit; /* Config limit on Unix98 ptys */ extern int pty_limit; /* Config limit on Unix98 ptys */
static DEFINE_IDR(allocated_ptys); static DEFINE_IDR(allocated_ptys);
static DECLARE_MUTEX(allocated_ptys_lock); static DEFINE_MUTEX(allocated_ptys_lock);
static int ptmx_open(struct inode *, struct file *); static int ptmx_open(struct inode *, struct file *);
#endif #endif
...@@ -2571,9 +2571,9 @@ static void release_dev(struct file * filp) ...@@ -2571,9 +2571,9 @@ static void release_dev(struct file * filp)
#ifdef CONFIG_UNIX98_PTYS #ifdef CONFIG_UNIX98_PTYS
/* Make this pty number available for reallocation */ /* Make this pty number available for reallocation */
if (devpts) { if (devpts) {
down(&allocated_ptys_lock); mutex_lock(&allocated_ptys_lock);
idr_remove(&allocated_ptys, idx); idr_remove(&allocated_ptys, idx);
up(&allocated_ptys_lock); mutex_unlock(&allocated_ptys_lock);
} }
#endif #endif
...@@ -2737,24 +2737,24 @@ static int ptmx_open(struct inode * inode, struct file * filp) ...@@ -2737,24 +2737,24 @@ static int ptmx_open(struct inode * inode, struct file * filp)
nonseekable_open(inode, filp); nonseekable_open(inode, filp);
/* find a device that is not in use. */ /* find a device that is not in use. */
down(&allocated_ptys_lock); mutex_lock(&allocated_ptys_lock);
if (!idr_pre_get(&allocated_ptys, GFP_KERNEL)) { if (!idr_pre_get(&allocated_ptys, GFP_KERNEL)) {
up(&allocated_ptys_lock); mutex_unlock(&allocated_ptys_lock);
return -ENOMEM; return -ENOMEM;
} }
idr_ret = idr_get_new(&allocated_ptys, NULL, &index); idr_ret = idr_get_new(&allocated_ptys, NULL, &index);
if (idr_ret < 0) { if (idr_ret < 0) {
up(&allocated_ptys_lock); mutex_unlock(&allocated_ptys_lock);
if (idr_ret == -EAGAIN) if (idr_ret == -EAGAIN)
return -ENOMEM; return -ENOMEM;
return -EIO; return -EIO;
} }
if (index >= pty_limit) { if (index >= pty_limit) {
idr_remove(&allocated_ptys, index); idr_remove(&allocated_ptys, index);
up(&allocated_ptys_lock); mutex_unlock(&allocated_ptys_lock);
return -EIO; return -EIO;
} }
up(&allocated_ptys_lock); mutex_unlock(&allocated_ptys_lock);
mutex_lock(&tty_mutex); mutex_lock(&tty_mutex);
retval = init_dev(ptm_driver, index, &tty); retval = init_dev(ptm_driver, index, &tty);
...@@ -2781,9 +2781,9 @@ static int ptmx_open(struct inode * inode, struct file * filp) ...@@ -2781,9 +2781,9 @@ static int ptmx_open(struct inode * inode, struct file * filp)
release_dev(filp); release_dev(filp);
return retval; return retval;
out: out:
down(&allocated_ptys_lock); mutex_lock(&allocated_ptys_lock);
idr_remove(&allocated_ptys, index); idr_remove(&allocated_ptys, index);
up(&allocated_ptys_lock); mutex_unlock(&allocated_ptys_lock);
return retval; return retval;
} }
#endif #endif
......
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