[PATCH v10 1/3] net: ethernet: mtk_eth_soc: fix return value and refactor MDIO ops
Andrew Lunn
andrew at lunn.ch
Sun Jan 2 08:43:32 PST 2022
> +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
More information about the linux-arm-kernel
mailing list