lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu,  3 Jan 2019 02:10:40 +0100
From:   Marek Vasut <marex@...x.de>
To:     netdev@...r.kernel.org
Cc:     Marek Vasut <marex@...x.de>,
        "David S . Miller" <davem@...emloft.net>,
        Nisar Sayed <Nisar.Sayed@...rochip.com>,
        Woojung Huh <Woojung.Huh@...rochip.com>,
        Andrew Lunn <andrew@...n.ch>,
        Florian Fainelli <f.fainelli@...il.com>,
        linux-usb@...r.kernel.org
Subject: [PATCH 19/19] usbnet: smsc95xx: Use phy bit operations

Use bit operations provided by bit.h instead of reimplementing them.
No functional change.

Signed-off-by: Marek Vasut <marex@...x.de>
Cc: David S. Miller <davem@...emloft.net>
Cc: Nisar Sayed <Nisar.Sayed@...rochip.com>
Cc: Woojung Huh <Woojung.Huh@...rochip.com>
Cc: Andrew Lunn <andrew@...n.ch>
Cc: Florian Fainelli <f.fainelli@...il.com>
Cc: linux-usb@...r.kernel.org
To: netdev@...r.kernel.org
---
 drivers/net/usb/smsc95xx.c | 67 +++++++++++++-------------------------
 1 file changed, 22 insertions(+), 45 deletions(-)

diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c
index c9931955c22a..20e41c15ce13 100644
--- a/drivers/net/usb/smsc95xx.c
+++ b/drivers/net/usb/smsc95xx.c
@@ -748,47 +748,35 @@ static void set_mdix_status(struct net_device *net, __u8 mdix_ctrl)
 {
 	struct usbnet *dev = netdev_priv(net);
 	struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]);
-	int buf;
 
 	if ((pdata->chip_id == ID_REV_CHIP_ID_9500A_) ||
 	    (pdata->chip_id == ID_REV_CHIP_ID_9530_) ||
 	    (pdata->chip_id == ID_REV_CHIP_ID_89530_) ||
 	    (pdata->chip_id == ID_REV_CHIP_ID_9730_)) {
 		/* Extend Manual AutoMDIX timer for 9500A/9500Ai */
-		buf = phy_read(pdata->phydev,
-					 PHY_EDPD_CONFIG);
-		buf |= PHY_EDPD_CONFIG_EXT_CROSSOVER_;
-		phy_write(pdata->phydev,
-				    PHY_EDPD_CONFIG, buf);
+		phy_set_bits(pdata->phydev, PHY_EDPD_CONFIG,
+			     PHY_EDPD_CONFIG_EXT_CROSSOVER_);
 	}
 
 	if (mdix_ctrl == ETH_TP_MDI) {
-		buf = phy_read(pdata->phydev,
-					 SPECIAL_CTRL_STS);
-		buf |= SPECIAL_CTRL_STS_OVRRD_AMDIX_;
-		buf &= ~(SPECIAL_CTRL_STS_AMDIX_ENABLE_ |
-			 SPECIAL_CTRL_STS_AMDIX_STATE_);
-		phy_write(pdata->phydev,
-				    SPECIAL_CTRL_STS, buf);
+		phy_modify(pdata->phydev, SPECIAL_CTRL_STS,
+			   SPECIAL_CTRL_STS_AMDIX_ENABLE_ |
+			   SPECIAL_CTRL_STS_AMDIX_STATE_,
+			   SPECIAL_CTRL_STS_OVRRD_AMDIX_);
 	} else if (mdix_ctrl == ETH_TP_MDI_X) {
-		buf = phy_read(pdata->phydev,
-					 SPECIAL_CTRL_STS);
-		buf |= SPECIAL_CTRL_STS_OVRRD_AMDIX_;
-		buf &= ~(SPECIAL_CTRL_STS_AMDIX_ENABLE_ |
-			 SPECIAL_CTRL_STS_AMDIX_STATE_);
-		buf |= SPECIAL_CTRL_STS_AMDIX_STATE_;
-		phy_write(pdata->phydev,
-				    SPECIAL_CTRL_STS, buf);
+		phy_modify(pdata->phydev, SPECIAL_CTRL_STS,
+			   SPECIAL_CTRL_STS_AMDIX_ENABLE_ |
+			   SPECIAL_CTRL_STS_AMDIX_STATE_,
+			   SPECIAL_CTRL_STS_OVRRD_AMDIX_ |
+			   SPECIAL_CTRL_STS_AMDIX_STATE_);
 	} else if (mdix_ctrl == ETH_TP_MDI_AUTO) {
-		buf = phy_read(pdata->phydev,
-					 SPECIAL_CTRL_STS);
-		buf &= ~SPECIAL_CTRL_STS_OVRRD_AMDIX_;
-		buf &= ~(SPECIAL_CTRL_STS_AMDIX_ENABLE_ |
-			 SPECIAL_CTRL_STS_AMDIX_STATE_);
-		buf |= SPECIAL_CTRL_STS_AMDIX_ENABLE_;
-		phy_write(pdata->phydev,
-				    SPECIAL_CTRL_STS, buf);
+		phy_modify(pdata->phydev, SPECIAL_CTRL_STS,
+			   SPECIAL_CTRL_STS_OVRRD_AMDIX_ |
+			   SPECIAL_CTRL_STS_AMDIX_ENABLE_ |
+			   SPECIAL_CTRL_STS_AMDIX_STATE_,
+			   SPECIAL_CTRL_STS_AMDIX_ENABLE_);
 	}
+
 	pdata->mdix_ctrl = mdix_ctrl;
 }
 
@@ -951,7 +939,7 @@ static int smsc95xx_phy_initialize(struct usbnet *dev)
 	}
 
 	phy_write(pdata->phydev, PHY_INT_MASK,
-		PHY_INT_MASK_DEFAULT_);
+		  PHY_INT_MASK_DEFAULT_);
 
 	ret = genphy_restart_aneg(pdata->phydev);
 	if (ret)
@@ -1372,15 +1360,7 @@ static int smsc95xx_enable_phy_wakeup_interrupts(struct usbnet *dev, u16 mask)
 		return ret;
 
 	/* enable interrupt source */
-	ret = phy_read(pdata->phydev, PHY_INT_MASK);
-	if (ret < 0)
-		return ret;
-
-	ret |= mask;
-
-	phy_write(pdata->phydev, PHY_INT_MASK, ret);
-
-	return 0;
+	return phy_set_bits(pdata->phydev, PHY_INT_MASK, mask);
 }
 
 static int smsc95xx_link_ok_nopm(struct usbnet *dev)
@@ -1445,17 +1425,14 @@ static int smsc95xx_enter_suspend1(struct usbnet *dev)
 	 */
 	if (pdata->features & FEATURE_PHY_NLP_CROSSOVER)
 		phy_write(pdata->phydev, PHY_EDPD_CONFIG,
-				    PHY_EDPD_CONFIG_DEFAULT);
+			  PHY_EDPD_CONFIG_DEFAULT);
 
 	/* enable energy detect power-down mode */
-	ret = phy_read(pdata->phydev, PHY_MODE_CTRL_STS);
+	ret = phy_set_bits(pdata->phydev, PHY_MODE_CTRL_STS,
+			   MODE_CTRL_STS_EDPWRDOWN_);
 	if (ret < 0)
 		return ret;
 
-	ret |= MODE_CTRL_STS_EDPWRDOWN_;
-
-	phy_write(pdata->phydev, PHY_MODE_CTRL_STS, ret);
-
 	/* enter SUSPEND1 mode */
 	ret = smsc95xx_read_reg(dev, PM_CTRL, &val);
 	if (ret < 0)
-- 
2.19.2

Powered by blists - more mailing lists