[PATCH v4 4/4] usb: Convert ad-hoc poll/timeout sequences in usb.c to iopoll
Marek Vasut
marek.vasut at mailbox.org
Tue Mar 3 21:37:09 CET 2026
On 3/3/26 7:25 AM, Ronan Dalton wrote:
> The usb_control_msg and usb_bulk_msg functions in usb.c use a while loop
> and delay to wait for a USB control message to be processed. iopoll
> provides a macro to do this for us which can be used instead.
>
> Replace the while loops with calls to the read_poll_timeout macro. Also
> add a check for timeout being negative at the start of the functions and
> return -EINVAL in that case, since a negative timeout doesn't make
> sense.
>
> This also fixes a bug where usb_control_msg would check if timeout was
> equal to 0 to determine if a timeout occurred, when it should have been
> checking if it was -1 instead. This caused -1 to be returned by the
> function in most cases when a timeout occurred instead of the correct
> error code of -ETIMEDOUT.
>
> usb_bulk_msg now returns -ETIMEDOUT instead of -EIO on timeout.
>
> Signed-off-by: Ronan Dalton <ronan.dalton at alliedtelesis.co.nz>
Reviewed-by: Marek Vasut <marek.vasut at mailbox.org>
More information about the U-Boot
mailing list