diff options
author | Chunfeng Yun | 2020-09-21 14:13:34 +0800 |
---|---|---|
committer | Greg Kroah-Hartman | 2020-09-25 16:30:06 +0200 |
commit | 805ca9c2c26479d9e3e01edb884961cd33bf265e (patch) | |
tree | a99c4527afa3bb77649efa51a9a4b8cc2cf1345f /drivers/usb/gadget/udc | |
parent | f158afecff1f8638744e7e0b90531cadae360244 (diff) |
usb: udc: net2280: convert to readl_poll_timeout_atomic()
Use readl_poll_timeout_atomic() to simplify code
Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: Felipe Balbi <balbi@kernel.org>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Link: https://lore.kernel.org/r/1600668815-12135-10-git-send-email-chunfeng.yun@mediatek.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/gadget/udc')
-rw-r--r-- | drivers/usb/gadget/udc/net2280.c | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c index 7530bd9a08c4..f1a21f4ff9a1 100644 --- a/drivers/usb/gadget/udc/net2280.c +++ b/drivers/usb/gadget/udc/net2280.c @@ -52,6 +52,7 @@ #include <linux/usb/gadget.h> #include <linux/prefetch.h> #include <linux/io.h> +#include <linux/iopoll.h> #include <asm/byteorder.h> #include <asm/irq.h> @@ -360,18 +361,16 @@ print_err: static int handshake(u32 __iomem *ptr, u32 mask, u32 done, int usec) { u32 result; + int ret; - do { - result = readl(ptr); - if (result == ~(u32)0) /* "device unplugged" */ - return -ENODEV; - result &= mask; - if (result == done) - return 0; - udelay(1); - usec--; - } while (usec > 0); - return -ETIMEDOUT; + ret = readl_poll_timeout_atomic(ptr, result, + ((result & mask) == done || + result == U32_MAX), + 1, usec); + if (result == U32_MAX) /* device unplugged */ + return -ENODEV; + + return ret; } static const struct usb_ep_ops net2280_ep_ops; |