|
@@ -2122,6 +2122,17 @@ static ssize_t n_tty_read(struct tty_struct *tty, struct file *file,
|
|
|
if (c < 0)
|
|
|
return c;
|
|
|
|
|
|
+ /*
|
|
|
+ * Internal serialization of reads.
|
|
|
+ */
|
|
|
+ if (file->f_flags & O_NONBLOCK) {
|
|
|
+ if (!mutex_trylock(&ldata->atomic_read_lock))
|
|
|
+ return -EAGAIN;
|
|
|
+ } else {
|
|
|
+ if (mutex_lock_interruptible(&ldata->atomic_read_lock))
|
|
|
+ return -ERESTARTSYS;
|
|
|
+ }
|
|
|
+
|
|
|
down_read(&tty->termios_rwsem);
|
|
|
|
|
|
minimum = time = 0;
|
|
@@ -2141,20 +2152,6 @@ static ssize_t n_tty_read(struct tty_struct *tty, struct file *file,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /*
|
|
|
- * Internal serialization of reads.
|
|
|
- */
|
|
|
- if (file->f_flags & O_NONBLOCK) {
|
|
|
- if (!mutex_trylock(&ldata->atomic_read_lock)) {
|
|
|
- up_read(&tty->termios_rwsem);
|
|
|
- return -EAGAIN;
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (mutex_lock_interruptible(&ldata->atomic_read_lock)) {
|
|
|
- up_read(&tty->termios_rwsem);
|
|
|
- return -ERESTARTSYS;
|
|
|
- }
|
|
|
- }
|
|
|
packet = tty->packet;
|
|
|
|
|
|
add_wait_queue(&tty->read_wait, &wait);
|