Re: [PATCH v2 2/2] serial: rsci: Remove goto and refactor baud rate clock selection

From: Geert Uytterhoeven

Date: Wed Apr 08 2026 - 12:02:42 EST


Hi Biju,

On Wed, 8 Apr 2026 at 17:45, Geert Uytterhoeven <geert@xxxxxxxxxxxxxx> wrote:
> On Wed, 8 Apr 2026 at 16:21, Biju <biju.das.au@xxxxxxxxx> wrote:
> > From: Biju Das <biju.das.jz@xxxxxxxxxxxxxx>
> >
> > Replace the goto done pattern in rsci_set_termios() with a positive
> > conditional block. When baud rate is zero, the clock selection logic
> > is now simply skipped rather than jumping to a 'done' label, eliminating
> > the goto entirely.
> >
> > Since RSCI only uses a single clock source (SCI_FCK), the multi-clock
> > tracking variables (best_clk, min_err, brr1, srr1, cks1) are redundant
> > and removed. ccr0_val and ccr4_val are likewise dropped, replaced with
> > hardcoded 0 at their write sites, as they were never modified from their
> > initial zero values.
> >
> > No functional change intended.
> >
> > Reported-by: Pavel Machek <pavel@xxxxxxxxxxxx>
> > Closes: https://lore.kernel.org/all/abPpZULsXhRmXTX9@xxxxxxxxxx/
> > Signed-off-by: Biju Das <biju.das.jz@xxxxxxxxxxxxxx>
> > ---
> > v1->v2:
> > * Dropped the check (abs(err) < abs(min_err) as it is always true.
> > * Dropped the check (abs(err) < abs(min_err) as it is always true.
> > * Dropped variables best_clk and min_err as they are no longer needed.
> > * Dropped intermediate variables brr1, cks1 and srr1; results are now
> > written directly into brr, cks and srr.
> > * Moved dev_dbg() inside the if (baud) block.
> > * Dropped ccr0_val and ccr4_val, replaced with hardcoded 0 at their
> > write sites, as they were never modified from their initial values.
> > * Scoped variables err and srr locally within the if (baud) block.
> > * Updated commit description.
>
> Reviewed-by: Geert Uytterhoeven <geert+renesas@xxxxxxxxx>

I spoke too soon, you need one more change to make it build:

--- a/drivers/tty/serial/rsci.c
+++ b/drivers/tty/serial/rsci.c
@@ -308,8 +308,7 @@ static void rsci_set_termios(struct uart_port
*port, struct ktermios *termios,
rsci_serial_out(port, CFCLR, CFCLR_CLRFLAG);
rsci_serial_out(port, FFCLR, FFCLR_DRC);

- ccr0_val |= CCR0_RE;
- rsci_serial_out(port, CCR0, ccr0_val);
+ rsci_serial_out(port, CCR0, CCR0_RE);

if ((termios->c_cflag & CREAD) != 0)
rsci_start_rx(port);

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds