Commit fb571101 authored by Mathieu OTHACEHE's avatar Mathieu OTHACEHE Committed by Johan Hovold

USB: serial: fix compare_const_fl.cocci warnings

Move constants to the right of binary operators where it increases
readability.

Generated by: scripts/coccinelle/misc/compare_const_fl.cocci
Signed-off-by: default avatarMathieu OTHACEHE <m.othacehe@gmail.com>
[johan: drop some chunks and fix others, amend commit message ]
Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
parent 81f70ba2
...@@ -370,7 +370,7 @@ static void ch341_set_termios(struct tty_struct *tty, ...@@ -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) static void ch341_break_ctl(struct tty_struct *tty, int break_state)
{ {
const uint16_t ch341_break_reg = 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; struct usb_serial_port *port = tty->driver_data;
int r; int r;
uint16_t reg_contents; uint16_t reg_contents;
......
...@@ -1320,11 +1320,11 @@ static __u32 get_ftdi_divisor(struct tty_struct *tty, ...@@ -1320,11 +1320,11 @@ static __u32 get_ftdi_divisor(struct tty_struct *tty,
if (baud <= 3000000) { if (baud <= 3000000) {
__u16 product_id = le16_to_cpu( __u16 product_id = le16_to_cpu(
port->serial->dev->descriptor.idProduct); port->serial->dev->descriptor.idProduct);
if (((FTDI_NDI_HUC_PID == product_id) || if (((product_id == FTDI_NDI_HUC_PID) ||
(FTDI_NDI_SPECTRA_SCU_PID == product_id) || (product_id == FTDI_NDI_SPECTRA_SCU_PID) ||
(FTDI_NDI_FUTURE_2_PID == product_id) || (product_id == FTDI_NDI_FUTURE_2_PID) ||
(FTDI_NDI_FUTURE_3_PID == product_id) || (product_id == FTDI_NDI_FUTURE_3_PID) ||
(FTDI_NDI_AURORA_SCU_PID == product_id)) && (product_id == FTDI_NDI_AURORA_SCU_PID)) &&
(baud == 19200)) { (baud == 19200)) {
baud = 1200000; baud = 1200000;
} }
......
...@@ -239,11 +239,11 @@ enum ftdi_sio_baudrate { ...@@ -239,11 +239,11 @@ enum ftdi_sio_baudrate {
*/ */
#define FTDI_SIO_SET_DTR_MASK 0x1 #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_HIGH ((FTDI_SIO_SET_DTR_MASK << 8) | 1)
#define FTDI_SIO_SET_DTR_LOW (0 | (FTDI_SIO_SET_DTR_MASK << 8)) #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_MASK 0x2
#define FTDI_SIO_SET_RTS_HIGH (2 | (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 (0 | (FTDI_SIO_SET_RTS_MASK << 8)) #define FTDI_SIO_SET_RTS_LOW ((FTDI_SIO_SET_RTS_MASK << 8) | 0)
/* /*
* ControlValue * ControlValue
......
...@@ -237,10 +237,10 @@ static inline int getDataLength(const __u8 *usbPacket) ...@@ -237,10 +237,10 @@ static inline int getDataLength(const __u8 *usbPacket)
*/ */
static inline int isAbortTrfCmnd(const unsigned char *buf) static inline int isAbortTrfCmnd(const unsigned char *buf)
{ {
if (0 == memcmp(buf, GARMIN_STOP_TRANSFER_REQ, if (memcmp(buf, GARMIN_STOP_TRANSFER_REQ,
sizeof(GARMIN_STOP_TRANSFER_REQ)) || sizeof(GARMIN_STOP_TRANSFER_REQ)) == 0 ||
0 == memcmp(buf, GARMIN_STOP_TRANSFER_REQ_V2, memcmp(buf, GARMIN_STOP_TRANSFER_REQ_V2,
sizeof(GARMIN_STOP_TRANSFER_REQ_V2))) sizeof(GARMIN_STOP_TRANSFER_REQ_V2)) == 0)
return 1; return 1;
else else
return 0; return 0;
...@@ -350,7 +350,7 @@ static int gsp_send_ack(struct garmin_data *garmin_data_p, __u8 pkt_id) ...@@ -350,7 +350,7 @@ static int gsp_send_ack(struct garmin_data *garmin_data_p, __u8 pkt_id)
unsigned l = 0; unsigned l = 0;
dev_dbg(&garmin_data_p->port->dev, "%s - pkt-id: 0x%X.\n", __func__, dev_dbg(&garmin_data_p->port->dev, "%s - pkt-id: 0x%X.\n", __func__,
0xFF & pkt_id); pkt_id);
*ptr++ = DLE; *ptr++ = DLE;
*ptr++ = ACK; *ptr++ = ACK;
...@@ -366,7 +366,7 @@ static int gsp_send_ack(struct garmin_data *garmin_data_p, __u8 pkt_id) ...@@ -366,7 +366,7 @@ static int gsp_send_ack(struct garmin_data *garmin_data_p, __u8 pkt_id)
*ptr++ = DLE; *ptr++ = DLE;
*ptr++ = 0; *ptr++ = 0;
*ptr++ = 0xFF & (-cksum); *ptr++ = (-cksum) & 0xFF;
*ptr++ = DLE; *ptr++ = DLE;
*ptr++ = ETX; *ptr++ = ETX;
...@@ -423,9 +423,9 @@ static int gsp_rec_packet(struct garmin_data *garmin_data_p, int count) ...@@ -423,9 +423,9 @@ static int gsp_rec_packet(struct garmin_data *garmin_data_p, int count)
n++; n++;
} }
if ((0xff & (cksum + *recpkt)) != 0) { if (((cksum + *recpkt) & 0xff) != 0) {
dev_dbg(dev, "%s - invalid checksum, expected %02x, got %02x\n", dev_dbg(dev, "%s - invalid checksum, expected %02x, got %02x\n",
__func__, 0xff & -cksum, 0xff & *recpkt); __func__, -cksum & 0xff, *recpkt);
return -EINVPKT; return -EINVPKT;
} }
...@@ -528,7 +528,7 @@ static int gsp_receive(struct garmin_data *garmin_data_p, ...@@ -528,7 +528,7 @@ static int gsp_receive(struct garmin_data *garmin_data_p,
dev_dbg(dev, "NAK packet complete.\n"); dev_dbg(dev, "NAK packet complete.\n");
} else { } else {
dev_dbg(dev, "packet complete - id=0x%X.\n", dev_dbg(dev, "packet complete - id=0x%X.\n",
0xFF & data); data);
gsp_rec_packet(garmin_data_p, size); gsp_rec_packet(garmin_data_p, size);
} }
...@@ -636,7 +636,7 @@ static int gsp_send(struct garmin_data *garmin_data_p, ...@@ -636,7 +636,7 @@ static int gsp_send(struct garmin_data *garmin_data_p,
garmin_data_p->outsize = 0; 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", dev_dbg(dev, "not an application packet (%d)\n",
getLayerId(garmin_data_p->outbuffer)); getLayerId(garmin_data_p->outbuffer));
return -1; return -1;
...@@ -688,7 +688,7 @@ static int gsp_send(struct garmin_data *garmin_data_p, ...@@ -688,7 +688,7 @@ static int gsp_send(struct garmin_data *garmin_data_p,
*dst++ = DLE; *dst++ = DLE;
} }
cksum = 0xFF & -cksum; cksum = -cksum & 0xFF;
*dst++ = cksum; *dst++ = cksum;
if (cksum == DLE) if (cksum == DLE)
*dst++ = DLE; *dst++ = DLE;
...@@ -970,7 +970,7 @@ static void garmin_write_bulk_callback(struct urb *urb) ...@@ -970,7 +970,7 @@ static void garmin_write_bulk_callback(struct urb *urb)
struct garmin_data *garmin_data_p = struct garmin_data *garmin_data_p =
usb_get_serial_port_data(port); 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) { if (garmin_data_p->mode == MODE_GARMIN_SERIAL) {
gsp_send_ack(garmin_data_p, gsp_send_ack(garmin_data_p,
...@@ -1025,7 +1025,7 @@ static int garmin_write_bulk(struct usb_serial_port *port, ...@@ -1025,7 +1025,7 @@ static int garmin_write_bulk(struct usb_serial_port *port,
dismiss_ack ? NULL : port); dismiss_ack ? NULL : port);
urb->transfer_flags |= URB_ZERO_PACKET; 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); spin_lock_irqsave(&garmin_data_p->lock, flags);
garmin_data_p->flags |= APP_REQ_SEEN; garmin_data_p->flags |= APP_REQ_SEEN;
...@@ -1077,9 +1077,9 @@ static int garmin_write(struct tty_struct *tty, struct usb_serial_port *port, ...@@ -1077,9 +1077,9 @@ static int garmin_write(struct tty_struct *tty, struct usb_serial_port *port,
pktsiz = getDataLength(garmin_data_p->privpkt); pktsiz = getDataLength(garmin_data_p->privpkt);
pktid = getPacketId(garmin_data_p->privpkt); pktid = getPacketId(garmin_data_p->privpkt);
if (count == (GARMIN_PKTHDR_LENGTH+pktsiz) if (count == (GARMIN_PKTHDR_LENGTH + pktsiz) &&
&& GARMIN_LAYERID_PRIVATE == getLayerId(garmin_data_p->privpkt) ==
getLayerId(garmin_data_p->privpkt)) { GARMIN_LAYERID_PRIVATE) {
dev_dbg(dev, "%s - processing private request %d\n", dev_dbg(dev, "%s - processing private request %d\n",
__func__, pktid); __func__, pktid);
...@@ -1192,7 +1192,7 @@ static void garmin_read_bulk_callback(struct urb *urb) ...@@ -1192,7 +1192,7 @@ static void garmin_read_bulk_callback(struct urb *urb)
garmin_read_process(garmin_data_p, data, urb->actual_length, 1); garmin_read_process(garmin_data_p, data, urb->actual_length, 1);
if (urb->actual_length == 0 && 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); spin_lock_irqsave(&garmin_data_p->lock, flags);
garmin_data_p->flags &= ~FLAGS_BULK_IN_RESTART; garmin_data_p->flags &= ~FLAGS_BULK_IN_RESTART;
spin_unlock_irqrestore(&garmin_data_p->lock, flags); spin_unlock_irqrestore(&garmin_data_p->lock, flags);
...@@ -1203,7 +1203,7 @@ static void garmin_read_bulk_callback(struct urb *urb) ...@@ -1203,7 +1203,7 @@ static void garmin_read_bulk_callback(struct urb *urb)
__func__, retval); __func__, retval);
} else if (urb->actual_length > 0) { } else if (urb->actual_length > 0) {
/* Continue trying to read until nothing more is received */ /* 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); retval = usb_submit_urb(port->read_urb, GFP_ATOMIC);
if (retval) if (retval)
dev_err(&port->dev, dev_err(&port->dev,
...@@ -1249,12 +1249,12 @@ static void garmin_read_int_callback(struct urb *urb) ...@@ -1249,12 +1249,12 @@ static void garmin_read_int_callback(struct urb *urb)
urb->transfer_buffer); urb->transfer_buffer);
if (urb->actual_length == sizeof(GARMIN_BULK_IN_AVAIL_REPLY) && if (urb->actual_length == sizeof(GARMIN_BULK_IN_AVAIL_REPLY) &&
0 == memcmp(data, GARMIN_BULK_IN_AVAIL_REPLY, memcmp(data, GARMIN_BULK_IN_AVAIL_REPLY,
sizeof(GARMIN_BULK_IN_AVAIL_REPLY))) { sizeof(GARMIN_BULK_IN_AVAIL_REPLY)) == 0) {
dev_dbg(&port->dev, "%s - bulk data available.\n", __func__); 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 */ /* bulk data available */
retval = usb_submit_urb(port->read_urb, GFP_ATOMIC); retval = usb_submit_urb(port->read_urb, GFP_ATOMIC);
...@@ -1276,8 +1276,8 @@ static void garmin_read_int_callback(struct urb *urb) ...@@ -1276,8 +1276,8 @@ static void garmin_read_int_callback(struct urb *urb)
} }
} else if (urb->actual_length == (4+sizeof(GARMIN_START_SESSION_REPLY)) } else if (urb->actual_length == (4+sizeof(GARMIN_START_SESSION_REPLY))
&& 0 == memcmp(data, GARMIN_START_SESSION_REPLY, && memcmp(data, GARMIN_START_SESSION_REPLY,
sizeof(GARMIN_START_SESSION_REPLY))) { sizeof(GARMIN_START_SESSION_REPLY)) == 0) {
spin_lock_irqsave(&garmin_data_p->lock, flags); spin_lock_irqsave(&garmin_data_p->lock, flags);
garmin_data_p->flags |= FLAGS_SESSION_REPLY1_SEEN; garmin_data_p->flags |= FLAGS_SESSION_REPLY1_SEEN;
...@@ -1356,7 +1356,7 @@ static void garmin_unthrottle(struct tty_struct *tty) ...@@ -1356,7 +1356,7 @@ static void garmin_unthrottle(struct tty_struct *tty)
if (garmin_data_p->mode == MODE_NATIVE) if (garmin_data_p->mode == MODE_NATIVE)
garmin_flush_queue(garmin_data_p); 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); status = usb_submit_urb(port->read_urb, GFP_KERNEL);
if (status) if (status)
dev_err(&port->dev, dev_err(&port->dev,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment