From d22ec04b5bbb4384eb38d959ec2833f0f062551b Mon Sep 17 00:00:00 2001 From: bloqaudio Date: Fri, 18 Sep 2026 13:59:50 -0500 Subject: [PATCH] leds: index the second LED register from the set it belongs to leds_setup() walks all four LED sets and writes the high-speed nibble of each into one of two registers, LED3_0_SET1 for sets 0 and 1 and LED3_0_SET3 for sets 2 and 3. The second branch reuses the index expression of the first without rebasing it, so sets 2 and 3 address sfr_data[-1], [-2], [-3] and [-4]. Two things follow. Sets 2 and 3 never receive their nibble, because the read-modify-write pair writes back exactly what it read. And four bytes below sfr_data are overwritten on every boot of every machine: the loop runs over all four sets whatever the board declares. On this build the linker places sfr_data directly after the serial receive ring, so the writes land in the tail of that ring. leds_dump() reads the same two registers back and already rebases with (set - 2); use the same form here. --- rtl837x_leds.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rtl837x_leds.c b/rtl837x_leds.c index e4dc5a8d..d0aa498b 100644 --- a/rtl837x_leds.c +++ b/rtl837x_leds.c @@ -275,7 +275,7 @@ void leds_setup(void) __banked reg_write_m(RTL837X_REG_LED3_0_SET1); } else { reg_read_m(RTL837X_REG_LED3_0_SET3); - sfr_data[3 - (set << 1)] = (*(lptr + 6) << 4) | (*(lptr + 2)); + sfr_data[3 - ((set - 2) << 1)] = (*(lptr + 6) << 4) | (*(lptr + 2)); reg_write_m(RTL837X_REG_LED3_0_SET3); } lptr += 8; @@ -291,7 +291,7 @@ void leds_setup(void) __banked reg_write_m(RTL837X_REG_LED3_0_SET1); } else { reg_read_m(RTL837X_REG_LED3_0_SET3); - sfr_data[2 - (set << 1)] = (*(lptr + 6) << 4) | (*(lptr + 2)); + sfr_data[2 - ((set - 2) << 1)] = (*(lptr + 6) << 4) | (*(lptr + 2)); reg_write_m(RTL837X_REG_LED3_0_SET3); } lptr += 8;