linux-arm-msm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/6] phy: phy-bcm-ns-usb3: convert to readl_poll_timeout_atomic()
@ 2020-08-25  2:03 Chunfeng Yun
  2020-08-25  2:03 ` [PATCH 2/6] phy: phy-bcm-ns2-usbdrd: " Chunfeng Yun
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Chunfeng Yun @ 2020-08-25  2:03 UTC (permalink / raw)
  To: Kishon Vijay Abraham I
  Cc: Vinod Koul, Andy Gross, Bjorn Andersson, Matthias Brugger,
	Chunfeng Yun, Rikard Falkeborn, Bharat Gooty,
	Rayagonda Kokatanur, linux-kernel, linux-arm-msm,
	linux-arm-kernel, linux-mediatek

Use readl_poll_timeout_atomic() to simplify code

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
 drivers/phy/broadcom/phy-bcm-ns-usb3.c | 22 +++++++++-------------
 1 file changed, 9 insertions(+), 13 deletions(-)

diff --git a/drivers/phy/broadcom/phy-bcm-ns-usb3.c b/drivers/phy/broadcom/phy-bcm-ns-usb3.c
index 14f45bc..47b029f 100644
--- a/drivers/phy/broadcom/phy-bcm-ns-usb3.c
+++ b/drivers/phy/broadcom/phy-bcm-ns-usb3.c
@@ -13,6 +13,7 @@
 #include <linux/bcma/bcma.h>
 #include <linux/delay.h>
 #include <linux/err.h>
+#include <linux/iopoll.h>
 #include <linux/mdio.h>
 #include <linux/module.h>
 #include <linux/of_address.h>
@@ -258,29 +259,24 @@ static int bcm_ns_usb3_mdio_probe(struct mdio_device *mdiodev)
  **************************************************/
 
 static int bcm_ns_usb3_wait_reg(struct bcm_ns_usb3 *usb3, void __iomem *addr,
-				u32 mask, u32 value, unsigned long timeout)
+				u32 mask, u32 value, int usec)
 {
-	unsigned long deadline = jiffies + timeout;
 	u32 val;
+	int ret;
 
-	do {
-		val = readl(addr);
-		if ((val & mask) == value)
-			return 0;
-		cpu_relax();
-		udelay(10);
-	} while (!time_after_eq(jiffies, deadline));
+	ret = readl_poll_timeout_atomic(addr, val, ((val & mask) == value),
+					10, usec);
+	if (ret)
+		dev_err(usb3->dev, "Timeout waiting for register %p\n", addr);
 
-	dev_err(usb3->dev, "Timeout waiting for register %p\n", addr);
-
-	return -EBUSY;
+	return ret;
 }
 
 static inline int bcm_ns_usb3_mii_mng_wait_idle(struct bcm_ns_usb3 *usb3)
 {
 	return bcm_ns_usb3_wait_reg(usb3, usb3->ccb_mii + BCMA_CCB_MII_MNG_CTL,
 				    0x0100, 0x0000,
-				    usecs_to_jiffies(BCM_NS_USB3_MII_MNG_TIMEOUT_US));
+				    BCM_NS_USB3_MII_MNG_TIMEOUT_US);
 }
 
 static int bcm_ns_usb3_platform_phy_write(struct bcm_ns_usb3 *usb3, u16 reg,
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-09-08  4:26 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-25  2:03 [PATCH 1/6] phy: phy-bcm-ns-usb3: convert to readl_poll_timeout_atomic() Chunfeng Yun
2020-08-25  2:03 ` [PATCH 2/6] phy: phy-bcm-ns2-usbdrd: " Chunfeng Yun
2020-08-25  2:03 ` [PATCH 3/6] phy: phy-bcm-sr-usb: " Chunfeng Yun
2020-08-25  2:03 ` [PATCH 4/6] phy: phy-qcom-apq8064-sata: convert to readl_relaxed_poll_timeout() Chunfeng Yun
2020-08-25  2:03 ` [PATCH 5/6] phy: phy-pxa-28nm-hsic: convert to readl_poll_timeout() Chunfeng Yun
2020-08-25  2:03 ` [PATCH 6/6] phy: phy-pxa-28nm-usb2: " Chunfeng Yun
2020-09-08  4:26 ` [PATCH 1/6] phy: phy-bcm-ns-usb3: convert to readl_poll_timeout_atomic() Vinod Koul

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).