diff mbox series

[net-next,06/11] net: phy: marvell: initialise link partner state earlier

Message ID E1ihD4Q-0001yt-JM@rmk-PC.armlinux.org.uk
State Accepted
Delegated to: David Miller
Headers show
Series phylib consolidation | expand

Commit Message

Russell King (Oracle) Dec. 17, 2019, 1:39 p.m. UTC
Move the initialisation of the link partner state earlier, inside
marvell_read_status_page(), so we don't have the same initialisation
scattered amongst the other files.  This is in a similar place to
the genphy implementation, so would result in the same behaviour if
a PHY read error occurs.

This allows us to get rid of marvell_read_status_page_fixed(), which
became a pointless wrapper around genphy_read_status_fixed().

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
---
 drivers/net/phy/marvell.c | 25 +++++--------------------
 1 file changed, 5 insertions(+), 20 deletions(-)

Comments

Andrew Lunn Dec. 17, 2019, 3:45 p.m. UTC | #1
On Tue, Dec 17, 2019 at 01:39:26PM +0000, Russell King wrote:
> Move the initialisation of the link partner state earlier, inside
> marvell_read_status_page(), so we don't have the same initialisation
> scattered amongst the other files.  This is in a similar place to
> the genphy implementation, so would result in the same behaviour if
> a PHY read error occurs.
> 
> This allows us to get rid of marvell_read_status_page_fixed(), which
> became a pointless wrapper around genphy_read_status_fixed().
> 
> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew
Florian Fainelli Dec. 17, 2019, 5:30 p.m. UTC | #2
On 12/17/19 5:39 AM, Russell King wrote:
> Move the initialisation of the link partner state earlier, inside
> marvell_read_status_page(), so we don't have the same initialisation
> scattered amongst the other files.  This is in a similar place to
> the genphy implementation, so would result in the same behaviour if
> a PHY read error occurs.
> 
> This allows us to get rid of marvell_read_status_page_fixed(), which
> became a pointless wrapper around genphy_read_status_fixed().
> 
> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
diff mbox series

Patch

diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
index 18080d9c0cd9..d57df48b3568 100644
--- a/drivers/net/phy/marvell.c
+++ b/drivers/net/phy/marvell.c
@@ -1230,8 +1230,6 @@  static int marvell_read_status_page_an(struct phy_device *phydev,
 		if (err < 0)
 			return err;
 
-		phydev->pause = 0;
-		phydev->asym_pause = 0;
 		phy_resolve_aneg_pause(phydev);
 	} else {
 		lpa = phy_read(phydev, MII_LPA);
@@ -1241,8 +1239,6 @@  static int marvell_read_status_page_an(struct phy_device *phydev,
 		/* The fiber link is only 1000M capable */
 		fiber_lpa_mod_linkmode_lpa_t(phydev->lp_advertising, lpa);
 
-		phydev->pause = 0;
-		phydev->asym_pause = 0;
 		if (phydev->duplex == DUPLEX_FULL) {
 			if (!(lpa & LPA_PAUSE_FIBER)) {
 				phydev->pause = 0;
@@ -1279,21 +1275,6 @@  static int marvell_read_status_page_an(struct phy_device *phydev,
 	return 0;
 }
 
-static int marvell_read_status_page_fixed(struct phy_device *phydev)
-{
-	int err;
-
-	err = genphy_read_status_fixed(phydev);
-	if (err < 0)
-		return err;
-
-	phydev->pause = 0;
-	phydev->asym_pause = 0;
-	linkmode_zero(phydev->lp_advertising);
-
-	return 0;
-}
-
 /* marvell_read_status_page
  *
  * Description:
@@ -1319,10 +1300,14 @@  static int marvell_read_status_page(struct phy_device *phydev, int page)
 	if (err)
 		return err;
 
+	linkmode_zero(phydev->lp_advertising);
+	phydev->pause = 0;
+	phydev->asym_pause = 0;
+
 	if (phydev->autoneg == AUTONEG_ENABLE)
 		err = marvell_read_status_page_an(phydev, fiber);
 	else
-		err = marvell_read_status_page_fixed(phydev);
+		err = genphy_read_status_fixed(phydev);
 
 	return err;
 }