linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/14] USB: serial: Fix coccinelle warnings
@ 2016-01-30 17:44 Mathieu OTHACEHE
  2016-01-30 17:44 ` [PATCH 01/14] USB: serial: safe_serial: fix assignment of bool to 0/1 Mathieu OTHACEHE
                   ` (14 more replies)
  0 siblings, 15 replies; 20+ messages in thread
From: Mathieu OTHACEHE @ 2016-01-30 17:44 UTC (permalink / raw)
  To: johan, gregkh; +Cc: linux-kernel, linux-usb, Mathieu OTHACEHE

This series of patches fixes all coccinelle warnings in
USB serial subsystem

Mathieu OTHACEHE (14):
  USB: serial: safe_serial: fix assignment of bool to 0/1
  USB: serial: safe_serial: fix assignment of bool to non 0/1 constant
  USB: serial: quatech2: remove comparison to bool
  USB: serial: iuu_phoenix: remove comparison of bool
  USB: serial: mos7840: remove comparison to bool
  USB: serial: garmin_gps: move constants to right
  USB: serial: ftdi_sio: move constants to right
  USB: serial: keyspan: remove unused semicolon
  USB: serial: cyberjack: remove unneeded variable
  USB: serial: garmin_gps: remove unneeded variable
  USB: serial: mos7840: move constants to right
  USB: serial: ch341: move constants to right
  USB: serial: f81232: move constants to right
  USB: serial: kl5kusb105: remove unneeded semicolons

 drivers/usb/serial/ch341.c       |  2 +-
 drivers/usb/serial/cyberjack.c   |  3 +--
 drivers/usb/serial/f81232.c      |  2 +-
 drivers/usb/serial/ftdi_sio.c    | 16 ++++++-------
 drivers/usb/serial/ftdi_sio.h    |  8 +++----
 drivers/usb/serial/garmin_gps.c  | 51 ++++++++++++++++++++--------------------
 drivers/usb/serial/iuu_phoenix.c |  4 ++--
 drivers/usb/serial/keyspan.c     |  2 +-
 drivers/usb/serial/kl5kusb105.c  |  3 ---
 drivers/usb/serial/mos7840.c     |  8 +++----
 drivers/usb/serial/quatech2.c    |  2 +-
 drivers/usb/serial/safe_serial.c | 11 +++------
 12 files changed, 51 insertions(+), 61 deletions(-)

-- 
2.6.4

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH 01/14] USB: serial: safe_serial: fix assignment of bool to 0/1
  2016-01-30 17:44 [PATCH 00/14] USB: serial: Fix coccinelle warnings Mathieu OTHACEHE
@ 2016-01-30 17:44 ` Mathieu OTHACEHE
  2016-01-30 17:44 ` [PATCH 02/14] USB: serial: safe_serial: fix assignment of bool to non 0/1 constant Mathieu OTHACEHE
                   ` (13 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Mathieu OTHACEHE @ 2016-01-30 17:44 UTC (permalink / raw)
  To: johan, gregkh; +Cc: linux-kernel, linux-usb, Mathieu OTHACEHE

This patch fixes the following coccinelle warnings:

drivers/usb/serial/safe_serial.c:84:12-16: WARNING: Assignment of bool to 0/1
drivers/usb/serial/safe_serial.c:281:2-8: WARNING: Assignment of bool to 0/1

Signed-off-by: Mathieu OTHACEHE <m.othacehe@gmail.com>
---
 drivers/usb/serial/safe_serial.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/serial/safe_serial.c b/drivers/usb/serial/safe_serial.c
index b2dff0f..5662df6 100644
--- a/drivers/usb/serial/safe_serial.c
+++ b/drivers/usb/serial/safe_serial.c
@@ -81,7 +81,7 @@
 #define CONFIG_USB_SERIAL_SAFE_PADDED 0
 #endif
 
-static bool safe = 1;
+static bool safe = true;
 static bool padded = CONFIG_USB_SERIAL_SAFE_PADDED;
 
 #define DRIVER_AUTHOR "sl@lineo.com, tbr@lineo.com, Johan Hovold <jhovold@gmail.com>"
@@ -278,7 +278,7 @@ static int safe_startup(struct usb_serial *serial)
 	case LINEO_SAFESERIAL_CRC:
 		break;
 	case LINEO_SAFESERIAL_CRC_PADDED:
-		padded = 1;
+		padded = true;
 		break;
 	default:
 		return -EINVAL;
-- 
2.6.4

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 02/14] USB: serial: safe_serial: fix assignment of bool to non 0/1 constant
  2016-01-30 17:44 [PATCH 00/14] USB: serial: Fix coccinelle warnings Mathieu OTHACEHE
  2016-01-30 17:44 ` [PATCH 01/14] USB: serial: safe_serial: fix assignment of bool to 0/1 Mathieu OTHACEHE
@ 2016-01-30 17:44 ` Mathieu OTHACEHE
  2016-01-30 17:44 ` [PATCH 03/14] USB: serial: quatech2: remove comparison to bool Mathieu OTHACEHE
                   ` (12 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Mathieu OTHACEHE @ 2016-01-30 17:44 UTC (permalink / raw)
  To: johan, gregkh; +Cc: linux-kernel, linux-usb, Mathieu OTHACEHE

This patch fixes the following coccinelle error:

drivers/usb/serial/safe_serial.c:85:12-18: ERROR: Assignment of bool to non-0/1 constant

Signed-off-by: Mathieu OTHACEHE <m.othacehe@gmail.com>
---
 drivers/usb/serial/safe_serial.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/usb/serial/safe_serial.c b/drivers/usb/serial/safe_serial.c
index 5662df6..93c6c9b 100644
--- a/drivers/usb/serial/safe_serial.c
+++ b/drivers/usb/serial/safe_serial.c
@@ -76,13 +76,8 @@
 #include <linux/usb.h>
 #include <linux/usb/serial.h>
 
-
-#ifndef CONFIG_USB_SERIAL_SAFE_PADDED
-#define CONFIG_USB_SERIAL_SAFE_PADDED 0
-#endif
-
 static bool safe = true;
-static bool padded = CONFIG_USB_SERIAL_SAFE_PADDED;
+static bool padded = IS_ENABLED(CONFIG_USB_SERIAL_SAFE_PADDED);
 
 #define DRIVER_AUTHOR "sl@lineo.com, tbr@lineo.com, Johan Hovold <jhovold@gmail.com>"
 #define DRIVER_DESC "USB Safe Encapsulated Serial"
-- 
2.6.4

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 03/14] USB: serial: quatech2: remove comparison to bool
  2016-01-30 17:44 [PATCH 00/14] USB: serial: Fix coccinelle warnings Mathieu OTHACEHE
  2016-01-30 17:44 ` [PATCH 01/14] USB: serial: safe_serial: fix assignment of bool to 0/1 Mathieu OTHACEHE
  2016-01-30 17:44 ` [PATCH 02/14] USB: serial: safe_serial: fix assignment of bool to non 0/1 constant Mathieu OTHACEHE
@ 2016-01-30 17:44 ` Mathieu OTHACEHE
  2016-01-30 17:44 ` [PATCH 04/14] USB: serial: iuu_phoenix: remove comparison of bool Mathieu OTHACEHE
                   ` (11 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Mathieu OTHACEHE @ 2016-01-30 17:44 UTC (permalink / raw)
  To: johan, gregkh; +Cc: linux-kernel, linux-usb, Mathieu OTHACEHE

This patch fixes the following coccinelle warning:

drivers/usb/serial/quatech2.c:976:5-26: WARNING: Comparison to bool

Signed-off-by: Mathieu OTHACEHE <m.othacehe@gmail.com>
---
 drivers/usb/serial/quatech2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/serial/quatech2.c b/drivers/usb/serial/quatech2.c
index 504f5bf..2df8ad5 100644
--- a/drivers/usb/serial/quatech2.c
+++ b/drivers/usb/serial/quatech2.c
@@ -973,7 +973,7 @@ static int qt2_write(struct tty_struct *tty,
 
 	data = write_urb->transfer_buffer;
 	spin_lock_irqsave(&port_priv->urb_lock, flags);
-	if (port_priv->urb_in_use == true) {
+	if (port_priv->urb_in_use) {
 		dev_err(&port->dev, "qt2_write - urb is in use\n");
 		goto write_out;
 	}
-- 
2.6.4

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 04/14] USB: serial: iuu_phoenix: remove comparison of bool
  2016-01-30 17:44 [PATCH 00/14] USB: serial: Fix coccinelle warnings Mathieu OTHACEHE
                   ` (2 preceding siblings ...)
  2016-01-30 17:44 ` [PATCH 03/14] USB: serial: quatech2: remove comparison to bool Mathieu OTHACEHE
@ 2016-01-30 17:44 ` Mathieu OTHACEHE
  2016-01-30 17:44 ` [PATCH 05/14] USB: serial: mos7840: remove comparison to bool Mathieu OTHACEHE
                   ` (10 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Mathieu OTHACEHE @ 2016-01-30 17:44 UTC (permalink / raw)
  To: johan, gregkh; +Cc: linux-kernel, linux-usb, Mathieu OTHACEHE

This patch fixes the following coccinelle warning:

drivers/usb/serial/iuu_phoenix.c:383:5-9: WARNING: Comparison of bool to 0/1
drivers/usb/serial/iuu_phoenix.c:363:5-9: WARNING: Comparison of bool to 0/1

Signed-off-by: Mathieu OTHACEHE <m.othacehe@gmail.com>
---
 drivers/usb/serial/iuu_phoenix.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/serial/iuu_phoenix.c b/drivers/usb/serial/iuu_phoenix.c
index 5ad4a0f..344b4ee 100644
--- a/drivers/usb/serial/iuu_phoenix.c
+++ b/drivers/usb/serial/iuu_phoenix.c
@@ -360,7 +360,7 @@ static void iuu_led_activity_on(struct urb *urb)
 	int result;
 	char *buf_ptr = port->write_urb->transfer_buffer;
 	*buf_ptr++ = IUU_SET_LED;
-	if (xmas == 1) {
+	if (xmas) {
 		get_random_bytes(buf_ptr, 6);
 		*(buf_ptr+7) = 1;
 	} else {
@@ -380,7 +380,7 @@ static void iuu_led_activity_off(struct urb *urb)
 	struct usb_serial_port *port = urb->context;
 	int result;
 	char *buf_ptr = port->write_urb->transfer_buffer;
-	if (xmas == 1) {
+	if (xmas) {
 		iuu_rxcmd(urb);
 		return;
 	} else {
-- 
2.6.4

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 05/14] USB: serial: mos7840: remove comparison to bool
  2016-01-30 17:44 [PATCH 00/14] USB: serial: Fix coccinelle warnings Mathieu OTHACEHE
                   ` (3 preceding siblings ...)
  2016-01-30 17:44 ` [PATCH 04/14] USB: serial: iuu_phoenix: remove comparison of bool Mathieu OTHACEHE
@ 2016-01-30 17:44 ` Mathieu OTHACEHE
  2016-01-30 17:44 ` [PATCH 06/14] USB: serial: garmin_gps: move constants to right Mathieu OTHACEHE
                   ` (9 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Mathieu OTHACEHE @ 2016-01-30 17:44 UTC (permalink / raw)
  To: johan, gregkh; +Cc: linux-kernel, linux-usb, Mathieu OTHACEHE

This patch fixes the following coccinelle warning:

drivers/usb/serial/mos7840.c:1845:5-32: WARNING: Comparison to bool
drivers/usb/serial/mos7840.c:1909:5-32: WARNING: Comparison to bool

Signed-off-by: Mathieu OTHACEHE <m.othacehe@gmail.com>
---
 drivers/usb/serial/mos7840.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
index 2c69bfc..8ddc313 100644
--- a/drivers/usb/serial/mos7840.c
+++ b/drivers/usb/serial/mos7840.c
@@ -1842,7 +1842,7 @@ static void mos7840_change_port_settings(struct tty_struct *tty,
 	Data = 0x0c;
 	mos7840_set_uart_reg(port, INTERRUPT_ENABLE_REGISTER, Data);
 
-	if (mos7840_port->read_urb_busy == false) {
+	if (!mos7840_port->read_urb_busy) {
 		mos7840_port->read_urb_busy = true;
 		status = usb_submit_urb(mos7840_port->read_urb, GFP_KERNEL);
 		if (status) {
@@ -1906,7 +1906,7 @@ static void mos7840_set_termios(struct tty_struct *tty,
 		return;
 	}
 
-	if (mos7840_port->read_urb_busy == false) {
+	if (!mos7840_port->read_urb_busy) {
 		mos7840_port->read_urb_busy = true;
 		status = usb_submit_urb(mos7840_port->read_urb, GFP_KERNEL);
 		if (status) {
-- 
2.6.4

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 06/14] USB: serial: garmin_gps: move constants to right
  2016-01-30 17:44 [PATCH 00/14] USB: serial: Fix coccinelle warnings Mathieu OTHACEHE
                   ` (4 preceding siblings ...)
  2016-01-30 17:44 ` [PATCH 05/14] USB: serial: mos7840: remove comparison to bool Mathieu OTHACEHE
@ 2016-01-30 17:44 ` Mathieu OTHACEHE
  2016-01-30 17:44 ` [PATCH 07/14] USB: serial: ftdi_sio: " Mathieu OTHACEHE
                   ` (8 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Mathieu OTHACEHE @ 2016-01-30 17:44 UTC (permalink / raw)
  To: johan, gregkh; +Cc: linux-kernel, linux-usb, Mathieu OTHACEHE

This patch fixes the following coccinelle warning:

drivers/usb/serial/garmin_gps.c:1195:3-4: Move constant to right.
drivers/usb/serial/garmin_gps.c:1206:6-7: Move constant to right.
drivers/usb/serial/garmin_gps.c:1252:5-6: Move constant to right.
drivers/usb/serial/garmin_gps.c:1257:6-7: Move constant to right.
drivers/usb/serial/garmin_gps.c:1279:7-8: Move constant to right.
drivers/usb/serial/garmin_gps.c:1359:5-6: Move constant to right.
drivers/usb/serial/garmin_gps.c:1081:9-31: Move constant to right.
drivers/usb/serial/garmin_gps.c:1028:5-24: Move constant to right.
drivers/usb/serial/garmin_gps.c:973:6-25: Move constant to right.
drivers/usb/serial/garmin_gps.c:426:6-10: Move constant to right.
drivers/usb/serial/garmin_gps.c:428:13-17: Move constant to right.
drivers/usb/serial/garmin_gps.c:428:28-32: Move constant to right.
drivers/usb/serial/garmin_gps.c:531:6-10: Move constant to right.
drivers/usb/serial/garmin_gps.c:639:5-24: Move constant to right.
drivers/usb/serial/garmin_gps.c:691:9-13: Move constant to right.
drivers/usb/serial/garmin_gps.c:353:2-6: Move constant to right.
drivers/usb/serial/garmin_gps.c:369:10-14: Move constant to right.
drivers/usb/serial/garmin_gps.c:240:5-6: Move constant to right.
drivers/usb/serial/garmin_gps.c:242:5-6: Move constant to right.

Signed-off-by: Mathieu OTHACEHE <m.othacehe@gmail.com>
---
 drivers/usb/serial/garmin_gps.c | 48 ++++++++++++++++++++---------------------
 1 file changed, 24 insertions(+), 24 deletions(-)

diff --git a/drivers/usb/serial/garmin_gps.c b/drivers/usb/serial/garmin_gps.c
index db591d1..c0bbe44 100644
--- a/drivers/usb/serial/garmin_gps.c
+++ b/drivers/usb/serial/garmin_gps.c
@@ -237,10 +237,10 @@ static inline int getDataLength(const __u8 *usbPacket)
  */
 static inline int isAbortTrfCmnd(const unsigned char *buf)
 {
-	if (0 == memcmp(buf, GARMIN_STOP_TRANSFER_REQ,
-					sizeof(GARMIN_STOP_TRANSFER_REQ)) ||
-	    0 == memcmp(buf, GARMIN_STOP_TRANSFER_REQ_V2,
-					sizeof(GARMIN_STOP_TRANSFER_REQ_V2)))
+	if (memcmp(buf, GARMIN_STOP_TRANSFER_REQ,
+			sizeof(GARMIN_STOP_TRANSFER_REQ)) == 0 ||
+	    memcmp(buf, GARMIN_STOP_TRANSFER_REQ_V2,
+			sizeof(GARMIN_STOP_TRANSFER_REQ_V2)) == 0)
 		return 1;
 	else
 		return 0;
@@ -350,7 +350,7 @@ static int gsp_send_ack(struct garmin_data *garmin_data_p, __u8 pkt_id)
 	unsigned  l = 0;
 
 	dev_dbg(&garmin_data_p->port->dev, "%s - pkt-id: 0x%X.\n", __func__,
-		0xFF & pkt_id);
+			pkt_id & 0xFF);
 
 	*ptr++ = DLE;
 	*ptr++ = ACK;
@@ -366,7 +366,7 @@ static int gsp_send_ack(struct garmin_data *garmin_data_p, __u8 pkt_id)
 		*ptr++ = DLE;
 
 	*ptr++ = 0;
-	*ptr++ = 0xFF & (-cksum);
+	*ptr++ = (-cksum) & 0xFF;
 	*ptr++ = DLE;
 	*ptr++ = ETX;
 
@@ -423,9 +423,9 @@ static int gsp_rec_packet(struct garmin_data *garmin_data_p, int count)
 		n++;
 	}
 
-	if ((0xff & (cksum + *recpkt)) != 0) {
+	if (((cksum + *recpkt) & 0xff) != 0) {
 		dev_dbg(dev, "%s - invalid checksum, expected %02x, got %02x\n",
-			__func__, 0xff & -cksum, 0xff & *recpkt);
+			__func__, -cksum & 0xff, *recpkt & 0xff);
 		return -EINVPKT;
 	}
 
@@ -528,7 +528,7 @@ static int gsp_receive(struct garmin_data *garmin_data_p,
 					dev_dbg(dev, "NAK packet complete.\n");
 				} else {
 					dev_dbg(dev, "packet complete - id=0x%X.\n",
-						0xFF & data);
+							data & 0xFF);
 					gsp_rec_packet(garmin_data_p, size);
 				}
 
@@ -636,7 +636,7 @@ static int gsp_send(struct garmin_data *garmin_data_p,
 
 	garmin_data_p->outsize = 0;
 
-	if (GARMIN_LAYERID_APPL != getLayerId(garmin_data_p->outbuffer)) {
+	if (getLayerId(garmin_data_p->outbuffer) != GARMIN_LAYERID_APPL) {
 		dev_dbg(dev, "not an application packet (%d)\n",
 				getLayerId(garmin_data_p->outbuffer));
 		return -1;
@@ -688,7 +688,7 @@ static int gsp_send(struct garmin_data *garmin_data_p,
 			*dst++ = DLE;
 	}
 
-	cksum = 0xFF & -cksum;
+	cksum = -cksum & 0xFF;
 	*dst++ = cksum;
 	if (cksum == DLE)
 		*dst++ = DLE;
@@ -970,7 +970,7 @@ static void garmin_write_bulk_callback(struct urb *urb)
 		struct garmin_data *garmin_data_p =
 					usb_get_serial_port_data(port);
 
-		if (GARMIN_LAYERID_APPL == getLayerId(urb->transfer_buffer)) {
+		if (getLayerId(urb->transfer_buffer) == GARMIN_LAYERID_APPL) {
 
 			if (garmin_data_p->mode == MODE_GARMIN_SERIAL) {
 				gsp_send_ack(garmin_data_p,
@@ -1025,7 +1025,7 @@ static int garmin_write_bulk(struct usb_serial_port *port,
 				dismiss_ack ? NULL : port);
 	urb->transfer_flags |= URB_ZERO_PACKET;
 
-	if (GARMIN_LAYERID_APPL == getLayerId(buffer)) {
+	if (getLayerId(buffer) == GARMIN_LAYERID_APPL) {
 
 		spin_lock_irqsave(&garmin_data_p->lock, flags);
 		garmin_data_p->flags |= APP_REQ_SEEN;
@@ -1077,9 +1077,9 @@ static int garmin_write(struct tty_struct *tty, struct usb_serial_port *port,
 		pktsiz = getDataLength(garmin_data_p->privpkt);
 		pktid  = getPacketId(garmin_data_p->privpkt);
 
-		if (count == (GARMIN_PKTHDR_LENGTH+pktsiz)
-		    && GARMIN_LAYERID_PRIVATE ==
-				getLayerId(garmin_data_p->privpkt)) {
+		if ((GARMIN_PKTHDR_LENGTH+pktsiz) == count &&
+			getLayerId(garmin_data_p->privpkt) ==
+				GARMIN_LAYERID_PRIVATE) {
 
 			dev_dbg(dev, "%s - processing private request %d\n",
 				__func__, pktid);
@@ -1192,7 +1192,7 @@ static void garmin_read_bulk_callback(struct urb *urb)
 	garmin_read_process(garmin_data_p, data, urb->actual_length, 1);
 
 	if (urb->actual_length == 0 &&
-			0 != (garmin_data_p->flags & FLAGS_BULK_IN_RESTART)) {
+			(garmin_data_p->flags & FLAGS_BULK_IN_RESTART) != 0) {
 		spin_lock_irqsave(&garmin_data_p->lock, flags);
 		garmin_data_p->flags &= ~FLAGS_BULK_IN_RESTART;
 		spin_unlock_irqrestore(&garmin_data_p->lock, flags);
@@ -1203,7 +1203,7 @@ static void garmin_read_bulk_callback(struct urb *urb)
 				__func__, retval);
 	} else if (urb->actual_length > 0) {
 		/* Continue trying to read until nothing more is received  */
-		if (0 == (garmin_data_p->flags & FLAGS_THROTTLED)) {
+		if ((garmin_data_p->flags & FLAGS_THROTTLED) == 0) {
 			retval = usb_submit_urb(port->read_urb, GFP_ATOMIC);
 			if (retval)
 				dev_err(&port->dev,
@@ -1249,12 +1249,12 @@ static void garmin_read_int_callback(struct urb *urb)
 			      urb->transfer_buffer);
 
 	if (urb->actual_length == sizeof(GARMIN_BULK_IN_AVAIL_REPLY) &&
-	    0 == memcmp(data, GARMIN_BULK_IN_AVAIL_REPLY,
-				sizeof(GARMIN_BULK_IN_AVAIL_REPLY))) {
+		memcmp(data, GARMIN_BULK_IN_AVAIL_REPLY,
+				sizeof(GARMIN_BULK_IN_AVAIL_REPLY)) == 0) {
 
 		dev_dbg(&port->dev, "%s - bulk data available.\n", __func__);
 
-		if (0 == (garmin_data_p->flags & FLAGS_BULK_IN_ACTIVE)) {
+		if ((garmin_data_p->flags & FLAGS_BULK_IN_ACTIVE) == 0) {
 
 			/* bulk data available */
 			retval = usb_submit_urb(port->read_urb, GFP_ATOMIC);
@@ -1276,8 +1276,8 @@ static void garmin_read_int_callback(struct urb *urb)
 		}
 
 	} else if (urb->actual_length == (4+sizeof(GARMIN_START_SESSION_REPLY))
-			 && 0 == memcmp(data, GARMIN_START_SESSION_REPLY,
-					sizeof(GARMIN_START_SESSION_REPLY))) {
+			 && memcmp(data, GARMIN_START_SESSION_REPLY,
+				 sizeof(GARMIN_START_SESSION_REPLY)) == 0) {
 
 		spin_lock_irqsave(&garmin_data_p->lock, flags);
 		garmin_data_p->flags |= FLAGS_SESSION_REPLY1_SEEN;
@@ -1356,7 +1356,7 @@ static void garmin_unthrottle(struct tty_struct *tty)
 	if (garmin_data_p->mode == MODE_NATIVE)
 		garmin_flush_queue(garmin_data_p);
 
-	if (0 != (garmin_data_p->flags & FLAGS_BULK_IN_ACTIVE)) {
+	if ((garmin_data_p->flags & FLAGS_BULK_IN_ACTIVE) != 0) {
 		status = usb_submit_urb(port->read_urb, GFP_KERNEL);
 		if (status)
 			dev_err(&port->dev,
-- 
2.6.4

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 07/14] USB: serial: ftdi_sio: move constants to right
  2016-01-30 17:44 [PATCH 00/14] USB: serial: Fix coccinelle warnings Mathieu OTHACEHE
                   ` (5 preceding siblings ...)
  2016-01-30 17:44 ` [PATCH 06/14] USB: serial: garmin_gps: move constants to right Mathieu OTHACEHE
@ 2016-01-30 17:44 ` Mathieu OTHACEHE
  2016-01-30 17:44 ` [PATCH 08/14] USB: serial: keyspan: remove unused semicolon Mathieu OTHACEHE
                   ` (7 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Mathieu OTHACEHE @ 2016-01-30 17:44 UTC (permalink / raw)
  To: johan, gregkh; +Cc: linux-kernel, linux-usb, Mathieu OTHACEHE

This patch fixes the following coccinelle warnings:

drivers/usb/serial/ftdi_sio.h:242:31-32: Move constant to right.
drivers/usb/serial/ftdi_sio.h:243:31-32: Move constant to right.
drivers/usb/serial/ftdi_sio.h:245:31-32: Move constant to right.
drivers/usb/serial/ftdi_sio.h:246:30-31: Move constant to right.
drivers/usb/serial/ftdi_sio.c:2327:13-32: Move constant to right.
drivers/usb/serial/ftdi_sio.c:2356:22-42: Move constant to right.
drivers/usb/serial/ftdi_sio.c:1322:9-25: Move constant to right.
drivers/usb/serial/ftdi_sio.c:1323:9-33: Move constant to right.
drivers/usb/serial/ftdi_sio.c:1324:9-30: Move constant to right.
drivers/usb/serial/ftdi_sio.c:1325:9-30: Move constant to right.
drivers/usb/serial/ftdi_sio.c:1326:9-32: Move constant to right.

Signed-off-by: Mathieu OTHACEHE <m.othacehe@gmail.com>
---
 drivers/usb/serial/ftdi_sio.c | 16 ++++++++--------
 drivers/usb/serial/ftdi_sio.h |  8 ++++----
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 8c660ae..07b0040 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -1320,11 +1320,11 @@ static __u32 get_ftdi_divisor(struct tty_struct *tty,
 		if (baud <= 3000000) {
 			__u16 product_id = le16_to_cpu(
 				port->serial->dev->descriptor.idProduct);
-			if (((FTDI_NDI_HUC_PID == product_id) ||
-			     (FTDI_NDI_SPECTRA_SCU_PID == product_id) ||
-			     (FTDI_NDI_FUTURE_2_PID == product_id) ||
-			     (FTDI_NDI_FUTURE_3_PID == product_id) ||
-			     (FTDI_NDI_AURORA_SCU_PID == product_id)) &&
+			if (((product_id == FTDI_NDI_HUC_PID)		||
+			     (product_id == FTDI_NDI_SPECTRA_SCU_PID)	||
+			     (product_id == FTDI_NDI_FUTURE_2_PID)	||
+			     (product_id == FTDI_NDI_FUTURE_3_PID)	||
+			     (product_id == FTDI_NDI_AURORA_SCU_PID))	&&
 			    (baud == 19200)) {
 				baud = 1200000;
 			}
@@ -2325,7 +2325,7 @@ no_c_cflag_changes:
 				    usb_sndctrlpipe(dev, 0),
 				    FTDI_SIO_SET_FLOW_CTRL_REQUEST,
 				    FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE,
-				    0 , (FTDI_SIO_RTS_CTS_HS | priv->interface),
+				    0, (priv->interface | FTDI_SIO_RTS_CTS_HS),
 				    NULL, 0, WDR_TIMEOUT) < 0) {
 			dev_err(ddev, "urb failed to set to rts/cts flow control\n");
 		}
@@ -2354,8 +2354,8 @@ no_c_cflag_changes:
 					    usb_sndctrlpipe(dev, 0),
 					    FTDI_SIO_SET_FLOW_CTRL_REQUEST,
 					    FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE,
-					    urb_value , (FTDI_SIO_XON_XOFF_HS
-							 | priv->interface),
+					    urb_value, (priv->interface |
+						    FTDI_SIO_XON_XOFF_HS),
 					    NULL, 0, WDR_TIMEOUT) < 0) {
 				dev_err(&port->dev, "urb failed to set to "
 					"xon/xoff flow control\n");
diff --git a/drivers/usb/serial/ftdi_sio.h b/drivers/usb/serial/ftdi_sio.h
index ed58c6f..bbcc13df 100644
--- a/drivers/usb/serial/ftdi_sio.h
+++ b/drivers/usb/serial/ftdi_sio.h
@@ -239,11 +239,11 @@ enum ftdi_sio_baudrate {
  */
 
 #define FTDI_SIO_SET_DTR_MASK 0x1
-#define FTDI_SIO_SET_DTR_HIGH (1 | (FTDI_SIO_SET_DTR_MASK  << 8))
-#define FTDI_SIO_SET_DTR_LOW  (0 | (FTDI_SIO_SET_DTR_MASK  << 8))
+#define FTDI_SIO_SET_DTR_HIGH ((FTDI_SIO_SET_DTR_MASK  << 8) | 1)
+#define FTDI_SIO_SET_DTR_LOW  ((FTDI_SIO_SET_DTR_MASK  << 8) | 0)
 #define FTDI_SIO_SET_RTS_MASK 0x2
-#define FTDI_SIO_SET_RTS_HIGH (2 | (FTDI_SIO_SET_RTS_MASK << 8))
-#define FTDI_SIO_SET_RTS_LOW (0 | (FTDI_SIO_SET_RTS_MASK << 8))
+#define FTDI_SIO_SET_RTS_HIGH ((FTDI_SIO_SET_RTS_MASK << 8) | 2)
+#define FTDI_SIO_SET_RTS_LOW  ((FTDI_SIO_SET_RTS_MASK << 8) | 0)
 
 /*
  * ControlValue
-- 
2.6.4

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 08/14] USB: serial: keyspan: remove unused semicolon
  2016-01-30 17:44 [PATCH 00/14] USB: serial: Fix coccinelle warnings Mathieu OTHACEHE
                   ` (6 preceding siblings ...)
  2016-01-30 17:44 ` [PATCH 07/14] USB: serial: ftdi_sio: " Mathieu OTHACEHE
@ 2016-01-30 17:44 ` Mathieu OTHACEHE
  2016-01-30 17:44 ` [PATCH 09/14] USB: serial: cyberjack: remove unneeded variable Mathieu OTHACEHE
                   ` (6 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Mathieu OTHACEHE @ 2016-01-30 17:44 UTC (permalink / raw)
  To: johan, gregkh; +Cc: linux-kernel, linux-usb, Mathieu OTHACEHE

This patch fixes the following coccinelle warning:

drivers/usb/serial/keyspan.c:1966:49-50: Unneeded semicolon

Signed-off-by: Mathieu OTHACEHE <m.othacehe@gmail.com>
---
 drivers/usb/serial/keyspan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c
index e07b15e..b6bd8e4 100644
--- a/drivers/usb/serial/keyspan.c
+++ b/drivers/usb/serial/keyspan.c
@@ -1963,7 +1963,7 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial,
 	if (d_details->product_id == keyspan_usa49wg_product_id) {
 		dr = (void *)(s_priv->ctrl_buf);
 		dr->bRequestType = USB_TYPE_VENDOR | USB_DIR_OUT;
-		dr->bRequest = 0xB0;	/* 49wg control message */;
+		dr->bRequest = 0xB0;	/* 49wg control message */
 		dr->wValue = 0;
 		dr->wIndex = 0;
 		dr->wLength = cpu_to_le16(sizeof(msg));
-- 
2.6.4

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 09/14] USB: serial: cyberjack: remove unneeded variable
  2016-01-30 17:44 [PATCH 00/14] USB: serial: Fix coccinelle warnings Mathieu OTHACEHE
                   ` (7 preceding siblings ...)
  2016-01-30 17:44 ` [PATCH 08/14] USB: serial: keyspan: remove unused semicolon Mathieu OTHACEHE
@ 2016-01-30 17:44 ` Mathieu OTHACEHE
  2016-01-30 17:44 ` [PATCH 10/14] USB: serial: garmin_gps: " Mathieu OTHACEHE
                   ` (5 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Mathieu OTHACEHE @ 2016-01-30 17:44 UTC (permalink / raw)
  To: johan, gregkh; +Cc: linux-kernel, linux-usb, Mathieu OTHACEHE

This patch fixes the following coccinelle warning:

drivers/usb/serial/cyberjack.c:143:5-11: Unneeded variable:
"result". Return "0" on line 155

Signed-off-by: Mathieu OTHACEHE <m.othacehe@gmail.com>
---
 drivers/usb/serial/cyberjack.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/usb/serial/cyberjack.c b/drivers/usb/serial/cyberjack.c
index 2916dea..5f17a3b 100644
--- a/drivers/usb/serial/cyberjack.c
+++ b/drivers/usb/serial/cyberjack.c
@@ -140,7 +140,6 @@ static int  cyberjack_open(struct tty_struct *tty,
 {
 	struct cyberjack_private *priv;
 	unsigned long flags;
-	int result = 0;
 
 	dev_dbg(&port->dev, "%s - usb_clear_halt\n", __func__);
 	usb_clear_halt(port->serial->dev, port->write_urb->pipe);
@@ -152,7 +151,7 @@ static int  cyberjack_open(struct tty_struct *tty,
 	priv->wrsent = 0;
 	spin_unlock_irqrestore(&priv->lock, flags);
 
-	return result;
+	return 0;
 }
 
 static void cyberjack_close(struct usb_serial_port *port)
-- 
2.6.4

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 10/14] USB: serial: garmin_gps: remove unneeded variable
  2016-01-30 17:44 [PATCH 00/14] USB: serial: Fix coccinelle warnings Mathieu OTHACEHE
                   ` (8 preceding siblings ...)
  2016-01-30 17:44 ` [PATCH 09/14] USB: serial: cyberjack: remove unneeded variable Mathieu OTHACEHE
@ 2016-01-30 17:44 ` Mathieu OTHACEHE
  2016-01-30 17:44 ` [PATCH 11/14] USB: serial: mos7840: move constants to right Mathieu OTHACEHE
                   ` (4 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Mathieu OTHACEHE @ 2016-01-30 17:44 UTC (permalink / raw)
  To: johan, gregkh; +Cc: linux-kernel, linux-usb, Mathieu OTHACEHE

This patch fixes the following coccinelle warning:

drivers/usb/serial/garmin_gps.c:863:5-11: Unneeded variable:
"status". Return "0" on line 873

Signed-off-by: Mathieu OTHACEHE <m.othacehe@gmail.com>
---
 drivers/usb/serial/garmin_gps.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/usb/serial/garmin_gps.c b/drivers/usb/serial/garmin_gps.c
index c0bbe44..91a9b55 100644
--- a/drivers/usb/serial/garmin_gps.c
+++ b/drivers/usb/serial/garmin_gps.c
@@ -860,7 +860,6 @@ static int process_resetdev_request(struct usb_serial_port *port)
 static int garmin_clear(struct garmin_data *garmin_data_p)
 {
 	unsigned long flags;
-	int status = 0;
 
 	/* flush all queued data */
 	pkt_clear(garmin_data_p);
@@ -870,7 +869,7 @@ static int garmin_clear(struct garmin_data *garmin_data_p)
 	garmin_data_p->outsize = 0;
 	spin_unlock_irqrestore(&garmin_data_p->lock, flags);
 
-	return status;
+	return 0;
 }
 
 
-- 
2.6.4

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 11/14] USB: serial: mos7840: move constants to right
  2016-01-30 17:44 [PATCH 00/14] USB: serial: Fix coccinelle warnings Mathieu OTHACEHE
                   ` (9 preceding siblings ...)
  2016-01-30 17:44 ` [PATCH 10/14] USB: serial: garmin_gps: " Mathieu OTHACEHE
@ 2016-01-30 17:44 ` Mathieu OTHACEHE
  2016-01-31 21:33   ` Bjørn Mork
  2016-01-30 17:44 ` [PATCH 12/14] USB: serial: ch341: " Mathieu OTHACEHE
                   ` (3 subsequent siblings)
  14 siblings, 1 reply; 20+ messages in thread
From: Mathieu OTHACEHE @ 2016-01-30 17:44 UTC (permalink / raw)
  To: johan, gregkh; +Cc: linux-kernel, linux-usb, Mathieu OTHACEHE

This patch fixes the following coccinelle warnings:

drivers/usb/serial/mos7840.c:2042:4-10: Move constant to right.
drivers/usb/serial/mos7840.c:2062:16-22: Move constant to right.

Signed-off-by: Mathieu OTHACEHE <m.othacehe@gmail.com>
---
 drivers/usb/serial/mos7840.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
index 8ddc313..982a3fb 100644
--- a/drivers/usb/serial/mos7840.c
+++ b/drivers/usb/serial/mos7840.c
@@ -2039,7 +2039,7 @@ static int mos7810_check(struct usb_serial *serial)
 		/* Send the 1-bit test pattern out to MCS7810 test pin */
 		usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
 			MCS_WRREQ, MCS_WR_RTYPE,
-			(0x0300 | (((test_pattern >> i) & 0x0001) << 1)),
+			((((test_pattern >> i) & 0x0001) << 1) | 0x0300),
 			MODEM_CONTROL_REGISTER, NULL, 0, MOS_WDR_TIMEOUT);
 
 		/* Read the test pattern back */
@@ -2059,7 +2059,7 @@ static int mos7810_check(struct usb_serial *serial)
 
 	/* Restore MCR setting */
 	usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), MCS_WRREQ,
-		MCS_WR_RTYPE, 0x0300 | mcr_data, MODEM_CONTROL_REGISTER, NULL,
+		MCS_WR_RTYPE, mcr_data | 0x0300, MODEM_CONTROL_REGISTER, NULL,
 		0, MOS_WDR_TIMEOUT);
 
 	kfree(buf);
-- 
2.6.4

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 12/14] USB: serial: ch341: move constants to right
  2016-01-30 17:44 [PATCH 00/14] USB: serial: Fix coccinelle warnings Mathieu OTHACEHE
                   ` (10 preceding siblings ...)
  2016-01-30 17:44 ` [PATCH 11/14] USB: serial: mos7840: move constants to right Mathieu OTHACEHE
@ 2016-01-30 17:44 ` Mathieu OTHACEHE
  2016-01-30 17:44 ` [PATCH 13/14] USB: serial: f81232: " Mathieu OTHACEHE
                   ` (2 subsequent siblings)
  14 siblings, 0 replies; 20+ messages in thread
From: Mathieu OTHACEHE @ 2016-01-30 17:44 UTC (permalink / raw)
  To: johan, gregkh; +Cc: linux-kernel, linux-usb, Mathieu OTHACEHE

This patch fixes the following coccinelle warning:

drivers/usb/serial/ch341.c:373:2-18: Move constant to right.

Signed-off-by: Mathieu OTHACEHE <m.othacehe@gmail.com>
---
 drivers/usb/serial/ch341.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/serial/ch341.c b/drivers/usb/serial/ch341.c
index c73808f..f139488 100644
--- a/drivers/usb/serial/ch341.c
+++ b/drivers/usb/serial/ch341.c
@@ -370,7 +370,7 @@ static void ch341_set_termios(struct tty_struct *tty,
 static void ch341_break_ctl(struct tty_struct *tty, int break_state)
 {
 	const uint16_t ch341_break_reg =
-		CH341_REG_BREAK1 | ((uint16_t) CH341_REG_BREAK2 << 8);
+			((uint16_t) CH341_REG_BREAK2 << 8) | CH341_REG_BREAK1;
 	struct usb_serial_port *port = tty->driver_data;
 	int r;
 	uint16_t reg_contents;
-- 
2.6.4

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 13/14] USB: serial: f81232: move constants to right
  2016-01-30 17:44 [PATCH 00/14] USB: serial: Fix coccinelle warnings Mathieu OTHACEHE
                   ` (11 preceding siblings ...)
  2016-01-30 17:44 ` [PATCH 12/14] USB: serial: ch341: " Mathieu OTHACEHE
@ 2016-01-30 17:44 ` Mathieu OTHACEHE
  2016-01-30 17:44 ` [PATCH 14/14] USB: serial: kl5kusb105: remove unneeded semicolons Mathieu OTHACEHE
  2016-01-31 20:10 ` [PATCH 00/14] USB: serial: Fix coccinelle warnings Johan Hovold
  14 siblings, 0 replies; 20+ messages in thread
From: Mathieu OTHACEHE @ 2016-01-30 17:44 UTC (permalink / raw)
  To: johan, gregkh; +Cc: linux-kernel, linux-usb, Mathieu OTHACEHE

This patch fixes the following coccinelle warning:

drivers/usb/serial/f81232.c:193:7-20: Move constant to right.

Signed-off-by: Mathieu OTHACEHE <m.othacehe@gmail.com>
---
 drivers/usb/serial/f81232.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/serial/f81232.c b/drivers/usb/serial/f81232.c
index 972f5a5..589d856 100644
--- a/drivers/usb/serial/f81232.c
+++ b/drivers/usb/serial/f81232.c
@@ -190,7 +190,7 @@ static int f81232_set_mctrl(struct usb_serial_port *port,
 
 	/* force enable interrupt with OUT2 */
 	mutex_lock(&priv->lock);
-	val = UART_MCR_OUT2 | priv->modem_control;
+	val = priv->modem_control | UART_MCR_OUT2;
 
 	if (clear & TIOCM_DTR)
 		val &= ~UART_MCR_DTR;
-- 
2.6.4

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 14/14] USB: serial: kl5kusb105: remove unneeded semicolons
  2016-01-30 17:44 [PATCH 00/14] USB: serial: Fix coccinelle warnings Mathieu OTHACEHE
                   ` (12 preceding siblings ...)
  2016-01-30 17:44 ` [PATCH 13/14] USB: serial: f81232: " Mathieu OTHACEHE
@ 2016-01-30 17:44 ` Mathieu OTHACEHE
  2016-01-31 20:10 ` [PATCH 00/14] USB: serial: Fix coccinelle warnings Johan Hovold
  14 siblings, 0 replies; 20+ messages in thread
From: Mathieu OTHACEHE @ 2016-01-30 17:44 UTC (permalink / raw)
  To: johan, gregkh; +Cc: linux-kernel, linux-usb, Mathieu OTHACEHE

This patch fixes the following coccinelle warnings:

drivers/usb/serial/kl5kusb105.c:475:2-3: Unneeded semicolon
drivers/usb/serial/kl5kusb105.c:530:2-3: Unneeded semicolon
drivers/usb/serial/kl5kusb105.c:549:2-3: Unneeded semicolon

Signed-off-by: Mathieu OTHACEHE <m.othacehe@gmail.com>
---
 drivers/usb/serial/kl5kusb105.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c
index e020ad2..fc5d3a7 100644
--- a/drivers/usb/serial/kl5kusb105.c
+++ b/drivers/usb/serial/kl5kusb105.c
@@ -472,7 +472,6 @@ static void klsi_105_set_termios(struct tty_struct *tty,
 		/* maybe this should be simulated by sending read
 		 * disable and read enable messages?
 		 */
-		;
 #if 0
 		priv->control_state &= ~(TIOCM_DTR | TIOCM_RTS);
 		mct_u232_set_modem_ctrl(serial, priv->control_state);
@@ -527,7 +526,6 @@ static void klsi_105_set_termios(struct tty_struct *tty,
 
 		mct_u232_set_line_ctrl(serial, priv->last_lcr);
 #endif
-		;
 	}
 	/*
 	 * Set flow control: well, I do not really now how to handle DTR/RTS.
@@ -546,7 +544,6 @@ static void klsi_105_set_termios(struct tty_struct *tty,
 			priv->control_state &= ~(TIOCM_DTR | TIOCM_RTS);
 		mct_u232_set_modem_ctrl(serial, priv->control_state);
 #endif
-		;
 	}
 	memcpy(cfg, &priv->cfg, sizeof(*cfg));
 	spin_unlock_irqrestore(&priv->lock, flags);
-- 
2.6.4

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: [PATCH 00/14] USB: serial: Fix coccinelle warnings
  2016-01-30 17:44 [PATCH 00/14] USB: serial: Fix coccinelle warnings Mathieu OTHACEHE
                   ` (13 preceding siblings ...)
  2016-01-30 17:44 ` [PATCH 14/14] USB: serial: kl5kusb105: remove unneeded semicolons Mathieu OTHACEHE
@ 2016-01-31 20:10 ` Johan Hovold
  14 siblings, 0 replies; 20+ messages in thread
From: Johan Hovold @ 2016-01-31 20:10 UTC (permalink / raw)
  To: Mathieu OTHACEHE; +Cc: johan, gregkh, linux-kernel, linux-usb

On Sat, Jan 30, 2016 at 06:44:33PM +0100, Mathieu OTHACEHE wrote:
> This series of patches fixes all coccinelle warnings in
> USB serial subsystem
> 
> Mathieu OTHACEHE (14):
>   USB: serial: safe_serial: fix assignment of bool to 0/1
>   USB: serial: safe_serial: fix assignment of bool to non 0/1 constant
>   USB: serial: quatech2: remove comparison to bool
>   USB: serial: iuu_phoenix: remove comparison of bool
>   USB: serial: mos7840: remove comparison to bool
>   USB: serial: garmin_gps: move constants to right
>   USB: serial: ftdi_sio: move constants to right
>   USB: serial: keyspan: remove unused semicolon
>   USB: serial: cyberjack: remove unneeded variable
>   USB: serial: garmin_gps: remove unneeded variable
>   USB: serial: mos7840: move constants to right
>   USB: serial: ch341: move constants to right
>   USB: serial: f81232: move constants to right
>   USB: serial: kl5kusb105: remove unneeded semicolons

Please squash these per type (or larger class) of issue you're fixing,
at least when the diffs aren't too big. No need to remove two semicolons
in two patches, etc.

Thanks,
Johan

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 11/14] USB: serial: mos7840: move constants to right
  2016-01-30 17:44 ` [PATCH 11/14] USB: serial: mos7840: move constants to right Mathieu OTHACEHE
@ 2016-01-31 21:33   ` Bjørn Mork
  2016-02-01 11:57     ` Mathieu OTHACEHE
  0 siblings, 1 reply; 20+ messages in thread
From: Bjørn Mork @ 2016-01-31 21:33 UTC (permalink / raw)
  To: Mathieu OTHACEHE; +Cc: johan, gregkh, linux-kernel, linux-usb

Mathieu OTHACEHE <m.othacehe@gmail.com> writes:

> This patch fixes the following coccinelle warnings:
>
> drivers/usb/serial/mos7840.c:2042:4-10: Move constant to right.
> drivers/usb/serial/mos7840.c:2062:16-22: Move constant to right.
>
> Signed-off-by: Mathieu OTHACEHE <m.othacehe@gmail.com>
> ---
>  drivers/usb/serial/mos7840.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
> index 8ddc313..982a3fb 100644
> --- a/drivers/usb/serial/mos7840.c
> +++ b/drivers/usb/serial/mos7840.c
> @@ -2039,7 +2039,7 @@ static int mos7810_check(struct usb_serial *serial)
>  		/* Send the 1-bit test pattern out to MCS7810 test pin */
>  		usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
>  			MCS_WRREQ, MCS_WR_RTYPE,
> -			(0x0300 | (((test_pattern >> i) & 0x0001) << 1)),
> +			((((test_pattern >> i) & 0x0001) << 1) | 0x0300),
>  			MODEM_CONTROL_REGISTER, NULL, 0, MOS_WDR_TIMEOUT);
>  
>  		/* Read the test pattern back */
> @@ -2059,7 +2059,7 @@ static int mos7810_check(struct usb_serial *serial)
>  
>  	/* Restore MCR setting */
>  	usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), MCS_WRREQ,
> -		MCS_WR_RTYPE, 0x0300 | mcr_data, MODEM_CONTROL_REGISTER, NULL,
> +		MCS_WR_RTYPE, mcr_data | 0x0300, MODEM_CONTROL_REGISTER, NULL,
>  		0, MOS_WDR_TIMEOUT);
>  
>  	kfree(buf);

I feel I'm missing something here, so I have to ask the stupid question:
What could possibly be the benefit here?  Is it faster? Safer?  Easier
to read?



Bjørn

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 11/14] USB: serial: mos7840: move constants to right
  2016-01-31 21:33   ` Bjørn Mork
@ 2016-02-01 11:57     ` Mathieu OTHACEHE
  2016-02-01 12:37       ` Bjørn Mork
  0 siblings, 1 reply; 20+ messages in thread
From: Mathieu OTHACEHE @ 2016-02-01 11:57 UTC (permalink / raw)
  To: Bjørn Mork; +Cc: johan, gregkh, linux-kernel, linux-usb

On Sun, Jan 31, 2016 at 10:33:54PM +0100, Bjørn Mork wrote:
> Mathieu OTHACEHE <m.othacehe@gmail.com> writes:
> 
> > This patch fixes the following coccinelle warnings:
> >
> > drivers/usb/serial/mos7840.c:2042:4-10: Move constant to right.
> > drivers/usb/serial/mos7840.c:2062:16-22: Move constant to right.
> >
> > Signed-off-by: Mathieu OTHACEHE <m.othacehe@gmail.com>
> > ---
> >  drivers/usb/serial/mos7840.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
> > index 8ddc313..982a3fb 100644
> > --- a/drivers/usb/serial/mos7840.c
> > +++ b/drivers/usb/serial/mos7840.c
> > @@ -2039,7 +2039,7 @@ static int mos7810_check(struct usb_serial *serial)
> >  		/* Send the 1-bit test pattern out to MCS7810 test pin */
> >  		usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
> >  			MCS_WRREQ, MCS_WR_RTYPE,
> > -			(0x0300 | (((test_pattern >> i) & 0x0001) << 1)),
> > +			((((test_pattern >> i) & 0x0001) << 1) | 0x0300),
> >  			MODEM_CONTROL_REGISTER, NULL, 0, MOS_WDR_TIMEOUT);
> >  
> >  		/* Read the test pattern back */
> > @@ -2059,7 +2059,7 @@ static int mos7810_check(struct usb_serial *serial)
> >  
> >  	/* Restore MCR setting */
> >  	usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), MCS_WRREQ,
> > -		MCS_WR_RTYPE, 0x0300 | mcr_data, MODEM_CONTROL_REGISTER, NULL,
> > +		MCS_WR_RTYPE, mcr_data | 0x0300, MODEM_CONTROL_REGISTER, NULL,
> >  		0, MOS_WDR_TIMEOUT);
> >  
> >  	kfree(buf);
> 
> I feel I'm missing something here, so I have to ask the stupid question:
> What could possibly be the benefit here?  Is it faster? Safer?  Easier
> to read?

I don't think it will be faster or safer, maybe easier to read. But the point is to remove the
warnings produced by the file scripts/coccinelle/misc/compare_const_fl.cocci when
running make coccicheck.

> 
> 
> 
> Bjørn

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 11/14] USB: serial: mos7840: move constants to right
  2016-02-01 11:57     ` Mathieu OTHACEHE
@ 2016-02-01 12:37       ` Bjørn Mork
  2016-02-28 12:46         ` Johan Hovold
  0 siblings, 1 reply; 20+ messages in thread
From: Bjørn Mork @ 2016-02-01 12:37 UTC (permalink / raw)
  To: Mathieu OTHACEHE; +Cc: johan, gregkh, linux-kernel, linux-usb

Mathieu OTHACEHE <m.othacehe@gmail.com> writes:
> On Sun, Jan 31, 2016 at 10:33:54PM +0100, Bjørn Mork wrote:
>
>> I feel I'm missing something here, so I have to ask the stupid question:
>> What could possibly be the benefit here?  Is it faster? Safer?  Easier
>> to read?
>
> I don't think it will be faster or safer, maybe easier to read. But the point is to remove the
> warnings produced by the file scripts/coccinelle/misc/compare_const_fl.cocci when
> running make coccicheck.

Making a tool happy is never going to be a valid reason for anything.
If it were, then you would not be necessary...

Luckily you still are. Your task is adding some intelligence to the
output of the script.  That means that you should look at the output and
describe how it improves the code in a way that makes me understand it.
And I can be pretty slow :)

If you can't do that, then there is a high probability that the script
didn't improve anything.


Bjørn

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 11/14] USB: serial: mos7840: move constants to right
  2016-02-01 12:37       ` Bjørn Mork
@ 2016-02-28 12:46         ` Johan Hovold
  0 siblings, 0 replies; 20+ messages in thread
From: Johan Hovold @ 2016-02-28 12:46 UTC (permalink / raw)
  To: Bjørn Mork; +Cc: Mathieu OTHACEHE, johan, gregkh, linux-kernel, linux-usb

On Mon, Feb 01, 2016 at 01:37:33PM +0100, Bjørn Mork wrote:
> Mathieu OTHACEHE <m.othacehe@gmail.com> writes:
> > On Sun, Jan 31, 2016 at 10:33:54PM +0100, Bjørn Mork wrote:
> >
> >> I feel I'm missing something here, so I have to ask the stupid question:
> >> What could possibly be the benefit here?  Is it faster? Safer?  Easier
> >> to read?
> >
> > I don't think it will be faster or safer, maybe easier to read. But the point is to remove the
> > warnings produced by the file scripts/coccinelle/misc/compare_const_fl.cocci when
> > running make coccicheck.
> 
> Making a tool happy is never going to be a valid reason for anything.
> If it were, then you would not be necessary...

Agreed.

> Luckily you still are. Your task is adding some intelligence to the
> output of the script.  That means that you should look at the output and
> describe how it improves the code in a way that makes me understand it.
> And I can be pretty slow :)
> 
> If you can't do that, then there is a high probability that the script
> didn't improve anything.

Looking through some of these (resent) chunks now, it's clear that some
arguable do not even improve readability.

I'll try to go through them and only pick the ones that do.

Thanks,
Johan

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2016-02-28 12:46 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-30 17:44 [PATCH 00/14] USB: serial: Fix coccinelle warnings Mathieu OTHACEHE
2016-01-30 17:44 ` [PATCH 01/14] USB: serial: safe_serial: fix assignment of bool to 0/1 Mathieu OTHACEHE
2016-01-30 17:44 ` [PATCH 02/14] USB: serial: safe_serial: fix assignment of bool to non 0/1 constant Mathieu OTHACEHE
2016-01-30 17:44 ` [PATCH 03/14] USB: serial: quatech2: remove comparison to bool Mathieu OTHACEHE
2016-01-30 17:44 ` [PATCH 04/14] USB: serial: iuu_phoenix: remove comparison of bool Mathieu OTHACEHE
2016-01-30 17:44 ` [PATCH 05/14] USB: serial: mos7840: remove comparison to bool Mathieu OTHACEHE
2016-01-30 17:44 ` [PATCH 06/14] USB: serial: garmin_gps: move constants to right Mathieu OTHACEHE
2016-01-30 17:44 ` [PATCH 07/14] USB: serial: ftdi_sio: " Mathieu OTHACEHE
2016-01-30 17:44 ` [PATCH 08/14] USB: serial: keyspan: remove unused semicolon Mathieu OTHACEHE
2016-01-30 17:44 ` [PATCH 09/14] USB: serial: cyberjack: remove unneeded variable Mathieu OTHACEHE
2016-01-30 17:44 ` [PATCH 10/14] USB: serial: garmin_gps: " Mathieu OTHACEHE
2016-01-30 17:44 ` [PATCH 11/14] USB: serial: mos7840: move constants to right Mathieu OTHACEHE
2016-01-31 21:33   ` Bjørn Mork
2016-02-01 11:57     ` Mathieu OTHACEHE
2016-02-01 12:37       ` Bjørn Mork
2016-02-28 12:46         ` Johan Hovold
2016-01-30 17:44 ` [PATCH 12/14] USB: serial: ch341: " Mathieu OTHACEHE
2016-01-30 17:44 ` [PATCH 13/14] USB: serial: f81232: " Mathieu OTHACEHE
2016-01-30 17:44 ` [PATCH 14/14] USB: serial: kl5kusb105: remove unneeded semicolons Mathieu OTHACEHE
2016-01-31 20:10 ` [PATCH 00/14] USB: serial: Fix coccinelle warnings Johan Hovold

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).