mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-03 23:58:05 +00:00
TTY: move ldisc data from tty_struct: bitmaps
Here we move bitmaps and use DECLARE_BITMAP to declare them in the new structure. And instead of memset, we use bitmap_zero as it is more appropriate. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Acked-by: Alan Cox <alan@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
53c5ee2cfb
commit
3fe780b379
2 changed files with 28 additions and 26 deletions
|
@ -80,6 +80,9 @@ struct n_tty_data {
|
||||||
|
|
||||||
unsigned char lnext:1, erasing:1, raw:1, real_raw:1, icanon:1;
|
unsigned char lnext:1, erasing:1, raw:1, real_raw:1, icanon:1;
|
||||||
unsigned char echo_overrun:1;
|
unsigned char echo_overrun:1;
|
||||||
|
|
||||||
|
DECLARE_BITMAP(process_char_map, 256);
|
||||||
|
DECLARE_BITMAP(read_flags, N_TTY_BUF_SIZE);
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline int tty_put_user(struct tty_struct *tty, unsigned char x,
|
static inline int tty_put_user(struct tty_struct *tty, unsigned char x,
|
||||||
|
@ -203,7 +206,7 @@ static void reset_buffer_flags(struct tty_struct *tty)
|
||||||
mutex_unlock(&tty->echo_lock);
|
mutex_unlock(&tty->echo_lock);
|
||||||
|
|
||||||
tty->canon_head = tty->canon_data = ldata->erasing = 0;
|
tty->canon_head = tty->canon_data = ldata->erasing = 0;
|
||||||
memset(&tty->read_flags, 0, sizeof tty->read_flags);
|
bitmap_zero(ldata->read_flags, N_TTY_BUF_SIZE);
|
||||||
n_tty_set_room(tty);
|
n_tty_set_room(tty);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1165,7 +1168,7 @@ static inline void n_tty_receive_char(struct tty_struct *tty, unsigned char c)
|
||||||
* handle specially, do shortcut processing to speed things
|
* handle specially, do shortcut processing to speed things
|
||||||
* up.
|
* up.
|
||||||
*/
|
*/
|
||||||
if (!test_bit(c, tty->process_char_map) || ldata->lnext) {
|
if (!test_bit(c, ldata->process_char_map) || ldata->lnext) {
|
||||||
ldata->lnext = 0;
|
ldata->lnext = 0;
|
||||||
parmrk = (c == (unsigned char) '\377' && I_PARMRK(tty)) ? 1 : 0;
|
parmrk = (c == (unsigned char) '\377' && I_PARMRK(tty)) ? 1 : 0;
|
||||||
if (tty->read_cnt >= (N_TTY_BUF_SIZE - parmrk - 1)) {
|
if (tty->read_cnt >= (N_TTY_BUF_SIZE - parmrk - 1)) {
|
||||||
|
@ -1321,7 +1324,7 @@ static inline void n_tty_receive_char(struct tty_struct *tty, unsigned char c)
|
||||||
|
|
||||||
handle_newline:
|
handle_newline:
|
||||||
spin_lock_irqsave(&tty->read_lock, flags);
|
spin_lock_irqsave(&tty->read_lock, flags);
|
||||||
set_bit(tty->read_head, tty->read_flags);
|
set_bit(tty->read_head, ldata->read_flags);
|
||||||
put_tty_queue_nolock(c, tty);
|
put_tty_queue_nolock(c, tty);
|
||||||
tty->canon_head = tty->read_head;
|
tty->canon_head = tty->read_head;
|
||||||
tty->canon_data++;
|
tty->canon_data++;
|
||||||
|
@ -1496,7 +1499,7 @@ static void n_tty_set_termios(struct tty_struct *tty, struct ktermios *old)
|
||||||
if (old)
|
if (old)
|
||||||
canon_change = (old->c_lflag ^ tty->termios.c_lflag) & ICANON;
|
canon_change = (old->c_lflag ^ tty->termios.c_lflag) & ICANON;
|
||||||
if (canon_change) {
|
if (canon_change) {
|
||||||
memset(&tty->read_flags, 0, sizeof tty->read_flags);
|
bitmap_zero(ldata->read_flags, N_TTY_BUF_SIZE);
|
||||||
tty->canon_head = tty->read_tail;
|
tty->canon_head = tty->read_tail;
|
||||||
tty->canon_data = 0;
|
tty->canon_data = 0;
|
||||||
ldata->erasing = 0;
|
ldata->erasing = 0;
|
||||||
|
@ -1516,41 +1519,41 @@ static void n_tty_set_termios(struct tty_struct *tty, struct ktermios *old)
|
||||||
I_ICRNL(tty) || I_INLCR(tty) || L_ICANON(tty) ||
|
I_ICRNL(tty) || I_INLCR(tty) || L_ICANON(tty) ||
|
||||||
I_IXON(tty) || L_ISIG(tty) || L_ECHO(tty) ||
|
I_IXON(tty) || L_ISIG(tty) || L_ECHO(tty) ||
|
||||||
I_PARMRK(tty)) {
|
I_PARMRK(tty)) {
|
||||||
memset(tty->process_char_map, 0, 256/8);
|
bitmap_zero(ldata->process_char_map, 256);
|
||||||
|
|
||||||
if (I_IGNCR(tty) || I_ICRNL(tty))
|
if (I_IGNCR(tty) || I_ICRNL(tty))
|
||||||
set_bit('\r', tty->process_char_map);
|
set_bit('\r', ldata->process_char_map);
|
||||||
if (I_INLCR(tty))
|
if (I_INLCR(tty))
|
||||||
set_bit('\n', tty->process_char_map);
|
set_bit('\n', ldata->process_char_map);
|
||||||
|
|
||||||
if (L_ICANON(tty)) {
|
if (L_ICANON(tty)) {
|
||||||
set_bit(ERASE_CHAR(tty), tty->process_char_map);
|
set_bit(ERASE_CHAR(tty), ldata->process_char_map);
|
||||||
set_bit(KILL_CHAR(tty), tty->process_char_map);
|
set_bit(KILL_CHAR(tty), ldata->process_char_map);
|
||||||
set_bit(EOF_CHAR(tty), tty->process_char_map);
|
set_bit(EOF_CHAR(tty), ldata->process_char_map);
|
||||||
set_bit('\n', tty->process_char_map);
|
set_bit('\n', ldata->process_char_map);
|
||||||
set_bit(EOL_CHAR(tty), tty->process_char_map);
|
set_bit(EOL_CHAR(tty), ldata->process_char_map);
|
||||||
if (L_IEXTEN(tty)) {
|
if (L_IEXTEN(tty)) {
|
||||||
set_bit(WERASE_CHAR(tty),
|
set_bit(WERASE_CHAR(tty),
|
||||||
tty->process_char_map);
|
ldata->process_char_map);
|
||||||
set_bit(LNEXT_CHAR(tty),
|
set_bit(LNEXT_CHAR(tty),
|
||||||
tty->process_char_map);
|
ldata->process_char_map);
|
||||||
set_bit(EOL2_CHAR(tty),
|
set_bit(EOL2_CHAR(tty),
|
||||||
tty->process_char_map);
|
ldata->process_char_map);
|
||||||
if (L_ECHO(tty))
|
if (L_ECHO(tty))
|
||||||
set_bit(REPRINT_CHAR(tty),
|
set_bit(REPRINT_CHAR(tty),
|
||||||
tty->process_char_map);
|
ldata->process_char_map);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (I_IXON(tty)) {
|
if (I_IXON(tty)) {
|
||||||
set_bit(START_CHAR(tty), tty->process_char_map);
|
set_bit(START_CHAR(tty), ldata->process_char_map);
|
||||||
set_bit(STOP_CHAR(tty), tty->process_char_map);
|
set_bit(STOP_CHAR(tty), ldata->process_char_map);
|
||||||
}
|
}
|
||||||
if (L_ISIG(tty)) {
|
if (L_ISIG(tty)) {
|
||||||
set_bit(INTR_CHAR(tty), tty->process_char_map);
|
set_bit(INTR_CHAR(tty), ldata->process_char_map);
|
||||||
set_bit(QUIT_CHAR(tty), tty->process_char_map);
|
set_bit(QUIT_CHAR(tty), ldata->process_char_map);
|
||||||
set_bit(SUSP_CHAR(tty), tty->process_char_map);
|
set_bit(SUSP_CHAR(tty), ldata->process_char_map);
|
||||||
}
|
}
|
||||||
clear_bit(__DISABLED_CHAR, tty->process_char_map);
|
clear_bit(__DISABLED_CHAR, ldata->process_char_map);
|
||||||
ldata->raw = 0;
|
ldata->raw = 0;
|
||||||
ldata->real_raw = 0;
|
ldata->real_raw = 0;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1879,7 +1882,7 @@ static ssize_t n_tty_read(struct tty_struct *tty, struct file *file,
|
||||||
int eol;
|
int eol;
|
||||||
|
|
||||||
eol = test_and_clear_bit(tty->read_tail,
|
eol = test_and_clear_bit(tty->read_tail,
|
||||||
tty->read_flags);
|
ldata->read_flags);
|
||||||
c = tty->read_buf[tty->read_tail];
|
c = tty->read_buf[tty->read_tail];
|
||||||
tty->read_tail = ((tty->read_tail+1) &
|
tty->read_tail = ((tty->read_tail+1) &
|
||||||
(N_TTY_BUF_SIZE-1));
|
(N_TTY_BUF_SIZE-1));
|
||||||
|
@ -2105,6 +2108,7 @@ static unsigned int n_tty_poll(struct tty_struct *tty, struct file *file,
|
||||||
|
|
||||||
static unsigned long inq_canon(struct tty_struct *tty)
|
static unsigned long inq_canon(struct tty_struct *tty)
|
||||||
{
|
{
|
||||||
|
struct n_tty_data *ldata = tty->disc_data;
|
||||||
int nr, head, tail;
|
int nr, head, tail;
|
||||||
|
|
||||||
if (!tty->canon_data)
|
if (!tty->canon_data)
|
||||||
|
@ -2114,7 +2118,7 @@ static unsigned long inq_canon(struct tty_struct *tty)
|
||||||
nr = (head - tail) & (N_TTY_BUF_SIZE-1);
|
nr = (head - tail) & (N_TTY_BUF_SIZE-1);
|
||||||
/* Skip EOF-chars.. */
|
/* Skip EOF-chars.. */
|
||||||
while (head != tail) {
|
while (head != tail) {
|
||||||
if (test_bit(tail, tty->read_flags) &&
|
if (test_bit(tail, ldata->read_flags) &&
|
||||||
tty->read_buf[tail] == __DISABLED_CHAR)
|
tty->read_buf[tail] == __DISABLED_CHAR)
|
||||||
nr--;
|
nr--;
|
||||||
tail = (tail+1) & (N_TTY_BUF_SIZE-1);
|
tail = (tail+1) & (N_TTY_BUF_SIZE-1);
|
||||||
|
|
|
@ -272,12 +272,10 @@ struct tty_struct {
|
||||||
*/
|
*/
|
||||||
unsigned char closing:1;
|
unsigned char closing:1;
|
||||||
unsigned short minimum_to_wake;
|
unsigned short minimum_to_wake;
|
||||||
unsigned long process_char_map[256/(8*sizeof(unsigned long))];
|
|
||||||
char *read_buf;
|
char *read_buf;
|
||||||
int read_head;
|
int read_head;
|
||||||
int read_tail;
|
int read_tail;
|
||||||
int read_cnt;
|
int read_cnt;
|
||||||
unsigned long read_flags[N_TTY_BUF_SIZE/(8*sizeof(unsigned long))];
|
|
||||||
unsigned char *echo_buf;
|
unsigned char *echo_buf;
|
||||||
unsigned int echo_pos;
|
unsigned int echo_pos;
|
||||||
unsigned int echo_cnt;
|
unsigned int echo_cnt;
|
||||||
|
|
Loading…
Reference in a new issue