[PATCH net-next 2/2] net: phy: mtk-ge-soc: Fix LED behavior if blinking is not set.

Sky Huang posted 2 patches 7 months ago
[PATCH net-next 2/2] net: phy: mtk-ge-soc: Fix LED behavior if blinking is not set.
Posted by Sky Huang 7 months ago
From: Sky Huang <skylake.huang@mediatek.com>

If delay_on==0 and delay_off==0 are passed to
mt798x_2p5ge_phy_led_blink_set() and mtk_phy_led_num_dly_cfg(),
blinking is actually not set. So don't clean "LED on" status under
this circumstance.

Signed-off-by: Sky Huang <skylake.huang@mediatek.com>
---
 drivers/net/phy/mediatek/mtk-ge-soc.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/net/phy/mediatek/mtk-ge-soc.c b/drivers/net/phy/mediatek/mtk-ge-soc.c
index cd0968478..15dcf2046 100644
--- a/drivers/net/phy/mediatek/mtk-ge-soc.c
+++ b/drivers/net/phy/mediatek/mtk-ge-soc.c
@@ -1228,8 +1228,11 @@ static int mt798x_phy_led_blink_set(struct phy_device *phydev, u8 index,
 	if (err)
 		return err;
 
-	return mtk_phy_hw_led_on_set(phydev, index, MTK_GPHY_LED_ON_MASK,
-				     false);
+	if (blinking)
+		mtk_phy_hw_led_on_set(phydev, index, MTK_GPHY_LED_ON_MASK,
+				      false);
+
+	return 0;
 }
 
 static int mt798x_phy_led_brightness_set(struct phy_device *phydev,
-- 
2.45.2
Re: [PATCH net-next 2/2] net: phy: mtk-ge-soc: Fix LED behavior if blinking is not set.
Posted by Andrew Lunn 6 months, 4 weeks ago
On Fri, May 23, 2025 at 07:36:01PM +0800, Sky Huang wrote:
> From: Sky Huang <skylake.huang@mediatek.com>
> 
> If delay_on==0 and delay_off==0 are passed to
> mt798x_2p5ge_phy_led_blink_set() and mtk_phy_led_num_dly_cfg(),
> blinking is actually not set. So don't clean "LED on" status under
> this circumstance.

Actually, i think mtk_phy_led_num_dly_cfg() is wrong.

https://docs.kernel.org/leds/leds-class.html#hardware-accelerated-blink-of-leds

   The blink_set() function should choose a user friendly blinking
   value if it is called with *delay_on==0 && *delay_off==0
   parameters. In this case the driver should give back the chosen
   value through delay_on and delay_off parameters to the leds
   subsystem.

That is not what mtk_phy_led_num_dly_cfg() does.

    Andrew

---
pw-bot: cr