]> git.ipfire.org Git - people/ms/u-boot.git/commitdiff
usb: r8a66597: convert wait loop to readw_poll_timeout
authorChris Brandt <chris.brandt@renesas.com>
Wed, 29 Nov 2017 19:49:21 +0000 (14:49 -0500)
committerMarek Vasut <marex@denx.de>
Sat, 9 Dec 2017 12:39:27 +0000 (13:39 +0100)
It is better to use an existing wait loop implementation.

Signed-off-by: Chris Brandt <chris.brandt@renesas.com>
drivers/usb/host/r8a66597-hcd.c

index 28d2bc8454c5614ba3f295a83bb7021a8a1884a6..e0ca2cb0d4c50b9adc851ae2b35b65073f9924c0 100644 (file)
@@ -10,6 +10,7 @@
 #include <console.h>
 #include <usb.h>
 #include <asm/io.h>
+#include <linux/iopoll.h>
 
 #include "r8a66597.h"
 
@@ -297,7 +298,6 @@ static int send_setup_packet(struct r8a66597 *r8a66597, struct usb_device *dev,
        int timeout = 3000;
 #if defined(CONFIG_RZA_USB)
        u16 dcpctr;
-       int timeout2 = 10000;
 #endif
        u16 devsel = setup->request == USB_REQ_SET_ADDRESS ? 0 : dev->devnum;
 
@@ -308,13 +308,10 @@ static int send_setup_packet(struct r8a66597 *r8a66597, struct usb_device *dev,
 #if defined(CONFIG_RZA_USB)
        dcpctr = r8a66597_read(r8a66597, DCPCTR);
        if ((dcpctr & PID) == PID_BUF) {
-               timeout2 = 10000;
-               while (!(dcpctr & BSTS)) {
-                       dcpctr = r8a66597_read(r8a66597, DCPCTR);
-                       if (timeout2-- < 0) {
-                               printf("DCPCTR clear timeout!\n");
-                               break;
-                       }
+               if (readw_poll_timeout(r8a66597->reg + DCPCTR, dcpctr,
+                                      dcpctr & BSTS, 1000) < 0) {
+                       printf("DCPCTR BSTS timeout!\n");
+                       return -ETIMEDOUT;
                }
        }
 #endif