mirror of https://gitee.com/openkylin/linux.git
n_tty: Factor signal char handling into separate fn
Reduce the monolithic n_tty_receive_char() complexity; factor the handling of INTR_CHAR, QUIT_CHAR and SUSP_CHAR into n_tty_receive_signal_char(). Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
4a23a4df50
commit
b0ac50be1f
|
@ -1219,6 +1219,26 @@ static inline void n_tty_receive_parity_error(struct tty_struct *tty,
|
||||||
wake_up_interruptible(&tty->read_wait);
|
wake_up_interruptible(&tty->read_wait);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
n_tty_receive_signal_char(struct tty_struct *tty, int signal, unsigned char c)
|
||||||
|
{
|
||||||
|
if (!L_NOFLSH(tty)) {
|
||||||
|
/* flushing needs exclusive termios_rwsem */
|
||||||
|
up_read(&tty->termios_rwsem);
|
||||||
|
n_tty_flush_buffer(tty);
|
||||||
|
tty_driver_flush_buffer(tty);
|
||||||
|
down_read(&tty->termios_rwsem);
|
||||||
|
}
|
||||||
|
if (I_IXON(tty))
|
||||||
|
start_tty(tty);
|
||||||
|
if (L_ECHO(tty)) {
|
||||||
|
echo_char(c, tty);
|
||||||
|
commit_echoes(tty);
|
||||||
|
}
|
||||||
|
isig(signal, tty);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* n_tty_receive_char - perform processing
|
* n_tty_receive_char - perform processing
|
||||||
* @tty: terminal device
|
* @tty: terminal device
|
||||||
|
@ -1314,30 +1334,14 @@ static inline void n_tty_receive_char(struct tty_struct *tty, unsigned char c)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (L_ISIG(tty)) {
|
if (L_ISIG(tty)) {
|
||||||
int signal;
|
if (c == INTR_CHAR(tty)) {
|
||||||
signal = SIGINT;
|
n_tty_receive_signal_char(tty, SIGINT, c);
|
||||||
if (c == INTR_CHAR(tty))
|
return;
|
||||||
goto send_signal;
|
} else if (c == QUIT_CHAR(tty)) {
|
||||||
signal = SIGQUIT;
|
n_tty_receive_signal_char(tty, SIGQUIT, c);
|
||||||
if (c == QUIT_CHAR(tty))
|
return;
|
||||||
goto send_signal;
|
} else if (c == SUSP_CHAR(tty)) {
|
||||||
signal = SIGTSTP;
|
n_tty_receive_signal_char(tty, SIGTSTP, c);
|
||||||
if (c == SUSP_CHAR(tty)) {
|
|
||||||
send_signal:
|
|
||||||
if (!L_NOFLSH(tty)) {
|
|
||||||
/* flushing needs exclusive termios_rwsem */
|
|
||||||
up_read(&tty->termios_rwsem);
|
|
||||||
n_tty_flush_buffer(tty);
|
|
||||||
tty_driver_flush_buffer(tty);
|
|
||||||
down_read(&tty->termios_rwsem);
|
|
||||||
}
|
|
||||||
if (I_IXON(tty))
|
|
||||||
start_tty(tty);
|
|
||||||
if (L_ECHO(tty)) {
|
|
||||||
echo_char(c, tty);
|
|
||||||
commit_echoes(tty);
|
|
||||||
}
|
|
||||||
isig(signal, tty);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue