On Mon, Mar 01, 2021 at 06:25:27PM +0800, Joakim Zhang wrote:
> @@ -121,11 +132,22 @@ static int stmmac_xgmac2_mdio_read(struct mii_bus *bus, 
> int phyaddr, int phyreg)
>  
>       /* Wait until any existing MII operation is complete */
>       if (readl_poll_timeout(priv->ioaddr + mii_data, tmp,
> -                            !(tmp & MII_XGMAC_BUSY), 100, 10000))
> -             return -EBUSY;
> +                            !(tmp & MII_XGMAC_BUSY), 100, 10000)) {
> +             ret = -EBUSY;
> +             goto err_disable_clks;
> +     }
>  
>       /* Read the data from the MII data register */
> -     return readl(priv->ioaddr + mii_data) & GENMASK(15, 0);
> +     data = (int)readl(priv->ioaddr + mii_data) & GENMASK(15, 0);
> +
> +     pm_runtime_put(priv->device);
> +
> +     return data;
> +
> +err_disable_clks:
> +     pm_runtime_put(priv->device);
> +
> +     return ret;

Hi Joakim

You could do

        ret = (int)readl(priv->ioaddr + mii_data) & GENMASK(15, 0);

err_disable_clks:
        pm_runtime_put(priv->device);

        return ret;

Slightly simpler.

>  
>       /* Read the data from the MII data register */
>       data = (int)readl(priv->ioaddr + mii_data) & MII_DATA_MASK;
>  
> +     pm_runtime_put(priv->device);
> +
>       return data;
> +
> +err_disable_clks:
> +     pm_runtime_put(priv->device);
> +
> +     return ret;
>  }

Same here.

Otherwise:

Reviewed-by: Andrew Lunn <[email protected]>

    Andrew

Reply via email to