>From 95598e6892cb0d392249f099587bd81ea3b664de Mon Sep 17 00:00:00 2001 From: Christian Marangi Date: Wed, 29 Nov 2023 02:50:09 +0100 Subject: [PATCH] fixup! dsa: qca8k: Use DSA common code for LEDs Fix off-by-one from port_num to phy. Signed-off-by: Christian Marangi --- drivers/net/dsa/qca/qca8k-leds.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/net/dsa/qca/qca8k-leds.c b/drivers/net/dsa/qca/qca8k-leds.c index febae23b65a9..67f42a0dbbd8 100644 --- a/drivers/net/dsa/qca/qca8k-leds.c +++ b/drivers/net/dsa/qca/qca8k-leds.c @@ -9,7 +9,7 @@ static int qca8k_get_enable_led_reg(int port_num, int led_num, struct qca8k_led_pattern_en *reg_info) { - switch (port_num) { + switch (qca8k_port_to_phy(port_num)) { case 0: reg_info->reg = QCA8K_LED_CTRL_REG(led_num); reg_info->shift = QCA8K_LED_PHY0123_CONTROL_RULE_SHIFT; @@ -41,7 +41,7 @@ qca8k_get_control_led_reg(int port_num, int led_num, struct qca8k_led_pattern_en * 3 control rules for phy0-3 that applies to all their leds * 3 control rules for phy4 */ - if (port_num == 4) + if (qca8k_port_to_phy(port_num) == 4) reg_info->shift = QCA8K_LED_PHY4_CONTROL_RULE_SHIFT; else reg_info->shift = QCA8K_LED_PHY0123_CONTROL_RULE_SHIFT; @@ -127,7 +127,8 @@ qca8k_led_brightness_set(struct dsa_switch *ds, int port_num, * to calculate the shift and the correct reg due to this problem of * not having a 1:1 map of LED with the regs. */ - if (port_num == 0 || port_num == 4) { + if (qca8k_port_to_phy(port_num) == 0 || + qca8k_port_to_phy(port_num) == 4) { mask = QCA8K_LED_PATTERN_EN_MASK; val <<= QCA8K_LED_PATTERN_EN_SHIFT; } else { @@ -162,7 +163,8 @@ qca8k_led_blink_set(struct dsa_switch *ds, int port_num, u8 led_num, qca8k_get_enable_led_reg(port_num, led_num, ®_info); - if (port_num == 0 || port_num == 4) { + if (qca8k_port_to_phy(port_num) == 0 || + qca8k_port_to_phy(port_num) == 4) { mask = QCA8K_LED_PATTERN_EN_MASK; val <<= QCA8K_LED_PATTERN_EN_SHIFT; } else { @@ -187,7 +189,8 @@ qca8k_led_trigger_offload(struct qca8k_priv *priv, int port_num, u8 led_num, if (enable) val = QCA8K_LED_RULE_CONTROLLED; - if (port_num == 0 || port_num == 4) { + if (qca8k_port_to_phy(port_num) == 0 || + qca8k_port_to_phy(port_num) == 4) { mask = QCA8K_LED_PATTERN_EN_MASK; val <<= QCA8K_LED_PATTERN_EN_SHIFT; } else { @@ -210,7 +213,8 @@ qca8k_led_hw_control_status(struct qca8k_priv *priv, int port_num, u8 led_num) val >>= reg_info.shift; - if (port_num == 0 || port_num == 4) { + if (qca8k_port_to_phy(port_num) == 0 || + qca8k_port_to_phy(port_num) == 4) { val &= QCA8K_LED_PATTERN_EN_MASK; val >>= QCA8K_LED_PATTERN_EN_SHIFT; } else { -- 2.40.1