Re: Aw: [PATCH 11/11] usb: xhci: convet to readx_poll_sleep_timeout()

2020-08-16 Thread Chunfeng Yun
On Sun, 2020-08-16 at 09:56 +0200, Frank Wunderlich wrote:
> > Gesendet: Donnerstag, 13. August 2020 um 05:25 Uhr
> > Von: "Chunfeng Yun" 
> > Betreff: [PATCH 11/11] usb: xhci: convet to readx_poll_sleep_timeout()
> 
> just a small typo "convet"
Will fix it, thanks

> 
> maybe it can be fixed while applying?
> 
> regards Frank



Aw: [PATCH 11/11] usb: xhci: convet to readx_poll_sleep_timeout()

2020-08-16 Thread Frank Wunderlich
> Gesendet: Donnerstag, 13. August 2020 um 05:25 Uhr
> Von: "Chunfeng Yun" 
> Betreff: [PATCH 11/11] usb: xhci: convet to readx_poll_sleep_timeout()

just a small typo "convet"

maybe it can be fixed while applying?

regards Frank


[PATCH 11/11] usb: xhci: convet to readx_poll_sleep_timeout()

2020-08-12 Thread Chunfeng Yun
Use readx_poll_sleep_timeout() to poll the register status

Signed-off-by: Chunfeng Yun 
---
 drivers/usb/host/xhci.c | 25 +++--
 1 file changed, 11 insertions(+), 14 deletions(-)

diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index fe30101..3547a9b 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -33,6 +33,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #ifndef CONFIG_USB_MAX_CONTROLLER_COUNT
@@ -143,23 +144,19 @@ struct xhci_ctrl *xhci_get_ctrl(struct usb_device *udev)
  * @param usec time to wait till
  * @return 0 if handshake is success else < 0 on failure
  */
-static int handshake(uint32_t volatile *ptr, uint32_t mask,
-   uint32_t done, int usec)
+static int
+handshake(uint32_t volatile *ptr, uint32_t mask, uint32_t done, int usec)
 {
uint32_t result;
+   int ret;
+
+   ret = readx_poll_sleep_timeout(xhci_readl, ptr, result,
+(result & mask) == done || result == U32_MAX,
+1, usec);
+   if (result == U32_MAX)  /* card removed */
+   return -ENODEV;
 
-   do {
-   result = xhci_readl(ptr);
-   if (result == ~(uint32_t)0)
-   return -ENODEV;
-   result &= mask;
-   if (result == done)
-   return 0;
-   usec--;
-   udelay(1);
-   } while (usec > 0);
-
-   return -ETIMEDOUT;
+   return ret;
 }
 
 /**
-- 
1.9.1