diff options
author | Chunfeng Yun <chunfeng.yun@mediatek.com> | 2020-07-13 09:48:01 +0300 |
---|---|---|
committer | Felipe Balbi <balbi@kernel.org> | 2020-07-24 16:45:12 +0300 |
commit | 75ae051efc9b3cceaed525e7ecb9cf19780e0af5 (patch) | |
tree | e2afff424c01e35b11a00b4bf4060ac32032efd9 /drivers/usb/gadget/udc/bdc | |
parent | 33a06f1300a79cfd461cea0268f05e969d4f34ec (diff) | |
download | linux-75ae051efc9b3cceaed525e7ecb9cf19780e0af5.tar.xz |
usb: gadget: bdc: use readl_poll_timeout() to simplify code
Use readl_poll_timeout() to poll register status
Cc: Florian Fainelli <f.fainelli@gmail.com>
Reviewed-by: Stephen Boyd <swboyd@chromium.org>
Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Felipe Balbi <balbi@kernel.org>
Diffstat (limited to 'drivers/usb/gadget/udc/bdc')
-rw-r--r-- | drivers/usb/gadget/udc/bdc/bdc_core.c | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/drivers/usb/gadget/udc/bdc/bdc_core.c b/drivers/usb/gadget/udc/bdc/bdc_core.c index 02a3a774670b..d567e20234f0 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> @@ -29,24 +30,19 @@ #include "bdc_dbg.h" /* Poll till controller status is not OIP */ -static int poll_oip(struct bdc *bdc, int usec) +static int poll_oip(struct bdc *bdc, u32 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, "operation timedout BDCSC: 0x%08x\n", status); + else + dev_dbg(bdc->dev, "%s complete status=%d", __func__, BDC_CSTS(status)); + + return ret; } /* Stop the BDC controller */ |