Linux Serial subsystem development
 help / color / mirror / Atom feed
* [PATCH v3 0/3] serial: sh-sci/rsci: Fix divide-by-zero and clean up baud rate handling
@ 2026-04-20 14:04 Biju
  2026-04-20 14:04 ` [PATCH v3 1/3] serial: sh-sci: Avoid divide-by-zero fault Biju
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Biju @ 2026-04-20 14:04 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby
  Cc: Biju Das, Geert Uytterhoeven, Lad Prabhakar, Thierry Bultel,
	linux-kernel, linux-serial, Biju Das, linux-renesas-soc

From: Biju Das <biju.das.jz@bp.renesas.com>

This series fixes a divide-by-zero fault in the SH-SCI driver and cleans
up dead code and redundant variables related to baud rate handling in both
the SH-SCI and RSCI drivers.

Patch 1 fixes a divide-by-zero fault in sci_set_termios() where the
expression (10000 * bits) / (baud / 100) could divide by zero if baud is
less than 100. The expression is rewritten as (10000 * bits) * 100 / baud,
which is algebraically equivalent but eliminates the intermediate
division.

Patch 2 removes the dead zero baud rate guard from both sci_set_termios()
and rsci_set_termios(). On DT systems, uart_get_baud_rate() never returns
zero, making the if (!baud) goto done; check and its associated done label
unreachable dead code.

Patch 3 refactors the baud rate clock selection in rsci_set_termios().
Since RSCI only supports a single clock source (SCI_FCK), the multi-clock
tracking variables are redundant and removed. ccr0_val and ccr4_val, which
were never modified from their initial zero values, are replaced with
hardcoded 0 at their write sites.

v2->v3:
 * Added a patch to rewrite rx_frame calculation to avoid divide-by-zero.
 * Added a patch to drop zero baud check from sh-sci and rsci drivers.
 * Dropped reported by tag as the goto statement in rsci_set_termios()
   removed in the previous patch.
 * baud check removed by previous patch.
 * Added missing macro CCR0_RE while dropping ccr0_val variable.
 * Updated commit description for patch#3.
v1->v2:
 * Add a patch for avoiding divide-by-zero fault.
 * 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.

Biju Das (3):
  serial: sh-sci: Avoid divide-by-zero fault
  serial: sh-sci: Drop check for zero baud rate from
    uart_get_baud_rate()
  serial: rsci: Refactor baud rate clock selection

 drivers/tty/serial/rsci.c   | 34 ++++++++++------------------------
 drivers/tty/serial/sh-sci.c |  4 +---
 2 files changed, 11 insertions(+), 27 deletions(-)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2026-04-22 14:05 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-20 14:04 [PATCH v3 0/3] serial: sh-sci/rsci: Fix divide-by-zero and clean up baud rate handling Biju
2026-04-20 14:04 ` [PATCH v3 1/3] serial: sh-sci: Avoid divide-by-zero fault Biju
2026-04-20 14:04 ` [PATCH v3 2/3] serial: sh-sci: Drop check for zero baud rate from uart_get_baud_rate() Biju
2026-04-20 15:59   ` Hugo Villeneuve
2026-04-22  7:04   ` Geert Uytterhoeven
2026-04-22  7:26     ` Biju Das
2026-04-22  8:59       ` Geert Uytterhoeven
2026-04-22 14:05         ` Hugo Villeneuve
2026-04-20 14:04 ` [PATCH v3 3/3] serial: rsci: Refactor baud rate clock selection Biju
2026-04-22  6:26   ` Biju Das

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox