[openwrt/openwrt] realtek: rtl930x: Clean up LED set initialization

LEDE Commits lede-commits at lists.infradead.org
Mon Oct 6 15:15:49 PDT 2025


hauke pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/21d56eeefa88da4fbc44e6efaec89a7f0154909c

commit 21d56eeefa88da4fbc44e6efaec89a7f0154909c
Author: Sven Eckelmann <se at simonwunderlich.de>
AuthorDate: Tue Jul 15 19:53:07 2025 +0200

    realtek: rtl930x: Clean up LED set initialization
    
    The integration of the LED set initialization for RTL931x added also minor
    improvements in the coding style. Just adopt them also for RTL9301x.
    
    Signed-off-by: Sven Eckelmann <se at simonwunderlich.de>
    Link: https://github.com/openwrt/openwrt/pull/20300
    Signed-off-by: Hauke Mehrtens <hauke at hauke-m.de>
---
 .../files-6.12/drivers/net/dsa/rtl83xx/rtl930x.c   | 26 +++++++++++-----------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl930x.c b/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl930x.c
index e507a931cf..d47319c013 100644
--- a/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl930x.c
+++ b/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl930x.c
@@ -2383,13 +2383,12 @@ static void rtl930x_led_init(struct rtl838x_switch_priv *priv)
 		sw_w32(0, RTL930X_LED_SETX_0_CTRL(set));
 		sw_w32(0, RTL930X_LED_SETX_1_CTRL(set));
 
-		/**
-		 * Each led set has 4 number of leds, and each LED is configured with 16 bits
-		 * So each 32bit register holds configuration for 2 leds
-		 * And therefore each set requires 2 registers for configuring 4 LEDs
-		 *
-		*/
-		sprintf(set_name, "led_set%d", set);
+		/* Each LED set has (up to) 4 LEDs, and each LED is configured
+		 * with 16 bits. So each 32 bit register holds configuration for
+		 * 2 LEDs. Therefore, each set requires 2 registers for
+		 * configuring all 4 LEDs.
+		 */
+		snprintf(set_name, sizeof(set_name), "led_set%d", set);
 		leds_in_this_set = of_property_count_u32_elems(node, set_name);
 
 		if (leds_in_this_set <= 0 || leds_in_this_set > ARRAY_SIZE(set_config)) {
@@ -2397,20 +2396,21 @@ static void rtl930x_led_init(struct rtl838x_switch_priv *priv)
 				dev_err(dev, "%s invalid, skipping this set, leds_in_this_set=%d, should be (0, %d]\n",
 					set_name, leds_in_this_set, ARRAY_SIZE(set_config));
 			}
+
 			continue;
 		}
+
 		dev_info(dev, "%s has %d LEDs configured\n", set_name, leds_in_this_set);
 		leds_in_set[set] = leds_in_this_set;
 
-		if (of_property_read_u32_array(node, set_name, set_config, leds_in_this_set)) {
+		if (of_property_read_u32_array(node, set_name, set_config, leds_in_this_set))
 			break;
-		}
 
-		/* Write configuration as per number of LEDs */
-		for (int i=0, led = leds_in_this_set-1; led >= 0; led--,i++) {
+		/* Write configuration for selected LEDs */
+		for (int i = 0, led = leds_in_this_set - 1; led >= 0; led--, i++) {
 			sw_w32_mask(0xffff << RTL930X_LED_SET_LEDX_SHIFT(led),
-						(0xffff & set_config[i]) << RTL930X_LED_SET_LEDX_SHIFT(led),
-						RTL930X_LED_SETX_LEDY(set, led));
+				    (0xffff & set_config[i]) << RTL930X_LED_SET_LEDX_SHIFT(led),
+				    RTL930X_LED_SETX_LEDY(set, led));
 		}
 	}
 




More information about the lede-commits mailing list