diff options
author | Daniel Walker <dwalker@mvista.com> | 2008-02-06 04:37:32 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2008-02-06 13:41:07 -0500 |
commit | a6752f3f538e9dc0d0e7fdb2080532554a5eb395 (patch) | |
tree | d0b97dc6d937bb601fc3bc6ea50cbb0d0f8b787a /drivers | |
parent | 4749380ed688884a3bd3328b1bf32529d96aa49b (diff) |
unix98 allocated_ptys_lock semaphore to mutex
Convert the unix98 allocated_ptys_lock to a mutex.
Signed-off-by: Daniel Walker <dwalker@mvista.com>
Acked-by: Ingo Molnar <mingo@elte.hu>
Cc: "H. Peter Anvin" <hpa@zytor.com>
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/char/tty_io.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index b62bb67c3414..79c86c47947f 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c | |||
@@ -138,7 +138,7 @@ EXPORT_SYMBOL(tty_mutex); | |||
138 | extern struct tty_driver *ptm_driver; /* Unix98 pty masters; for /dev/ptmx */ | 138 | extern struct tty_driver *ptm_driver; /* Unix98 pty masters; for /dev/ptmx */ |
139 | extern int pty_limit; /* Config limit on Unix98 ptys */ | 139 | extern int pty_limit; /* Config limit on Unix98 ptys */ |
140 | static DEFINE_IDR(allocated_ptys); | 140 | static DEFINE_IDR(allocated_ptys); |
141 | static DECLARE_MUTEX(allocated_ptys_lock); | 141 | static DEFINE_MUTEX(allocated_ptys_lock); |
142 | static int ptmx_open(struct inode *, struct file *); | 142 | static int ptmx_open(struct inode *, struct file *); |
143 | #endif | 143 | #endif |
144 | 144 | ||
@@ -2571,9 +2571,9 @@ static void release_dev(struct file * filp) | |||
2571 | #ifdef CONFIG_UNIX98_PTYS | 2571 | #ifdef CONFIG_UNIX98_PTYS |
2572 | /* Make this pty number available for reallocation */ | 2572 | /* Make this pty number available for reallocation */ |
2573 | if (devpts) { | 2573 | if (devpts) { |
2574 | down(&allocated_ptys_lock); | 2574 | mutex_lock(&allocated_ptys_lock); |
2575 | idr_remove(&allocated_ptys, idx); | 2575 | idr_remove(&allocated_ptys, idx); |
2576 | up(&allocated_ptys_lock); | 2576 | mutex_unlock(&allocated_ptys_lock); |
2577 | } | 2577 | } |
2578 | #endif | 2578 | #endif |
2579 | 2579 | ||
@@ -2737,24 +2737,24 @@ static int ptmx_open(struct inode * inode, struct file * filp) | |||
2737 | nonseekable_open(inode, filp); | 2737 | nonseekable_open(inode, filp); |
2738 | 2738 | ||
2739 | /* find a device that is not in use. */ | 2739 | /* find a device that is not in use. */ |
2740 | down(&allocated_ptys_lock); | 2740 | mutex_lock(&allocated_ptys_lock); |
2741 | if (!idr_pre_get(&allocated_ptys, GFP_KERNEL)) { | 2741 | if (!idr_pre_get(&allocated_ptys, GFP_KERNEL)) { |
2742 | up(&allocated_ptys_lock); | 2742 | mutex_unlock(&allocated_ptys_lock); |
2743 | return -ENOMEM; | 2743 | return -ENOMEM; |
2744 | } | 2744 | } |
2745 | idr_ret = idr_get_new(&allocated_ptys, NULL, &index); | 2745 | idr_ret = idr_get_new(&allocated_ptys, NULL, &index); |
2746 | if (idr_ret < 0) { | 2746 | if (idr_ret < 0) { |
2747 | up(&allocated_ptys_lock); | 2747 | mutex_unlock(&allocated_ptys_lock); |
2748 | if (idr_ret == -EAGAIN) | 2748 | if (idr_ret == -EAGAIN) |
2749 | return -ENOMEM; | 2749 | return -ENOMEM; |
2750 | return -EIO; | 2750 | return -EIO; |
2751 | } | 2751 | } |
2752 | if (index >= pty_limit) { | 2752 | if (index >= pty_limit) { |
2753 | idr_remove(&allocated_ptys, index); | 2753 | idr_remove(&allocated_ptys, index); |
2754 | up(&allocated_ptys_lock); | 2754 | mutex_unlock(&allocated_ptys_lock); |
2755 | return -EIO; | 2755 | return -EIO; |
2756 | } | 2756 | } |
2757 | up(&allocated_ptys_lock); | 2757 | mutex_unlock(&allocated_ptys_lock); |
2758 | 2758 | ||
2759 | mutex_lock(&tty_mutex); | 2759 | mutex_lock(&tty_mutex); |
2760 | retval = init_dev(ptm_driver, index, &tty); | 2760 | retval = init_dev(ptm_driver, index, &tty); |
@@ -2781,9 +2781,9 @@ out1: | |||
2781 | release_dev(filp); | 2781 | release_dev(filp); |
2782 | return retval; | 2782 | return retval; |
2783 | out: | 2783 | out: |
2784 | down(&allocated_ptys_lock); | 2784 | mutex_lock(&allocated_ptys_lock); |
2785 | idr_remove(&allocated_ptys, index); | 2785 | idr_remove(&allocated_ptys, index); |
2786 | up(&allocated_ptys_lock); | 2786 | mutex_unlock(&allocated_ptys_lock); |
2787 | return retval; | 2787 | return retval; |
2788 | } | 2788 | } |
2789 | #endif | 2789 | #endif |