From: "Jiri Slaby (SUSE)" <jirislaby@kernel.org>
To: gregkh@linuxfoundation.org
Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org,
"Jiri Slaby (SUSE)" <jirislaby@kernel.org>
Subject: [PATCH v2 08/14] tty: n_tty: move newline handling to a separate function
Date: Sun, 27 Aug 2023 09:41:41 +0200 [thread overview]
Message-ID: <20230827074147.2287-9-jirislaby@kernel.org> (raw)
In-Reply-To: <20230827074147.2287-1-jirislaby@kernel.org>
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) <jirislaby@kernel.org>
---
drivers/tty/n_tty.c | 27 +++++++++++++++++++--------
1 file changed, 19 insertions(+), 8 deletions(-)
diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
index 0149dc9dd0b1..632516d7b487 100644
--- a/drivers/tty/n_tty.c
+++ b/drivers/tty/n_tty.c
@@ -1262,6 +1262,17 @@ static bool n_tty_receive_char_flow_ctrl(struct tty_struct *tty, unsigned char c
return true;
}
+static void n_tty_receive_handle_newline(struct tty_struct *tty, u8 c)
+{
+ struct n_tty_data *ldata = tty->disc_data;
+
+ set_bit(MASK(ldata->read_head), ldata->read_flags);
+ put_tty_queue(c, ldata);
+ smp_store_release(&ldata->canon_head, ldata->read_head);
+ kill_fasync(&tty->fasync, SIGIO, POLL_IN);
+ wake_up_interruptible_poll(&tty->read_wait, EPOLLIN | EPOLLRDNORM);
+}
+
static bool n_tty_receive_char_canon(struct tty_struct *tty, u8 c)
{
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)
echo_char_raw('\n', ldata);
commit_echoes(tty);
}
- goto handle_newline;
+ n_tty_receive_handle_newline(tty, c);
+
+ return true;
}
if (c == EOF_CHAR(tty)) {
c = __DISABLED_CHAR;
- goto handle_newline;
+ n_tty_receive_handle_newline(tty, c);
+
+ return true;
}
if ((c == EOL_CHAR(tty)) ||
@@ -1335,12 +1350,8 @@ static bool n_tty_receive_char_canon(struct tty_struct *tty, u8 c)
if (c == (unsigned char) '\377' && I_PARMRK(tty))
put_tty_queue(c, ldata);
-handle_newline:
- set_bit(MASK(ldata->read_head), ldata->read_flags);
- put_tty_queue(c, ldata);
- smp_store_release(&ldata->canon_head, ldata->read_head);
- kill_fasync(&tty->fasync, SIGIO, POLL_IN);
- wake_up_interruptible_poll(&tty->read_wait, EPOLLIN | EPOLLRDNORM);
+ n_tty_receive_handle_newline(tty, c);
+
return true;
}
--
2.42.0
next prev parent reply other threads:[~2023-08-27 7:44 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-27 7:41 [PATCH v2 00/14] tty: n_tty: cleanup Jiri Slaby (SUSE)
2023-08-27 7:41 ` [PATCH v2 01/14] tty: n_tty: make flow of n_tty_receive_buf_common() a bool Jiri Slaby (SUSE)
2023-08-27 7:41 ` [PATCH v2 02/14] tty: n_tty: use output character directly Jiri Slaby (SUSE)
2023-08-27 7:41 ` [PATCH v2 03/14] tty: n_tty: use 'num' for writes' counts Jiri Slaby (SUSE)
2023-08-27 7:41 ` [PATCH v2 04/14] tty: n_tty: use time_is_before_jiffies() in n_tty_receive_overrun() Jiri Slaby (SUSE)
2023-08-27 7:41 ` [PATCH v2 05/14] tty: n_tty: make n_tty_data::num_overrun unsigned Jiri Slaby (SUSE)
2023-08-27 7:41 ` [PATCH v2 06/14] tty: n_tty: use MASK() for masking out size bits Jiri Slaby (SUSE)
2023-08-27 7:41 ` [PATCH v2 07/14] tty: n_tty: move canon handling to a separate function Jiri Slaby (SUSE)
2023-08-27 7:41 ` Jiri Slaby (SUSE) [this message]
2023-08-27 7:41 ` [PATCH v2 09/14] tty: n_tty: remove unsigned char casts from character constants Jiri Slaby (SUSE)
2023-08-27 7:41 ` [PATCH v2 10/14] tty: n_tty: simplify chars_in_buffer() Jiri Slaby (SUSE)
2023-08-27 7:41 ` [PATCH v2 11/14] tty: n_tty: use u8 for chars and flags Jiri Slaby (SUSE)
2023-08-27 7:41 ` [PATCH v2 12/14] tty: n_tty: unify counts to size_t Jiri Slaby (SUSE)
2023-08-27 7:41 ` [PATCH v2 13/14] tty: n_tty: extract ECHO_OP processing to a separate function Jiri Slaby (SUSE)
2023-08-27 7:41 ` [PATCH v2 14/14] tty: n_tty: deduplicate copy code in n_tty_receive_buf_real_raw() Jiri Slaby (SUSE)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230827074147.2287-9-jirislaby@kernel.org \
--to=jirislaby@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox