Messages in this thread |  | | Date | Thu, 10 Apr 2025 20:07:33 +0100 | | From | Simon Horman <> | | Subject | Re: [net-next PATCH v2 2/2] net: phy: mediatek: add Airoha PHY ID to SoC driver |
| |
On Thu, Apr 10, 2025 at 12:04:04PM +0200, Christian Marangi wrote: > Airoha AN7581 SoC ship with a Switch based on the MT753x Switch embedded > in other SoC like the MT7581 and the MT7988. Similar to these they > require configuring some pin to enable LED PHYs. > > Add support for the PHY ID for the Airoha embedded Switch and define a > simple probe function to toggle these pins. Also fill the LED functions > and add dedicated function to define LED polarity. > > Reviewed-by: Andrew Lunn <andrew@lunn.ch> > Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
...
> diff --git a/drivers/net/phy/mediatek/mtk-ge-soc.c b/drivers/net/phy/mediatek/mtk-ge-soc.c
...
> +static int an7581_phy_led_polarity_set(struct phy_device *phydev, int index, > + unsigned long modes) > +{ > + u32 mode; > + u16 val; > + > + if (index >= MTK_PHY_MAX_LEDS) > + return -EINVAL; > + > + for_each_set_bit(mode, &modes, __PHY_LED_MODES_NUM) { > + switch (mode) { > + case PHY_LED_ACTIVE_LOW: > + val = MTK_PHY_LED_ON_POLARITY; > + break; > + case PHY_LED_ACTIVE_HIGH: > + val = 0; > + break; > + default: > + return -EINVAL; > + } > + } > + > + return phy_modify_mmd(phydev, MDIO_MMD_VEND2, index ? > + MTK_PHY_LED1_ON_CTRL : MTK_PHY_LED0_ON_CTRL, > + MTK_PHY_LED_ON_POLARITY, val);
Hi Christian,
Perhaps this cannot occur in practice, but if the for_each_set_bit loop iterates zero times then val will be used uninitialised here.
Flagged by Smatch.
> +}
...
|  |