netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Heiner Kallweit <hkallweit1@gmail.com>
To: Russell King - ARM Linux <linux@armlinux.org.uk>,
	Andrew Lunn <andrew@lunn.ch>, Jakub Kicinski <kuba@kernel.org>,
	David Miller <davem@davemloft.net>,
	Paolo Abeni <pabeni@redhat.com>,
	Eric Dumazet <edumazet@google.com>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>
Subject: [PATCH net-next] net: phy: smsc: use phy_clear/set_bits in lan87xx_read_status
Date: Wed, 8 Mar 2023 21:11:02 +0100	[thread overview]
Message-ID: <6c4ca9e8-8b68-f730-7d88-ebb7165f6b1d@gmail.com> (raw)

Simplify the code by using phy_clear/sert_bits().

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 drivers/net/phy/smsc.c | 25 ++++++++++---------------
 1 file changed, 10 insertions(+), 15 deletions(-)

diff --git a/drivers/net/phy/smsc.c b/drivers/net/phy/smsc.c
index af89f3ef1..5965a8afa 100644
--- a/drivers/net/phy/smsc.c
+++ b/drivers/net/phy/smsc.c
@@ -204,17 +204,16 @@ static int lan95xx_config_aneg_ext(struct phy_device *phydev)
 static int lan87xx_read_status(struct phy_device *phydev)
 {
 	struct smsc_phy_priv *priv = phydev->priv;
+	int rc;
 
-	int err = genphy_read_status(phydev);
+	rc = genphy_read_status(phydev);
+	if (rc)
+		return rc;
 
 	if (!phydev->link && priv->energy_enable && phydev->irq == PHY_POLL) {
 		/* Disable EDPD to wake up PHY */
-		int rc = phy_read(phydev, MII_LAN83C185_CTRL_STATUS);
-		if (rc < 0)
-			return rc;
-
-		rc = phy_write(phydev, MII_LAN83C185_CTRL_STATUS,
-			       rc & ~MII_LAN83C185_EDPWRDOWN);
+		rc = phy_clear_bits(phydev, MII_LAN83C185_CTRL_STATUS,
+				    MII_LAN83C185_EDPWRDOWN);
 		if (rc < 0)
 			return rc;
 
@@ -222,24 +221,20 @@ static int lan87xx_read_status(struct phy_device *phydev)
 		 * an actual error.
 		 */
 		read_poll_timeout(phy_read, rc,
-				  rc & MII_LAN83C185_ENERGYON || rc < 0,
+				  rc < 0 || rc & MII_LAN83C185_ENERGYON,
 				  10000, 640000, true, phydev,
 				  MII_LAN83C185_CTRL_STATUS);
 		if (rc < 0)
 			return rc;
 
 		/* Re-enable EDPD */
-		rc = phy_read(phydev, MII_LAN83C185_CTRL_STATUS);
-		if (rc < 0)
-			return rc;
-
-		rc = phy_write(phydev, MII_LAN83C185_CTRL_STATUS,
-			       rc | MII_LAN83C185_EDPWRDOWN);
+		rc = phy_set_bits(phydev, MII_LAN83C185_CTRL_STATUS,
+				  MII_LAN83C185_EDPWRDOWN);
 		if (rc < 0)
 			return rc;
 	}
 
-	return err;
+	return 0;
 }
 
 static int smsc_get_sset_count(struct phy_device *phydev)
-- 
2.39.2


             reply	other threads:[~2023-03-08 20:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-08 20:11 Heiner Kallweit [this message]
2023-03-09 14:31 ` [PATCH net-next] net: phy: smsc: use phy_clear/set_bits in lan87xx_read_status Simon Horman
2023-03-10 20:51   ` Heiner Kallweit
2023-03-13 12:00     ` Simon Horman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6c4ca9e8-8b68-f730-7d88-ebb7165f6b1d@gmail.com \
    --to=hkallweit1@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).