linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
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>,
	Vineet Gupta <vgupta@kernel.org>
Subject: [PATCH 08/10] serial: arc_uart: simplify flags handling in arc_serial_rx_chars()
Date: Wed, 12 Jul 2023 10:18:09 +0200	[thread overview]
Message-ID: <20230712081811.29004-9-jirislaby@kernel.org> (raw)
In-Reply-To: <20230712081811.29004-1-jirislaby@kernel.org>

* move the declaration of flg (with the initializer) to the loop, so
  there is no need to reset it to TTY_NORMAL by an 'else' branch.
* use TTY_NORMAL as initializer above, not a magic zero constant
* remove the outer 'if' from this construct:
  if (S & (A | B)) {
    if (S & A)
      X;
    if (S & B)
      Y;
  }
* drop unlikely() as I doubt it has any benefits here. If it does,
  provide numbers.

All four make the code easier to read.

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
Cc: Vineet Gupta <vgupta@kernel.org>
---
 drivers/tty/serial/arc_uart.c | 29 +++++++++++++----------------
 1 file changed, 13 insertions(+), 16 deletions(-)

diff --git a/drivers/tty/serial/arc_uart.c b/drivers/tty/serial/arc_uart.c
index 4b2512eef577..835903488acb 100644
--- a/drivers/tty/serial/arc_uart.c
+++ b/drivers/tty/serial/arc_uart.c
@@ -195,8 +195,6 @@ static void arc_serial_start_tx(struct uart_port *port)
 
 static void arc_serial_rx_chars(struct uart_port *port, unsigned int status)
 {
-	unsigned int ch, flg = 0;
-
 	/*
 	 * UART has 4 deep RX-FIFO. Driver's recongnition of this fact
 	 * is very subtle. Here's how ...
@@ -207,24 +205,23 @@ static void arc_serial_rx_chars(struct uart_port *port, unsigned int status)
 	 * controller, which is indeed the Rx-FIFO.
 	 */
 	do {
+		unsigned int ch, flg = TTY_NORMAL;
+
 		/*
 		 * This could be an Rx Intr for err (no data),
 		 * so check err and clear that Intr first
 		 */
-		if (unlikely(status & (RXOERR | RXFERR))) {
-			if (status & RXOERR) {
-				port->icount.overrun++;
-				flg = TTY_OVERRUN;
-				UART_CLR_STATUS(port, RXOERR);
-			}
-
-			if (status & RXFERR) {
-				port->icount.frame++;
-				flg = TTY_FRAME;
-				UART_CLR_STATUS(port, RXFERR);
-			}
-		} else
-			flg = TTY_NORMAL;
+		if (status & RXOERR) {
+			port->icount.overrun++;
+			flg = TTY_OVERRUN;
+			UART_CLR_STATUS(port, RXOERR);
+		}
+
+		if (status & RXFERR) {
+			port->icount.frame++;
+			flg = TTY_FRAME;
+			UART_CLR_STATUS(port, RXFERR);
+		}
 
 		if (status & RXEMPTY)
 			continue;
-- 
2.41.0


  parent reply	other threads:[~2023-07-12  8:23 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-12  8:18 [PATCH 00/10] tty: u8 conversion preparation Jiri Slaby (SUSE)
2023-07-12  8:18 ` [PATCH 01/10] tty: sysrq: rename and re-type i in sysrq_handle_loglevel() Jiri Slaby (SUSE)
2023-07-12  8:18 ` [PATCH 02/10] tty: sysrq: switch sysrq handlers from int to u8 Jiri Slaby (SUSE)
2023-07-12  8:34   ` Thomas Zimmermann
2023-07-12 13:37   ` Paul E. McKenney
2023-07-12 15:19   ` Daniel Thompson
2023-07-13  2:45   ` WANG Xuerui
2023-07-12  8:18 ` [PATCH 03/10] tty: sysrq: switch the rest of keys " Jiri Slaby (SUSE)
2023-07-12  8:18 ` [PATCH 04/10] tty: sysrq: use switch in sysrq_key_table_key2index() Jiri Slaby (SUSE)
2023-07-12  8:18 ` [PATCH 05/10] serial: convert uart sysrq handling to u8 Jiri Slaby (SUSE)
2023-07-12  8:18 ` [PATCH 06/10] serial: make uart_insert_char() accept u8s Jiri Slaby (SUSE)
2023-07-12  8:18 ` [PATCH 07/10] serial: pass state to __uart_start() directly Jiri Slaby (SUSE)
2023-07-12  8:18 ` Jiri Slaby (SUSE) [this message]
2023-07-13  0:58   ` [PATCH 08/10] serial: arc_uart: simplify flags handling in arc_serial_rx_chars() Vineet Gupta
2023-07-12  8:18 ` [PATCH 09/10] serial: omap-serial: remove flag from serial_omap_rdi() Jiri Slaby (SUSE)
2023-07-12  8:18 ` [PATCH 10/10] serial: drivers: switch ch and flag to u8 Jiri Slaby (SUSE)
2023-07-12  9:44   ` Maciej W. Rozycki
2023-07-12 12:35   ` Thierry Reding
2023-07-13 13:58   ` Tobias Klauser
2023-07-14  9:45   ` Richard Genoud

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=20230712081811.29004-9-jirislaby@kernel.org \
    --to=jirislaby@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=vgupta@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;
as well as URLs for NNTP newsgroup(s).