[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1600668815-12135-9-git-send-email-chunfeng.yun@mediatek.com>
Date: Mon, 21 Sep 2020 14:13:33 +0800
From: Chunfeng Yun <chunfeng.yun@...iatek.com>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Felipe Balbi <balbi@...nel.org>
CC: Mathias Nyman <mathias.nyman@...el.com>,
Matthias Brugger <matthias.bgg@...il.com>,
Chunfeng Yun <chunfeng.yun@...iatek.com>,
"Eric W. Biederman" <ebiederm@...ssion.com>,
Sumit Garg <sumit.garg@...aro.org>,
Lee Jones <lee.jones@...aro.org>, Jann Horn <jannh@...gle.com>,
Jason Yan <yanaijie@...wei.com>, Arnd Bergmann <arnd@...db.de>,
Chuhong Yuan <hslester96@...il.com>,
"Gustavo A. R. Silva" <gustavoars@...nel.org>,
"Ben Dooks (Codethink)" <ben.dooks@...ethink.co.uk>,
Saurav Girepunje <saurav.girepunje@...il.com>,
<linux-usb@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<linux-arm-kernel@...ts.infradead.org>,
<linux-mediatek@...ts.infradead.org>,
Sergei Shtylyov <sergei.shtylyov@...entembedded.com>,
Daniel Thompson <daniel.thompson@...aro.org>
Subject: [PATCH v4 09/11] usb: phy: phy-mv-usb: convert to readl_poll_timeout_atomic()
Use readl_poll_timeout_atomic() to simplify code
Signed-off-by: Chunfeng Yun <chunfeng.yun@...iatek.com>
---
v4: no changes
v3: re-align argument of log suggested by Sergei
v2: udelay 10us instead of 20us according to kerneldoc
---
drivers/usb/phy/phy-mv-usb.c | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)
diff --git a/drivers/usb/phy/phy-mv-usb.c b/drivers/usb/phy/phy-mv-usb.c
index ce767ec..576d925 100644
--- a/drivers/usb/phy/phy-mv-usb.c
+++ b/drivers/usb/phy/phy-mv-usb.c
@@ -8,6 +8,7 @@
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/io.h>
+#include <linux/iopoll.h>
#include <linux/uaccess.h>
#include <linux/device.h>
#include <linux/proc_fs.h>
@@ -135,8 +136,8 @@ static int mv_otg_set_timer(struct mv_otg *mvotg, unsigned int id,
static int mv_otg_reset(struct mv_otg *mvotg)
{
- unsigned int loops;
u32 tmp;
+ int ret;
/* Stop the controller */
tmp = readl(&mvotg->op_regs->usbcmd);
@@ -146,15 +147,12 @@ static int mv_otg_reset(struct mv_otg *mvotg)
/* Reset the controller to get default values */
writel(USBCMD_CTRL_RESET, &mvotg->op_regs->usbcmd);
- loops = 500;
- while (readl(&mvotg->op_regs->usbcmd) & USBCMD_CTRL_RESET) {
- if (loops == 0) {
- dev_err(&mvotg->pdev->dev,
- "Wait for RESET completed TIMEOUT\n");
- return -ETIMEDOUT;
- }
- loops--;
- udelay(20);
+ ret = readl_poll_timeout_atomic(&mvotg->op_regs->usbcmd, tmp,
+ (tmp & USBCMD_CTRL_RESET), 10, 10000);
+ if (ret < 0) {
+ dev_err(&mvotg->pdev->dev,
+ "Wait for RESET completed TIMEOUT\n");
+ return ret;
}
writel(0x0, &mvotg->op_regs->usbintr);
--
1.9.1
Powered by blists - more mailing lists