lib: utils/serial: Ensure baudrate is non-zero before using
authorAndrew Jones <ajones@ventanamicro.com>
Mon, 18 Jul 2022 17:20:28 +0000 (19:20 +0200)
committerAnup Patel <anup@brainfault.org>
Sat, 30 Jul 2022 06:09:42 +0000 (11:39 +0530)
commitf27203525aa2fc20d0074feb892a6f8433f84e3a
treedb3f886de35c8bd270564e97278ae9ab08833d95
parent7198e1d06f486173e6565ff6c718f30bf8c2ff30
lib: utils/serial: Ensure baudrate is non-zero before using

RISC-V doesn't generate exceptions on divide-by-zero, but the result,
all bits set, is not likely what people expect either. In all cases
where we divide by baudrate there's a chance it's zero (when the DT
it came from is "bad"). To avoid difficult to debug situations, leave
baudrate dependent registers alone when baudrate is zero, as, also in
all cases, it appears we can skip initialization of those registers
and still [hopefully] have a functioning UART.

Signed-off-by: Andrew Jones <ajones@ventanamicro.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
lib/utils/serial/gaisler-uart.c
lib/utils/serial/shakti-uart.c
lib/utils/serial/sifive-uart.c
lib/utils/serial/uart8250.c