Subject: Re: [PATCH net-next 2/3] net: ag71xx: use devm for of_mdiobus_register

From: Simon Horman <[email-masked]>
Date: Tue, 13 Aug 2024 11:52:04 +0100

On Mon, Aug 12, 2024 at 12:06:52PM -0700, Rosen Penev wrote:
> Allows removing ag71xx_mdio_remove.
> 
> Removed local mii_bus variable and assign struct members directly.
> Easier to reason about.
> 
> Signed-off-by: Rosen Penev <[email-masked]>
> ---
>  drivers/net/ethernet/atheros/ag71xx.c | 39 ++++++++-------------------
>  1 file changed, 11 insertions(+), 28 deletions(-)
> 
> diff --git a/drivers/net/ethernet/atheros/ag71xx.c b/drivers/net/ethernet/atheros/ag71xx.c
> index c22ebd3c1f46..1bc882fc1388 100644
> --- a/drivers/net/ethernet/atheros/ag71xx.c
> +++ b/drivers/net/ethernet/atheros/ag71xx.c
> @@ -684,12 +684,10 @@ static int ag71xx_mdio_probe(struct ag71xx *ag)
>  {
>  	struct device *dev = &ag->pdev->dev;
>  	struct net_device *ndev = ag->ndev;
> -	static struct mii_bus *mii_bus;
>  	struct device_node *np, *mnp;
>  	int err;
>  
>  	np = dev->of_node;
> -	ag->mii_bus = NULL;
>  
>  	ag->clk_mdio = devm_clk_get_enabled(dev, "mdio");
>  	if (IS_ERR(ag->clk_mdio)) {
> @@ -703,7 +701,7 @@ static int ag71xx_mdio_probe(struct ag71xx *ag)
>  		return err;
>  	}
>  
> -	mii_bus = devm_mdiobus_alloc(dev);
> +	ag->mii_bus = devm_mdiobus_alloc(dev);
>  	if (!mii_bus)

Above mii_bus is removed, but here it is used.

>  		return -ENOMEM;

...