diff options
author | Peter Hurley <peter@hurleysoftware.com> | 2014-10-16 15:33:23 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-11-05 19:34:36 -0500 |
commit | dbfcd851a9ee0bf6952e538be75230b7c071dafb (patch) | |
tree | 83a8d040432dd90ad72c48f5f2158a753f47409a | |
parent | 6460fbbf476ad8d4f4196534c00019975b33e1db (diff) |
tty: Move pty-specific set_termios() handling to pty driver
Packet mode is unique to the pty driver; move the packet mode state
change code from the generic tty ioctl handler to the pty driver.
Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Reviewed-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/tty/pty.c | 28 | ||||
-rw-r--r-- | drivers/tty/tty_ioctl.c | 32 |
2 files changed, 29 insertions, 31 deletions
diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c index 6c7602592fe0..7f612c524224 100644 --- a/drivers/tty/pty.c +++ b/drivers/tty/pty.c | |||
@@ -259,6 +259,34 @@ out: | |||
259 | static void pty_set_termios(struct tty_struct *tty, | 259 | static void pty_set_termios(struct tty_struct *tty, |
260 | struct ktermios *old_termios) | 260 | struct ktermios *old_termios) |
261 | { | 261 | { |
262 | unsigned long flags; | ||
263 | |||
264 | /* See if packet mode change of state. */ | ||
265 | if (tty->link && tty->link->packet) { | ||
266 | int extproc = (old_termios->c_lflag & EXTPROC) | | ||
267 | (tty->termios.c_lflag & EXTPROC); | ||
268 | int old_flow = ((old_termios->c_iflag & IXON) && | ||
269 | (old_termios->c_cc[VSTOP] == '\023') && | ||
270 | (old_termios->c_cc[VSTART] == '\021')); | ||
271 | int new_flow = (I_IXON(tty) && | ||
272 | STOP_CHAR(tty) == '\023' && | ||
273 | START_CHAR(tty) == '\021'); | ||
274 | if ((old_flow != new_flow) || extproc) { | ||
275 | spin_lock_irqsave(&tty->ctrl_lock, flags); | ||
276 | if (old_flow != new_flow) { | ||
277 | tty->ctrl_status &= ~(TIOCPKT_DOSTOP | TIOCPKT_NOSTOP); | ||
278 | if (new_flow) | ||
279 | tty->ctrl_status |= TIOCPKT_DOSTOP; | ||
280 | else | ||
281 | tty->ctrl_status |= TIOCPKT_NOSTOP; | ||
282 | } | ||
283 | if (extproc) | ||
284 | tty->ctrl_status |= TIOCPKT_IOCTL; | ||
285 | spin_unlock_irqrestore(&tty->ctrl_lock, flags); | ||
286 | wake_up_interruptible(&tty->link->read_wait); | ||
287 | } | ||
288 | } | ||
289 | |||
262 | tty->termios.c_cflag &= ~(CSIZE | PARENB); | 290 | tty->termios.c_cflag &= ~(CSIZE | PARENB); |
263 | tty->termios.c_cflag |= (CS8 | CREAD); | 291 | tty->termios.c_cflag |= (CS8 | CREAD); |
264 | } | 292 | } |
diff --git a/drivers/tty/tty_ioctl.c b/drivers/tty/tty_ioctl.c index ab4562c06af4..24a136079d90 100644 --- a/drivers/tty/tty_ioctl.c +++ b/drivers/tty/tty_ioctl.c | |||
@@ -524,10 +524,7 @@ EXPORT_SYMBOL(tty_termios_hw_change); | |||
524 | * @tty: tty to update | 524 | * @tty: tty to update |
525 | * @new_termios: desired new value | 525 | * @new_termios: desired new value |
526 | * | 526 | * |
527 | * Perform updates to the termios values set on this terminal. There | 527 | * Perform updates to the termios values set on this terminal. |
528 | * is a bit of layering violation here with n_tty in terms of the | ||
529 | * internal knowledge of this function. | ||
530 | * | ||
531 | * A master pty's termios should never be set. | 528 | * A master pty's termios should never be set. |
532 | * | 529 | * |
533 | * Locking: termios_rwsem | 530 | * Locking: termios_rwsem |
@@ -537,7 +534,6 @@ int tty_set_termios(struct tty_struct *tty, struct ktermios *new_termios) | |||
537 | { | 534 | { |
538 | struct ktermios old_termios; | 535 | struct ktermios old_termios; |
539 | struct tty_ldisc *ld; | 536 | struct tty_ldisc *ld; |
540 | unsigned long flags; | ||
541 | 537 | ||
542 | WARN_ON(tty->driver->type == TTY_DRIVER_TYPE_PTY && | 538 | WARN_ON(tty->driver->type == TTY_DRIVER_TYPE_PTY && |
543 | tty->driver->subtype == PTY_TYPE_MASTER); | 539 | tty->driver->subtype == PTY_TYPE_MASTER); |
@@ -553,32 +549,6 @@ int tty_set_termios(struct tty_struct *tty, struct ktermios *new_termios) | |||
553 | tty->termios = *new_termios; | 549 | tty->termios = *new_termios; |
554 | unset_locked_termios(&tty->termios, &old_termios, &tty->termios_locked); | 550 | unset_locked_termios(&tty->termios, &old_termios, &tty->termios_locked); |
555 | 551 | ||
556 | /* See if packet mode change of state. */ | ||
557 | if (tty->link && tty->link->packet) { | ||
558 | int extproc = (old_termios.c_lflag & EXTPROC) | | ||
559 | (tty->termios.c_lflag & EXTPROC); | ||
560 | int old_flow = ((old_termios.c_iflag & IXON) && | ||
561 | (old_termios.c_cc[VSTOP] == '\023') && | ||
562 | (old_termios.c_cc[VSTART] == '\021')); | ||
563 | int new_flow = (I_IXON(tty) && | ||
564 | STOP_CHAR(tty) == '\023' && | ||
565 | START_CHAR(tty) == '\021'); | ||
566 | if ((old_flow != new_flow) || extproc) { | ||
567 | spin_lock_irqsave(&tty->ctrl_lock, flags); | ||
568 | if (old_flow != new_flow) { | ||
569 | tty->ctrl_status &= ~(TIOCPKT_DOSTOP | TIOCPKT_NOSTOP); | ||
570 | if (new_flow) | ||
571 | tty->ctrl_status |= TIOCPKT_DOSTOP; | ||
572 | else | ||
573 | tty->ctrl_status |= TIOCPKT_NOSTOP; | ||
574 | } | ||
575 | if (extproc) | ||
576 | tty->ctrl_status |= TIOCPKT_IOCTL; | ||
577 | spin_unlock_irqrestore(&tty->ctrl_lock, flags); | ||
578 | wake_up_interruptible(&tty->link->read_wait); | ||
579 | } | ||
580 | } | ||
581 | |||
582 | if (tty->ops->set_termios) | 552 | if (tty->ops->set_termios) |
583 | (*tty->ops->set_termios)(tty, &old_termios); | 553 | (*tty->ops->set_termios)(tty, &old_termios); |
584 | else | 554 | else |