Re: [PATCH v5 04/14] serial: 8250_mxpcie: enable automatic RTS/CTS flow control

From: Andy Shevchenko

Date: Sun Aug 02 2026 - 05:01:24 EST


On Fri, Jul 31, 2026 at 10:49 AM Crescent Hsieh
<crescentcy.hsieh@xxxxxxxx> wrote:
>
> The MUEx50 UART supports automatic RTS/CTS flow control via the enhanced
> feature register.
>
> Implement a mxpcie-specific set_termios() callback that enables MUEx50
> auto-RTS/auto-CTS when CRTSCTS is requested and disables it otherwise.
> Keep the 8250 port status flags in sync with the hardware configuration.

...

> +static void mxpcie8250_set_termios(struct uart_port *port,
> + struct ktermios *new,
> + const struct ktermios *old)
> +{
> + struct uart_8250_port *up = up_to_u8250p(port);
> + struct tty_struct *tty = port->state->port.tty;
> + unsigned int cflag = tty->termios.c_cflag;
> + u8 efr;
> +
> + serial8250_do_set_termios(port, new, old);

> + up->port.status &= ~(UPSTAT_AUTORTS | UPSTAT_AUTOCTS);
> +
> + efr = serial_in(up, MOXA_PUART_EFR);
> + efr &= ~(MOXA_PUART_EFR_AUTO_RTS | MOXA_PUART_EFR_AUTO_CTS);
> +
> + if (cflag & CRTSCTS) {
> + efr |= (MOXA_PUART_EFR_AUTO_RTS | MOXA_PUART_EFR_AUTO_CTS);
> + up->port.status |= (UPSTAT_AUTORTS | UPSTAT_AUTOCTS);


Don't you want to use FIELD_MODIFY() at least for efr value? Also
if-else looks better, no?

if (..) {
FIELD_MODIFY(&efr);
up->port.status ...
} else {
...
}

> + }
> + serial_out(up, MOXA_PUART_EFR, efr);
> +}

--
With Best Regards,
Andy Shevchenko