diff mbox series

[2/3] USB: core: drop short-transfer check from usb_control_msg_send()

Message ID 20201204085110.20055-3-johan@kernel.org (mailing list archive)
State Accepted
Commit baf7df456b3848e4b6f8648e754e3a0f77fe700e
Headers show
Series USB: tweak the new control-message helpers | expand

Commit Message

Johan Hovold Dec. 4, 2020, 8:51 a.m. UTC
A failure to send a complete control message is always an error so
there's no need to check for short transfers in usb_control_msg_send().

Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/usb/core/message.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Comments

Greg Kroah-Hartman Dec. 4, 2020, 3:17 p.m. UTC | #1
On Fri, Dec 04, 2020 at 09:51:09AM +0100, Johan Hovold wrote:
> A failure to send a complete control message is always an error so
> there's no need to check for short transfers in usb_control_msg_send().
> 
> Signed-off-by: Johan Hovold <johan@kernel.org>
> ---
>  drivers/usb/core/message.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
> index a04b01247117..b08de9571f7a 100644
> --- a/drivers/usb/core/message.c
> +++ b/drivers/usb/core/message.c
> @@ -216,9 +216,8 @@ int usb_control_msg_send(struct usb_device *dev, __u8 endpoint, __u8 request,
>  
>  	if (ret < 0)
>  		return ret;
> -	if (ret == size)
> -		return 0;
> -	return -EINVAL;
> +
> +	return 0;

Ah, this came from the read call where a short read is not an error, but
we wanted it to be.  Nice catch.

greg k-h
diff mbox series

Patch

diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index a04b01247117..b08de9571f7a 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -216,9 +216,8 @@  int usb_control_msg_send(struct usb_device *dev, __u8 endpoint, __u8 request,
 
 	if (ret < 0)
 		return ret;
-	if (ret == size)
-		return 0;
-	return -EINVAL;
+
+	return 0;
 }
 EXPORT_SYMBOL_GPL(usb_control_msg_send);