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

Simon Horman horms at kernel.org
Sat Sep 13 06:01:37 PDT 2025


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.

> +
> +	of_node_put(mdio_np);
> +	return ret;
> +}

...



More information about the Linux-mediatek mailing list