[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHp75Vex-YzE-0PydYcSZGd24hkmbBanVHRTSsWQ_X-bc8kW9Q@mail.gmail.com>
Date: Sun, 30 Nov 2025 19:29:47 +0200
From: Andy Shevchenko <andy.shevchenko@...il.com>
To: Crescent Hsieh <crescentcy.hsieh@...a.com>
Cc: gregkh@...uxfoundation.org, jirislaby@...nel.org,
ilpo.jarvinen@...ux.intel.com, linux-kernel@...r.kernel.org,
linux-serial@...r.kernel.org
Subject: Re: [PATCH v1 07/31] serial: 8250_mxupci: add GDL-based Rx routine
for 8250_mxupci
On Sun, Nov 30, 2025 at 12:43 PM Crescent Hsieh
<crescentcy.hsieh@...a.com> wrote:
>
> Introduce a custom Rx routine using the GDL (Good Data Length) register to
> read multiple bytes from the Rx FIFO on Moxa UPCI serial boards.
>
> When no LSR error bits are present, the handler reads GDL bytes from
> UART_RX and inserts them into the TTY flip buffer. If error bits are
> detected, it falls back to the default serial8250_rx_chars() handler.
...
> +static void mxupci8250_rx_chars(struct uart_8250_port *up)
> +{
> + struct uart_port *port = &up->port;
> + struct tty_port *tport = &port->state->port;
> + int recv_room, gdl, i;
> + u8 buf[MOXA_UART_FIFO_SIZE];
> +
> + recv_room = tty_buffer_request_room(tport, port->fifosize);
> +
Stray blank line addition.
> + if (recv_room) {
Can't it be
if (!recv_room)
return;
?
> + gdl = serial_in(up, MOXA_UART_GDL);
> +
Stray blank line addition.
> + if (gdl > recv_room)
> + gdl = recv_room;
> +
> + for (i = 0; i < gdl; ++i)
> + buf[i] = serial_in(up, UART_RX);
> +
> + port->icount.rx += gdl;
> + tty_insert_flip_string(tport, buf, gdl);
> + tty_flip_buffer_push(tport);
> + }
> +}
...
> - if (lsr & (UART_LSR_DR | UART_LSR_BI) && !skip_rx)
> - lsr = serial8250_rx_chars(up, lsr);
> -
> + if (lsr & (UART_LSR_DR | UART_LSR_BI) && !skip_rx) {
> + if (lsr & UART_LSR_BRK_ERROR_BITS)
> + lsr = serial8250_rx_chars(up, lsr);
> + else
> + mxupci8250_rx_chars(up);
> + }
Oh, can we reduce ping-pong a bit (the modification of the lines just
being added earlier in the same patch series)?
I think you can create a helper to wrap 8250_rx_chars() with split
version of the almost unreadable conditionals, this will also remove
the skip_rx variable
static ... _rx_chars()
{
/* split version of skip_rx monstrous if */
if ...
return ...;
if ...
return ...;
if ...
return ...;
return 8250_rx_chars(...);
}
Then in this patch only a couple of lines will be added to the end of
the function.
if (...)
return ...
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists