[PATCH v3 4/4] usb: Convert ad-hoc poll/timeout sequences in usb.c to iopoll
Marek Vasut
marek.vasut at mailbox.org
Mon Mar 2 13:59:50 CET 2026
On 3/2/26 5:45 AM, Ronan Dalton wrote:
[...]
> @@ -276,19 +279,22 @@ int usb_control_msg(struct usb_device *dev, unsigned int pipe,
> int usb_bulk_msg(struct usb_device *dev, unsigned int pipe,
> void *data, int len, int *actual_length, int timeout)
> {
> + volatile unsigned long usb_status;
> +
> if (len < 0)
> return -EINVAL;
>
> + if (timeout < 0)
> + return -EINVAL;
> +
> dev->status = USB_ST_NOT_PROC; /*not yet processed */
>
> if (submit_bulk_msg(dev, pipe, data, len) < 0)
> return -EIO;
>
> - while (timeout--) {
> - if (!((volatile unsigned long)dev->status & USB_ST_NOT_PROC))
> - break;
> - mdelay(1);
> - }
> + read_poll_timeout((volatile unsigned long), usb_status,
> + !(usb_status & USB_ST_NOT_PROC), 1000,
> + timeout * 1000UL, dev->status);
Maybe this could use an error check here too ?
With that fixed:
Reviewed-by: Marek Vasut <marek.vasut at mailbox.org>
More information about the U-Boot
mailing list