Skip to contentSkip to conversation

net: phy: mediatek: init val in .phy_led_polarity_set for AN7581

PATCH Applied Christian Marangi 3 participants 3 messages Apr 15, 2025 – Apr 17, 2025

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: phy: mediatek: init val in .phy_led_polarity_set for AN7581

Fix smatch warning for uninitialised val in .phy_led_polarity_set for AN7581 driver.

Correctly init to 0 to set polarity high by default.

Fixes 6a325aed130b ("net: phy: mediatek: add Airoha PHY ID to SoC driver")
---
 drivers/net/phy/mediatek/mtk-ge-soc.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/phy/mediatek/mtk-ge-soc.c +1 -2
index fd0e447ffce7..cd09684780a4 100644
@@ -1432,8 +1432,8 @@ static int an7581_phy_probe(struct phy_device *phydev)
 static int an7581_phy_led_polarity_set(struct phy_device *phydev, int index,
 				       unsigned long modes)
 {
+	u16 val = 0;
 	u32 mode;
-	u16 val;
 
 	if (index >= MTK_PHY_MAX_LEDS)
 		return -EINVAL;
@@ -1444,7 +1444,6 @@ static int an7581_phy_led_polarity_set(struct phy_device *phydev, int index,
 			val = MTK_PHY_LED_ON_POLARITY;
 			break;
 		case PHY_LED_ACTIVE_HIGH:
-			val = 0;
 			break;
 		default:
 			return -EINVAL;
Signature · 1 line
2.48.1
#1 lore raw

Il 15/04/25 12:53, Christian Marangi ha scritto:

Quoted 17 lines

Fix smatch warning for uninitialised val in .phy_led_polarity_set for AN7581 driver.

Correctly init to 0 to set polarity high by default.

Fixes 6a325aed130b ("net: phy: mediatek: add Airoha PHY ID to SoC driver")
---
  drivers/net/phy/mediatek/mtk-ge-soc.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/phy/mediatek/mtk-ge-soc.c +0 -0
index fd0e447ffce7..cd09684780a4 100644

drivers/net/phy/mediatek/mtk-ge-soc.c static int an7581_phy_probe(struct phy_device *phydev) · line 1436

Quoted 6 lines
drivers/net/phy/mediatek/mtk-ge-soc.c +1 -1
@@ -1432,8 +1432,8 @@ static int an7581_phy_probe(struct phy_device *phydev)
  static int an7581_phy_led_polarity_set(struct phy_device *phydev, int index,
  				       unsigned long modes)
  {
+	u16 val = 0;
  	u32 mode;
-	u16 val;

....but that's double initialization then, so....

	u32 mode;
	u16 val;

	if (index >= MTK_PHY_MAX_LEDS)
		return -EINVAL;

	if (modes == 0)
		val = 0;

	for_each_set_bit(.....

Cheers,
Angelo

Quoted 11 lines
drivers/net/phy/mediatek/mtk-ge-soc.c +0 -1
  	if (index >= MTK_PHY_MAX_LEDS)
  		return -EINVAL;
@@ -1444,7 +1444,6 @@ static int an7581_phy_led_polarity_set(struct phy_device *phydev, int index,
  			val = MTK_PHY_LED_ON_POLARITY;
  			break;
  		case PHY_LED_ACTIVE_HIGH:
-			val = 0;
  			break;
  		default:
  			return -EINVAL;
#2 lore raw
In reply to Christian Marangi
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 10 lines · On Tue, 15 Apr 2025 12:53:05 +0200 you wrote:

Fix smatch warning for uninitialised val in .phy_led_polarity_set for AN7581 driver.

Correctly init to 0 to set polarity high by default.

Fixes 6a325aed130b ("net: phy: mediatek: add Airoha PHY ID to SoC driver")

[...]

Here is the summary with links:
- [net-next] net: phy: mediatek: init val in .phy_led_polarity_set for AN7581

    https://git.kernel.org/netdev/net-next/c/00868d034818

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html