[net-next PATCH v17 6/8] mfd: an8855: Add support for Airoha AN8855 Switch MFD

Simon Horman horms at kernel.org
Mon Sep 15 04:00:00 PDT 2025


On Sat, Sep 13, 2025 at 03:04:40PM +0200, Christian Marangi wrote:
> On Sat, Sep 13, 2025 at 02:01:37PM +0100, Simon Horman wrote:
> > On Thu, Sep 11, 2025 at 03:39:21PM +0200, Christian Marangi wrote:
> > > Add support for Airoha AN8855 Switch MFD that provide support for a DSA
> > > switch and a NVMEM provider.
> > > 
> > > Also make use of the mdio-regmap driver and register a regmap for each
> > > internal PHY of the switch.
> > > This is needed to handle the double usage of the PHYs as both PHY and
> > > Switch accessor.
> > > 
> > > Signed-off-by: Christian Marangi <ansuelsmth at gmail.com>
> > 
> > ...
> > 
> > > diff --git a/drivers/mfd/airoha-an8855.c b/drivers/mfd/airoha-an8855.c
> > 
> > ...
> > 
> > > +static int an855_mdio_register(struct device *dev, struct an8855_core_priv *priv)
> > > +{
> > > +	struct device_node *mdio_np;
> > > +	int ret;
> > > +
> > > +	mdio_np = of_get_child_by_name(dev->of_node, "mdio");
> > > +	if (!mdio_np)
> > > +		return -ENODEV;
> > > +
> > > +	for_each_available_child_of_node_scoped(mdio_np, phy_np) {
> > > +		ret = an8855_phy_register(dev, priv, phy_np);
> > > +		if (ret)
> > > +			break;
> > > +	}
> > 
> > Hi Christian,
> > 
> > Maybe it cannot happen, but if the loop above iterates zero times,
> > then ret will be used uninitialised below.
> > 
> > Flagged by Smatch.
> >
> 
> Do you have hint of how to run smatch on this? Is there a simple arg to
> make to enable this?

Perhaps not so simple, but also not so difficult.

1. Checkout Smatch from and compile

   Smatch can be found in Git here:
   https://github.com/error27/smatch/commits/master/

2. Prepare kernel

   e.g. make allmodconfig

3. Run Smatch

   PATH="$PATH:.../smatch/bin" \
   .../smatch/smatch_scripts/kchecker drivers/mfd/airoha-an8855.o
   [ snip ]
   drivers/mfd/airoha-an8855.c:439 an855_mdio_register() error: uninitialized symbol 'ret'.

> Anyway yes it goes against schema but it's possible somehow to have a
> very broken DT node with no phy in it.

Understood, thanks.

...



More information about the Linux-mediatek mailing list