diff options
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 |