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.
This commit is contained in:
bloqaudio committed 2026-09-18 13:59:50 -05:00
1 parent 0cc09e4015
commit d22ec04b5b
1 file changed
+2 -2
+2 -2
View File
@@ -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;