[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <1594351856-876-1-git-send-email-chunfeng.yun@mediatek.com>
Date: Fri, 10 Jul 2020 11:30:56 +0800
From: Chunfeng Yun <chunfeng.yun@...iatek.com>
To: Felipe Balbi <balbi@...nel.org>
CC: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Matthias Brugger <matthias.bgg@...il.com>,
YueHaibing <yuehaibing@...wei.com>,
Stephen Boyd <swboyd@...omium.org>,
Chunfeng Yun <chunfeng.yun@...iatek.com>,
<linux-usb@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<linux-arm-kernel@...ts.infradead.org>,
<linux-mediatek@...ts.infradead.org>
Subject: [PATCH] usb: gadget: bdc: use readl_poll_timeout() to simplify code
Use readl_poll_timeout() to poll register status
Signed-off-by: Chunfeng Yun <chunfeng.yun@...iatek.com>
---
drivers/usb/gadget/udc/bdc/bdc_core.c | 22 ++++++++--------------
1 file changed, 8 insertions(+), 14 deletions(-)
diff --git a/drivers/usb/gadget/udc/bdc/bdc_core.c b/drivers/usb/gadget/udc/bdc/bdc_core.c
index 02a3a77..fa173de 100644
--- a/drivers/usb/gadget/udc/bdc/bdc_core.c
+++ b/drivers/usb/gadget/udc/bdc/bdc_core.c
@@ -12,6 +12,7 @@
#include <linux/spinlock.h>
#include <linux/platform_device.h>
#include <linux/interrupt.h>
+#include <linux/iopoll.h>
#include <linux/ioport.h>
#include <linux/io.h>
#include <linux/list.h>
@@ -32,21 +33,14 @@
static int poll_oip(struct bdc *bdc, int usec)
{
u32 status;
- /* Poll till STS!= OIP */
- while (usec) {
- status = bdc_readl(bdc->regs, BDC_BDCSC);
- if (BDC_CSTS(status) != BDC_OIP) {
- dev_dbg(bdc->dev,
- "poll_oip complete status=%d",
- BDC_CSTS(status));
- return 0;
- }
- udelay(10);
- usec -= 10;
- }
- dev_err(bdc->dev, "Err: operation timedout BDCSC: 0x%08x\n", status);
+ int ret;
- return -ETIMEDOUT;
+ ret = readl_poll_timeout(bdc->regs + BDC_BDCSC, status,
+ (BDC_CSTS(status) != BDC_OIP), 10, usec);
+ if (ret)
+ dev_err(bdc->dev, "Err: operation timedout BDCSC: 0x%08x\n", status);
+
+ return ret;
}
/* Stop the BDC controller */
--
1.9.1
Powered by blists - more mailing lists