Skip to content

Commit 0083040

Browse files
Jiri Slaby (SUSE)gregkh
authored andcommitted
tty: n_tty: move newline handling to a separate function
Currently, n_tty handles the newline in a label in n_tty_receive_char_canon(). That is invoked from two more places. Split this code to a separate function and avoid the label in this case. This makes the code flow more understandable. Signed-off-by: "Jiri Slaby (SUSE)" <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 102dc8a commit 0083040

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

drivers/tty/n_tty.c

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1262,6 +1262,17 @@ static bool n_tty_receive_char_flow_ctrl(struct tty_struct *tty, unsigned char c
12621262
return true;
12631263
}
12641264

1265+
static void n_tty_receive_handle_newline(struct tty_struct *tty, u8 c)
1266+
{
1267+
struct n_tty_data *ldata = tty->disc_data;
1268+
1269+
set_bit(MASK(ldata->read_head), ldata->read_flags);
1270+
put_tty_queue(c, ldata);
1271+
smp_store_release(&ldata->canon_head, ldata->read_head);
1272+
kill_fasync(&tty->fasync, SIGIO, POLL_IN);
1273+
wake_up_interruptible_poll(&tty->read_wait, EPOLLIN | EPOLLRDNORM);
1274+
}
1275+
12651276
static bool n_tty_receive_char_canon(struct tty_struct *tty, u8 c)
12661277
{
12671278
struct n_tty_data *ldata = tty->disc_data;
@@ -1308,12 +1319,16 @@ static bool n_tty_receive_char_canon(struct tty_struct *tty, u8 c)
13081319
echo_char_raw('\n', ldata);
13091320
commit_echoes(tty);
13101321
}
1311-
goto handle_newline;
1322+
n_tty_receive_handle_newline(tty, c);
1323+
1324+
return true;
13121325
}
13131326

13141327
if (c == EOF_CHAR(tty)) {
13151328
c = __DISABLED_CHAR;
1316-
goto handle_newline;
1329+
n_tty_receive_handle_newline(tty, c);
1330+
1331+
return true;
13171332
}
13181333

13191334
if ((c == EOL_CHAR(tty)) ||
@@ -1335,12 +1350,8 @@ static bool n_tty_receive_char_canon(struct tty_struct *tty, u8 c)
13351350
if (c == (unsigned char) '\377' && I_PARMRK(tty))
13361351
put_tty_queue(c, ldata);
13371352

1338-
handle_newline:
1339-
set_bit(MASK(ldata->read_head), ldata->read_flags);
1340-
put_tty_queue(c, ldata);
1341-
smp_store_release(&ldata->canon_head, ldata->read_head);
1342-
kill_fasync(&tty->fasync, SIGIO, POLL_IN);
1343-
wake_up_interruptible_poll(&tty->read_wait, EPOLLIN | EPOLLRDNORM);
1353+
n_tty_receive_handle_newline(tty, c);
1354+
13441355
return true;
13451356
}
13461357

0 commit comments

Comments
 (0)