diff mbox series

[11/15] usb: serial: ipaq: use usb_control_msg_send()

Message ID 20201104064703.15123-12-himadrispandya@gmail.com
State New
Headers show
Series usb: serial: avoid using usb_control_msg() directly | expand

Commit Message

Himadri Pandya Nov. 4, 2020, 6:46 a.m. UTC
The new usb_control_msg_send() nicely wraps usb_control_msg() with proper
error check. Hence use the wrapper instead of calling usb_control_msg()
directly.

Signed-off-by: Himadri Pandya <himadrispandya@gmail.com>
---
 drivers/usb/serial/ipaq.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

Comments

Johan Hovold Dec. 4, 2020, 10:21 a.m. UTC | #1
On Wed, Nov 04, 2020 at 12:16:59PM +0530, Himadri Pandya wrote:
> The new usb_control_msg_send() nicely wraps usb_control_msg() with proper

> error check. Hence use the wrapper instead of calling usb_control_msg()

> directly.

> 

> Signed-off-by: Himadri Pandya <himadrispandya@gmail.com>

> ---

>  drivers/usb/serial/ipaq.c | 9 ++++-----

>  1 file changed, 4 insertions(+), 5 deletions(-)

> 

> diff --git a/drivers/usb/serial/ipaq.c b/drivers/usb/serial/ipaq.c

> index f81746c3c26c..99505a76035d 100644

> --- a/drivers/usb/serial/ipaq.c

> +++ b/drivers/usb/serial/ipaq.c

> @@ -530,15 +530,14 @@ static int ipaq_open(struct tty_struct *tty,

>  	 */

>  	while (retries) {

>  		retries--;

> -		result = usb_control_msg(serial->dev,

> -				usb_sndctrlpipe(serial->dev, 0), 0x22, 0x21,

> -				0x1, 0, NULL, 0, 100);

> -		if (!result)

> +		result = usb_control_msg_send(serial->dev, 0, 0x22, 0x21, 0x1,

> +					      0, NULL, 0, 100, GFP_KERNEL);

> +		if (result == 0)

>  			break;


There's not point in using the new helper since there's no data stage
and usb_control_msg already returns negative errno or 0.

>  		msleep(1000);

>  	}

> -	if (!retries && result) {

> +	if (result) {

>  		dev_err(&port->dev, "%s - failed doing control urb, error %d\n",

>  							__func__, result);

>  		return result;


This looks like just an unrelated simplification of the logic; there was
never any need to check !retries here. You can send that as a clean up
patch of its own if you want.

Johan
diff mbox series

Patch

diff --git a/drivers/usb/serial/ipaq.c b/drivers/usb/serial/ipaq.c
index f81746c3c26c..99505a76035d 100644
--- a/drivers/usb/serial/ipaq.c
+++ b/drivers/usb/serial/ipaq.c
@@ -530,15 +530,14 @@  static int ipaq_open(struct tty_struct *tty,
 	 */
 	while (retries) {
 		retries--;
-		result = usb_control_msg(serial->dev,
-				usb_sndctrlpipe(serial->dev, 0), 0x22, 0x21,
-				0x1, 0, NULL, 0, 100);
-		if (!result)
+		result = usb_control_msg_send(serial->dev, 0, 0x22, 0x21, 0x1,
+					      0, NULL, 0, 100, GFP_KERNEL);
+		if (result == 0)
 			break;
 
 		msleep(1000);
 	}
-	if (!retries && result) {
+	if (result) {
 		dev_err(&port->dev, "%s - failed doing control urb, error %d\n",
 							__func__, result);
 		return result;