[PATCH 02/15] usb: serial: belkin_sa: use usb_control_msg_send()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
 drivers/usb/serial/belkin_sa.c | 35 +++++++++++++++++-----------------
 1 file changed, 17 insertions(+), 18 deletions(-)

diff --git a/drivers/usb/serial/belkin_sa.c b/drivers/usb/serial/belkin_sa.c
index 9bb123ab9bc9..a5ff55f48303 100644
--- a/drivers/usb/serial/belkin_sa.c
+++ b/drivers/usb/serial/belkin_sa.c
@@ -105,9 +105,10 @@ struct belkin_sa_private {
 #define WDR_TIMEOUT 5000 /* default urb timeout */
 
 /* assumes that struct usb_serial *serial is available */
-#define BSA_USB_CMD(c, v) usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), \
-					    (c), BELKIN_SA_SET_REQUEST_TYPE, \
-					    (v), 0, NULL, 0, WDR_TIMEOUT)
+#define BSA_USB_CMD(c, v) usb_control_msg_send(serial->dev, 0, (c), \
+					       BELKIN_SA_SET_REQUEST_TYPE, \
+					       (v), 0, NULL, 0, WDR_TIMEOUT, \
+					       GFP_KERNEL)
 
 static int belkin_sa_port_probe(struct usb_serial_port *port)
 {
@@ -309,12 +310,11 @@ static void belkin_sa_set_termios(struct tty_struct *tty,
 		/* reassert DTR and (maybe) RTS on transition from B0 */
 		if ((old_cflag & CBAUD) == B0) {
 			control_state |= (TIOCM_DTR|TIOCM_RTS);
-			if (BSA_USB_CMD(BELKIN_SA_SET_DTR_REQUEST, 1) < 0)
+			if (BSA_USB_CMD(BELKIN_SA_SET_DTR_REQUEST, 1))
 				dev_err(&port->dev, "Set DTR error\n");
 			/* don't set RTS if using hardware flow control */
 			if (!(old_cflag & CRTSCTS))
-				if (BSA_USB_CMD(BELKIN_SA_SET_RTS_REQUEST
-								, 1) < 0)
+				if (BSA_USB_CMD(BELKIN_SA_SET_RTS_REQUEST, 1))
 					dev_err(&port->dev, "Set RTS error\n");
 		}
 	}
@@ -330,18 +330,18 @@ static void belkin_sa_set_termios(struct tty_struct *tty,
 
 		/* Report the actual baud rate back to the caller */
 		tty_encode_baud_rate(tty, baud, baud);
-		if (BSA_USB_CMD(BELKIN_SA_SET_BAUDRATE_REQUEST, urb_value) < 0)
+		if (BSA_USB_CMD(BELKIN_SA_SET_BAUDRATE_REQUEST, urb_value))
 			dev_err(&port->dev, "Set baudrate error\n");
 	} else {
 		/* Disable flow control */
 		if (BSA_USB_CMD(BELKIN_SA_SET_FLOW_CTRL_REQUEST,
-						BELKIN_SA_FLOW_NONE) < 0)
+				BELKIN_SA_FLOW_NONE))
 			dev_err(&port->dev, "Disable flowcontrol error\n");
 		/* Drop RTS and DTR */
 		control_state &= ~(TIOCM_DTR | TIOCM_RTS);
-		if (BSA_USB_CMD(BELKIN_SA_SET_DTR_REQUEST, 0) < 0)
+		if (BSA_USB_CMD(BELKIN_SA_SET_DTR_REQUEST, 0))
 			dev_err(&port->dev, "DTR LOW error\n");
-		if (BSA_USB_CMD(BELKIN_SA_SET_RTS_REQUEST, 0) < 0)
+		if (BSA_USB_CMD(BELKIN_SA_SET_RTS_REQUEST, 0))
 			dev_err(&port->dev, "RTS LOW error\n");
 	}
 
@@ -352,7 +352,7 @@ static void belkin_sa_set_termios(struct tty_struct *tty,
 						: BELKIN_SA_PARITY_EVEN;
 		else
 			urb_value = BELKIN_SA_PARITY_NONE;
-		if (BSA_USB_CMD(BELKIN_SA_SET_PARITY_REQUEST, urb_value) < 0)
+		if (BSA_USB_CMD(BELKIN_SA_SET_PARITY_REQUEST, urb_value))
 			dev_err(&port->dev, "Set parity error\n");
 	}
 
@@ -377,7 +377,7 @@ static void belkin_sa_set_termios(struct tty_struct *tty,
 			urb_value = BELKIN_SA_DATA_BITS(8);
 			break;
 		}
-		if (BSA_USB_CMD(BELKIN_SA_SET_DATA_BITS_REQUEST, urb_value) < 0)
+		if (BSA_USB_CMD(BELKIN_SA_SET_DATA_BITS_REQUEST, urb_value))
 			dev_err(&port->dev, "Set data bits error\n");
 	}
 
@@ -385,8 +385,7 @@ static void belkin_sa_set_termios(struct tty_struct *tty,
 	if ((cflag & CSTOPB) != (old_cflag & CSTOPB)) {
 		urb_value = (cflag & CSTOPB) ? BELKIN_SA_STOP_BITS(2)
 						: BELKIN_SA_STOP_BITS(1);
-		if (BSA_USB_CMD(BELKIN_SA_SET_STOP_BITS_REQUEST,
-							urb_value) < 0)
+		if (BSA_USB_CMD(BELKIN_SA_SET_STOP_BITS_REQUEST, urb_value))
 			dev_err(&port->dev, "Set stop bits error\n");
 	}
 
@@ -407,7 +406,7 @@ static void belkin_sa_set_termios(struct tty_struct *tty,
 		if (bad_flow_control)
 			urb_value &= ~(BELKIN_SA_FLOW_IRTS);
 
-		if (BSA_USB_CMD(BELKIN_SA_SET_FLOW_CTRL_REQUEST, urb_value) < 0)
+		if (BSA_USB_CMD(BELKIN_SA_SET_FLOW_CTRL_REQUEST, urb_value))
 			dev_err(&port->dev, "Set flow control error\n");
 	}
 
@@ -422,7 +421,7 @@ static void belkin_sa_break_ctl(struct tty_struct *tty, int break_state)
 	struct usb_serial_port *port = tty->driver_data;
 	struct usb_serial *serial = port->serial;
 
-	if (BSA_USB_CMD(BELKIN_SA_SET_BREAK_REQUEST, break_state ? 1 : 0) < 0)
+	if (BSA_USB_CMD(BELKIN_SA_SET_BREAK_REQUEST, break_state ? 1 : 0))
 		dev_err(&port->dev, "Set break_ctl %d\n", break_state);
 }
 
@@ -476,13 +475,13 @@ static int belkin_sa_tiocmset(struct tty_struct *tty,
 	spin_unlock_irqrestore(&priv->lock, flags);
 
 	retval = BSA_USB_CMD(BELKIN_SA_SET_RTS_REQUEST, rts);
-	if (retval < 0) {
+	if (retval) {
 		dev_err(&port->dev, "Set RTS error %d\n", retval);
 		goto exit;
 	}
 
 	retval = BSA_USB_CMD(BELKIN_SA_SET_DTR_REQUEST, dtr);
-	if (retval < 0) {
+	if (retval) {
 		dev_err(&port->dev, "Set DTR error %d\n", retval);
 		goto exit;
 	}
-- 
2.17.1




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux