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>
This commit is contained in:
Chunfeng Yun 2020-09-21 14:13:34 +08:00 committed by Greg Kroah-Hartman
parent f158afecff
commit 805ca9c2c2
1 changed files with 10 additions and 11 deletions

View File

@ -52,6 +52,7 @@
#include <linux/usb/gadget.h> #include <linux/usb/gadget.h>
#include <linux/prefetch.h> #include <linux/prefetch.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/iopoll.h>
#include <asm/byteorder.h> #include <asm/byteorder.h>
#include <asm/irq.h> #include <asm/irq.h>
@ -360,18 +361,16 @@ net2280_enable(struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
static int handshake(u32 __iomem *ptr, u32 mask, u32 done, int usec) static int handshake(u32 __iomem *ptr, u32 mask, u32 done, int usec)
{ {
u32 result; u32 result;
int ret;
do { ret = readl_poll_timeout_atomic(ptr, result,
result = readl(ptr); ((result & mask) == done ||
if (result == ~(u32)0) /* "device unplugged" */ result == U32_MAX),
return -ENODEV; 1, usec);
result &= mask; if (result == U32_MAX) /* device unplugged */
if (result == done) return -ENODEV;
return 0;
udelay(1); return ret;
usec--;
} while (usec > 0);
return -ETIMEDOUT;
} }
static const struct usb_ep_ops net2280_ep_ops; static const struct usb_ep_ops net2280_ep_ops;