net: ethernet: mtk_eth_soc: fix return values and refactor MDIO ops
authorDaniel Golle <daniel@makrotopia.org>
Tue, 4 Jan 2022 12:06:22 +0000 (12:06 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 27 Jan 2022 10:03:49 +0000 (11:03 +0100)
commit6dab20da69f9b92ebbdd8beed45002ecb3c83cda
treee7708e24a4f61eef2b2357bdbb235edec8e0f3d9
parent10f849d3e563f0b443cdc38ff9e4000ec12ca432
net: ethernet: mtk_eth_soc: fix return values and refactor MDIO ops

[ Upstream commit eda80b249df7bbc7b3dd13907343a3e59bfc57fd ]

Instead of returning -1 (-EPERM) when MDIO bus is stuck busy
while writing or 0xffff if it happens while reading, return the
appropriate -ETIMEDOUT. Also fix return type to int instead of u32.
Refactor functions to use bitfield helpers instead of having various
masking and shifting constants in the code, which also results in the
register definitions in the header file being more obviously related
to what is stated in the MediaTek's Reference Manual.

Fixes: 656e705243fd0 ("net-next: mediatek: add support for MT7623 ethernet")
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/mediatek/mtk_eth_soc.c
drivers/net/ethernet/mediatek/mtk_eth_soc.h