diff options
-rw-r--r-- | drivers/tty/n_tty.c | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c index dd8ae0cad1d5..c9a9ddd1d0bc 100644 --- a/drivers/tty/n_tty.c +++ b/drivers/tty/n_tty.c | |||
@@ -2122,6 +2122,17 @@ static ssize_t n_tty_read(struct tty_struct *tty, struct file *file, | |||
2122 | if (c < 0) | 2122 | if (c < 0) |
2123 | return c; | 2123 | return c; |
2124 | 2124 | ||
2125 | /* | ||
2126 | * Internal serialization of reads. | ||
2127 | */ | ||
2128 | if (file->f_flags & O_NONBLOCK) { | ||
2129 | if (!mutex_trylock(&ldata->atomic_read_lock)) | ||
2130 | return -EAGAIN; | ||
2131 | } else { | ||
2132 | if (mutex_lock_interruptible(&ldata->atomic_read_lock)) | ||
2133 | return -ERESTARTSYS; | ||
2134 | } | ||
2135 | |||
2125 | down_read(&tty->termios_rwsem); | 2136 | down_read(&tty->termios_rwsem); |
2126 | 2137 | ||
2127 | minimum = time = 0; | 2138 | minimum = time = 0; |
@@ -2141,20 +2152,6 @@ static ssize_t n_tty_read(struct tty_struct *tty, struct file *file, | |||
2141 | } | 2152 | } |
2142 | } | 2153 | } |
2143 | 2154 | ||
2144 | /* | ||
2145 | * Internal serialization of reads. | ||
2146 | */ | ||
2147 | if (file->f_flags & O_NONBLOCK) { | ||
2148 | if (!mutex_trylock(&ldata->atomic_read_lock)) { | ||
2149 | up_read(&tty->termios_rwsem); | ||
2150 | return -EAGAIN; | ||
2151 | } | ||
2152 | } else { | ||
2153 | if (mutex_lock_interruptible(&ldata->atomic_read_lock)) { | ||
2154 | up_read(&tty->termios_rwsem); | ||
2155 | return -ERESTARTSYS; | ||
2156 | } | ||
2157 | } | ||
2158 | packet = tty->packet; | 2155 | packet = tty->packet; |
2159 | 2156 | ||
2160 | add_wait_queue(&tty->read_wait, &wait); | 2157 | add_wait_queue(&tty->read_wait, &wait); |