Re: [PATCH v10 1/3] net: ethernet: mtk_eth_soc: fix return value and refactor MDIO ops

From: Andrew Lunn
Date: Sun Jan 02 2022 - 11:45:17 EST


> +static int _mtk_mdio_write(struct mtk_eth *eth, u32 phy_addr, u32 phy_reg,
> + u32 write_data)
> {
> if (mtk_mdio_busy_wait(eth))
> - return -1;
> -
> - write_data &= 0xffff;
> + return -EBUSY;

-ETIMEDOUT would be more normal.

I would probably also change mtk_mdio_busy_wait() so that it either
returned 0, or -ETIMEDOUT. That is the general pattern in Linux,
return 0 on success, or a negative error code. Returning -1 is an
invitation for trouble.

The code would then become

ret = mtk_mdio_busy_wait(eth);
if (ret < 0)
return ret;

which is a very common pattern in Linux.

Andrew