Re: [net-next PATCH v2 2/2] net: phy: mediatek: add Airoha PHY ID to SoC driver

From: Christian Marangi
Date: Mon Apr 14 2025 - 06:31:16 EST


On Thu, Apr 10, 2025 at 08:07:33PM +0100, Simon Horman wrote:
> 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@xxxxxxx>
> > Signed-off-by: Christian Marangi <ansuelsmth@xxxxxxxxx>
>
> ...
>
> > 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.
>
> > +}
>
> ...

Almost impossible but yes I will post a follow-up patch fixing this!

--
Ansuel