[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1599726112-4439-7-git-send-email-chunfeng.yun@mediatek.com>
Date: Thu, 10 Sep 2020 16:21:48 +0800
From: Chunfeng Yun <chunfeng.yun@...iatek.com>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
CC: Mathias Nyman <mathias.nyman@...el.com>,
Felipe Balbi <balbi@...nel.org>,
Matthias Brugger <matthias.bgg@...il.com>,
Douglas Anderson <dianders@...omium.org>,
Chunfeng Yun <chunfeng.yun@...iatek.com>,
Daniel Thompson <daniel.thompson@...aro.org>,
"Eric W. Biederman" <ebiederm@...ssion.com>,
Lee Jones <lee.jones@...aro.org>,
Sumit Garg <sumit.garg@...aro.org>,
Jann Horn <jannh@...gle.com>, Arnd Bergmann <arnd@...db.de>,
Jason Yan <yanaijie@...wei.com>,
Chuhong Yuan <hslester96@...il.com>,
"Gustavo A. R. Silva" <gustavoars@...nel.org>,
Ben Dooks <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>
Subject: [PATCH RESEND v3 07/11] usb: isp1760-hcd: convert to readl_poll_timeout_atomic()
Use readl_poll_timeout_atomic() to simplify code
Signed-off-by: Chunfeng Yun <chunfeng.yun@...iatek.com>
---
v2~v3: no changes
---
drivers/usb/isp1760/isp1760-hcd.c | 20 +++++++++-----------
1 file changed, 9 insertions(+), 11 deletions(-)
diff --git a/drivers/usb/isp1760/isp1760-hcd.c b/drivers/usb/isp1760/isp1760-hcd.c
index dd74ab7a..33ae656 100644
--- a/drivers/usb/isp1760/isp1760-hcd.c
+++ b/drivers/usb/isp1760/isp1760-hcd.c
@@ -22,6 +22,7 @@
#include <linux/debugfs.h>
#include <linux/uaccess.h>
#include <linux/io.h>
+#include <linux/iopoll.h>
#include <linux/mm.h>
#include <linux/timer.h>
#include <asm/unaligned.h>
@@ -380,18 +381,15 @@ static int handshake(struct usb_hcd *hcd, u32 reg,
u32 mask, u32 done, int usec)
{
u32 result;
+ int ret;
+
+ ret = readl_poll_timeout_atomic(hcd->regs + reg, result,
+ ((result & mask) == done ||
+ result == U32_MAX), 1, usec);
+ if (result == U32_MAX)
+ return -ENODEV;
- do {
- result = reg_read32(hcd->regs, reg);
- if (result == ~0)
- return -ENODEV;
- result &= mask;
- if (result == done)
- return 0;
- udelay(1);
- usec--;
- } while (usec > 0);
- return -ETIMEDOUT;
+ return ret;
}
/* reset a non-running (STS_HALT == 1) controller */
--
1.9.1
Powered by blists - more mailing lists