net: phy: at803x: Use helpers to access MMD PHY registers
Subsystems (3)
PATCH 1/1 net: phy: at803x: Use helpers to access MMD PHY registers
Libphy provides a standard set of helpers to access the MMD PHY registers. Use those instead of relying on custom driver-specific functions.
--- drivers/net/phy/at803x.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-)
drivers/net/phy/at803x.c +3 -13
@@ -39,9 +39,6 @@#define AT803X_LOC_MAC_ADDR_0_15_OFFSET 0x804C#define AT803X_LOC_MAC_ADDR_16_31_OFFSET 0x804B#define AT803X_LOC_MAC_ADDR_32_47_OFFSET 0x804A -#define AT803X_MMD_ACCESS_CONTROL 0x0D -#define AT803X_MMD_ACCESS_CONTROL_DATA 0x0E -#define AT803X_FUNC_DATA 0x4003#define AT803X_REG_CHIP_CONFIG 0x1f#define AT803X_BT_BX_REG_SEL 0x8000
@@ -168,16 +165,9 @@ static int at803x_set_wol(struct phy_device *phydev,if (!is_valid_ether_addr (mac))return -EINVAL ; -for (i =0 ; i <3 ; i++) { -phy_write (phydev,AT803X_MMD_ACCESS_CONTROL , -AT803X_DEVICE_ADDR ); -phy_write (phydev,AT803X_MMD_ACCESS_CONTROL_DATA , - offsets[i]); -phy_write (phydev,AT803X_MMD_ACCESS_CONTROL , -AT803X_FUNC_DATA ); -phy_write (phydev,AT803X_MMD_ACCESS_CONTROL_DATA , - mac[(i *2 ) +1 ] | (mac[(i *2 )] <<8 )); - } +for (i =0 ; i <3 ; i++) +phy_write_mmd (phydev,AT803X_DEVICE_ADDR , offsets[i], + mac[(i *2 ) +1 ] | (mac[(i *2 )] <<8 )); value =phy_read (phydev,AT803X_INTR_ENABLE ); value |=AT803X_INTR_ENABLE_WOL ;
Signature · 1 line
2.19.1
Quoted 3 lines · Carlo Caione
Libphy provides a standard set of helpers to access the MMD PHY registers. Use those instead of relying on custom driver-specific functions.
Hi Carlo
Maybe deja vu, but i thought a similar patch went by recently?
Anyway,
Andrew
Quoted 43 lines
Signed-off-by Carlo Caione <[email protected]>--- drivers/net/phy/at803x.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-)drivers/net/phy/at803x.c +3
-13@@ -39,9 +39,6 @@#define AT803X_LOC_MAC_ADDR_0_15_OFFSET 0x804C#define AT803X_LOC_MAC_ADDR_16_31_OFFSET 0x804B#define AT803X_LOC_MAC_ADDR_32_47_OFFSET 0x804A -#define AT803X_MMD_ACCESS_CONTROL 0x0D -#define AT803X_MMD_ACCESS_CONTROL_DATA 0x0E -#define AT803X_FUNC_DATA 0x4003#define AT803X_REG_CHIP_CONFIG 0x1f#define AT803X_BT_BX_REG_SEL 0x8000@@ -168,16 +165,9 @@ static int at803x_set_wol(struct phy_device *phydev,if (!is_valid_ether_addr (mac))return -EINVAL ; -for (i =0 ; i <3 ; i++) { -phy_write (phydev,AT803X_MMD_ACCESS_CONTROL , -AT803X_DEVICE_ADDR ); -phy_write (phydev,AT803X_MMD_ACCESS_CONTROL_DATA , - offsets[i]); -phy_write (phydev,AT803X_MMD_ACCESS_CONTROL , -AT803X_FUNC_DATA ); -phy_write (phydev,AT803X_MMD_ACCESS_CONTROL_DATA , - mac[(i *2 ) +1 ] | (mac[(i *2 )] <<8 )); - } +for (i =0 ; i <3 ; i++) +phy_write_mmd (phydev,AT803X_DEVICE_ADDR , offsets[i], + mac[(i *2 ) +1 ] | (mac[(i *2 )] <<8 )); value =phy_read (phydev,AT803X_INTR_ENABLE ); value |=AT803X_INTR_ENABLE_WOL ;Signature · 1 line
2.19.1
Quoted 6 lines · Andrew Lunn
Quoted 3 lines · Carlo Caione
Libphy provides a standard set of helpers to access the MMD PHY registers. Use those instead of relying on custom driver-specific functions.
Hi Carlo
Hey Andrew,
Quoted 1 line
Maybe deja vu, but i thought a similar patch went by recently?
uhm, not from me for sure. There is a discussion going on about similar stuff on the U-Boot ml, maybe you saw that?
Anyway, feel free to drop this if someone already fixed this.
Thanks,
--
Carlo Caione
Heiner Kallweit
maintainerQuoted 9 lines · Andrew Lunn
Quoted 3 lines · Carlo Caione
Libphy provides a standard set of helpers to access the MMD PHY registers. Use those instead of relying on custom driver-specific functions.
Hi Carlo
Maybe deja vu, but i thought a similar patch went by recently?
Andrew, maybe you mean this one?
9b420eff9fcf ("net: phy: micrel: use phy_read_mmd and phy_write_mmd")
Quoted 51 lines
Anyway,
Reviewed-by Andrew Lunn <[email protected]>Andrew
Quoted 43 lines
Signed-off-by Carlo Caione <[email protected]>--- drivers/net/phy/at803x.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-)drivers/net/phy/at803x.c +3
-13@@ -39,9 +39,6 @@#define AT803X_LOC_MAC_ADDR_0_15_OFFSET 0x804C#define AT803X_LOC_MAC_ADDR_16_31_OFFSET 0x804B#define AT803X_LOC_MAC_ADDR_32_47_OFFSET 0x804A -#define AT803X_MMD_ACCESS_CONTROL 0x0D -#define AT803X_MMD_ACCESS_CONTROL_DATA 0x0E -#define AT803X_FUNC_DATA 0x4003#define AT803X_REG_CHIP_CONFIG 0x1f#define AT803X_BT_BX_REG_SEL 0x8000@@ -168,16 +165,9 @@ static int at803x_set_wol(struct phy_device *phydev,if (!is_valid_ether_addr (mac))return -EINVAL ; -for (i =0 ; i <3 ; i++) { -phy_write (phydev,AT803X_MMD_ACCESS_CONTROL , -AT803X_DEVICE_ADDR ); -phy_write (phydev,AT803X_MMD_ACCESS_CONTROL_DATA , - offsets[i]); -phy_write (phydev,AT803X_MMD_ACCESS_CONTROL , -AT803X_FUNC_DATA ); -phy_write (phydev,AT803X_MMD_ACCESS_CONTROL_DATA , - mac[(i *2 ) +1 ] | (mac[(i *2 )] <<8 )); - } +for (i =0 ; i <3 ; i++) +phy_write_mmd (phydev,AT803X_DEVICE_ADDR , offsets[i], + mac[(i *2 ) +1 ] | (mac[(i *2 )] <<8 )); value =phy_read (phydev,AT803X_INTR_ENABLE ); value |=AT803X_INTR_ENABLE_WOL ;Signature · 1 line
2.19.1.
Andrew Lunn
maintainerQuoted 6 lines · Heiner Kallweit
Quoted 5 lines · Andrew Lunn
Quoted 3 lines · Carlo Caione
Libphy provides a standard set of helpers to access the MMD PHY registers. Use those instead of relying on custom driver-specific functions.
Quoted 7 lines
Quoted 4 lines
Hi Carlo
Maybe deja vu, but i thought a similar patch went by recently?
Andrew, maybe you mean this one?
9b420eff9fcf("net: phy: micrel: usephy_read_mmdandphy_write_mmd")
Yes, probably that one.
Might be worth grepping of 0xd, 0xe, 0x0d, 0x0e, 13, 14, and see if there are any more instances in PHY drivers.
Andrew
Quoted 5 lines · Carlo Caione
Libphy provides a standard set of helpers to access the MMD PHY registers. Use those instead of relying on custom driver-specific functions.
Signed-off-by Carlo Caione <[email protected]>
Signature · 1 line
Florian
From: Carlo Caione <[email protected]>
Date: Fri, 25 Jan 2019 12:35:10 +0000
Quoted 5 lines
Libphy provides a standard set of helpers to access the MMD PHY registers. Use those instead of relying on custom driver-specific functions.
Signed-off-by Carlo Caione <[email protected]>
Applied to net-next.