Commit 6054c16e authored by Peter Hurley's avatar Peter Hurley Committed by Greg Kroah-Hartman

tty: Use spin_lock_irq() for ctrl_lock when interrupts enabled

Interrupts are enabled in the n_tty_read() loop, ioctl(TIOCPKT)
and pty driver flush_buffer() routine; no need to save and restore
local interrupt state.
Signed-off-by: default avatarPeter Hurley <peter@hurleysoftware.com>
Reviewed-by: default avatarAlan Cox <alan@linux.intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 4d8c1dff
...@@ -2128,7 +2128,6 @@ static ssize_t n_tty_read(struct tty_struct *tty, struct file *file, ...@@ -2128,7 +2128,6 @@ static ssize_t n_tty_read(struct tty_struct *tty, struct file *file,
int minimum, time; int minimum, time;
ssize_t retval = 0; ssize_t retval = 0;
long timeout; long timeout;
unsigned long flags;
int packet; int packet;
c = job_control(tty, file); c = job_control(tty, file);
...@@ -2174,10 +2173,10 @@ static ssize_t n_tty_read(struct tty_struct *tty, struct file *file, ...@@ -2174,10 +2173,10 @@ static ssize_t n_tty_read(struct tty_struct *tty, struct file *file,
unsigned char cs; unsigned char cs;
if (b != buf) if (b != buf)
break; break;
spin_lock_irqsave(&tty->link->ctrl_lock, flags); spin_lock_irq(&tty->link->ctrl_lock);
cs = tty->link->ctrl_status; cs = tty->link->ctrl_status;
tty->link->ctrl_status = 0; tty->link->ctrl_status = 0;
spin_unlock_irqrestore(&tty->link->ctrl_lock, flags); spin_unlock_irq(&tty->link->ctrl_lock);
if (tty_put_user(tty, cs, b++)) { if (tty_put_user(tty, cs, b++)) {
retval = -EFAULT; retval = -EFAULT;
b--; b--;
......
...@@ -178,13 +178,12 @@ static int pty_get_lock(struct tty_struct *tty, int __user *arg) ...@@ -178,13 +178,12 @@ static int pty_get_lock(struct tty_struct *tty, int __user *arg)
/* Set the packet mode on a pty */ /* Set the packet mode on a pty */
static int pty_set_pktmode(struct tty_struct *tty, int __user *arg) static int pty_set_pktmode(struct tty_struct *tty, int __user *arg)
{ {
unsigned long flags;
int pktmode; int pktmode;
if (get_user(pktmode, arg)) if (get_user(pktmode, arg))
return -EFAULT; return -EFAULT;
spin_lock_irqsave(&tty->ctrl_lock, flags); spin_lock_irq(&tty->ctrl_lock);
if (pktmode) { if (pktmode) {
if (!tty->packet) { if (!tty->packet) {
tty->packet = 1; tty->packet = 1;
...@@ -192,7 +191,7 @@ static int pty_set_pktmode(struct tty_struct *tty, int __user *arg) ...@@ -192,7 +191,7 @@ static int pty_set_pktmode(struct tty_struct *tty, int __user *arg)
} }
} else } else
tty->packet = 0; tty->packet = 0;
spin_unlock_irqrestore(&tty->ctrl_lock, flags); spin_unlock_irq(&tty->ctrl_lock);
return 0; return 0;
} }
...@@ -221,16 +220,15 @@ static int pty_signal(struct tty_struct *tty, int sig) ...@@ -221,16 +220,15 @@ static int pty_signal(struct tty_struct *tty, int sig)
static void pty_flush_buffer(struct tty_struct *tty) static void pty_flush_buffer(struct tty_struct *tty)
{ {
struct tty_struct *to = tty->link; struct tty_struct *to = tty->link;
unsigned long flags;
if (!to) if (!to)
return; return;
/* tty_buffer_flush(to); FIXME */ /* tty_buffer_flush(to); FIXME */
if (to->packet) { if (to->packet) {
spin_lock_irqsave(&tty->ctrl_lock, flags); spin_lock_irq(&tty->ctrl_lock);
tty->ctrl_status |= TIOCPKT_FLUSHWRITE; tty->ctrl_status |= TIOCPKT_FLUSHWRITE;
wake_up_interruptible(&to->read_wait); wake_up_interruptible(&to->read_wait);
spin_unlock_irqrestore(&tty->ctrl_lock, flags); spin_unlock_irq(&tty->ctrl_lock);
} }
} }
......
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