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 <[email protected]>
Reviewed-by: Marek Vasut <[email protected]>

Reply via email to