Re: [PATCH v2 2/4] serial: 8250_dw: Only accept a contiguous DLF readback
From: Jiri Slaby
Date: Tue Oct 20 2026 - 02:11:18 EST
On 19. 10. 26, 22:06, Vinicius Pedrosa wrote:
--- a/drivers/tty/serial/8250/8250_dwlib.c
+++ b/drivers/tty/serial/8250/8250_dwlib.c
@@ -225,7 +225,11 @@ void dw8250_setup_port(struct uart_port *p)
reg = dw8250_readl_ext(p, DW_UART_DLF);
dw8250_writel_ext(p, DW_UART_DLF, old_dlf);
- if (reg) {
+ /*
+ * DLF is a bit field starting at bit 0, so a real one reads back as
+ * 2^n - 1. Any other value means this offset is something else.
+ */
+ if (reg && !(reg & (reg + 1))) {
Do I understand correctly, that this equivalent to:
if (is_power_of_2(reg + 1))
?
thanks,
--
js
suse labs