Changes two simple if statements to switch statements. Fixes some issues reported by checkpatch.pl like whitespace. Bracing changes so all arms of a statement have consistent bracing. Signed-off-by: Jaša Bartelj <jasa.bartelj@xxxxxxxxx> --- drivers/usb/serial/ftdi_sio.c | 48 +++++++++++++++++++++++++-------------- drivers/usb/serial/ftdi_sio_ids.h | 4 ++-- 2 files changed, 33 insertions(+), 19 deletions(-) diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index 19cf267..3340dea 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c @@ -58,7 +58,7 @@ struct ftdi_private { int custom_divisor; /* custom_divisor kludge, this is for baud_base (different from what goes to the chip!) */ - __u16 last_set_data_urb_value ; + __u16 last_set_data_urb_value; /* the last data state set - needed for doing * a break */ @@ -1038,6 +1038,7 @@ static unsigned short int ftdi_232am_baud_base_to_divisor(int baud, int base) unsigned short int divisor; /* divisor shifted 3 bits to the left */ int divisor3 = base / 2 / baud; + if ((divisor3 & 0x7) == 7) divisor3++; /* round x.7/8 up to x+1 */ divisor = divisor3 >> 3; @@ -1064,6 +1065,7 @@ static __u32 ftdi_232bm_baud_base_to_divisor(int baud, int base) __u32 divisor; /* divisor shifted 3 bits to the left */ int divisor3 = base / 2 / baud; + divisor = divisor3 >> 3; divisor |= (__u32)divfrac[divisor3 & 0x7] << 14; /* Deal with special cases for highest baud rates. */ @@ -1433,16 +1435,23 @@ static int set_serial_info(struct tty_struct *tty, check_and_exit: if ((old_priv.flags & ASYNC_SPD_MASK) != (priv->flags & ASYNC_SPD_MASK)) { - if ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI) + switch (priv->flags & ASYNC_SPD_MASK) { + case ASYNC_SPD_HI: tty->alt_speed = 57600; - else if ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI) + break; + case ASYNC_SPD_VHI: tty->alt_speed = 115200; - else if ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI) + break; + case ASYNC_SPD_SHI: tty->alt_speed = 230400; - else if ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP) + break; + case ASYNC_SPD_WARP: tty->alt_speed = 460800; - else + break; + default: tty->alt_speed = 0; + break; + } } if (((old_priv.flags & ASYNC_SPD_MASK) != (priv->flags & ASYNC_SPD_MASK)) || @@ -1450,9 +1459,9 @@ check_and_exit: (old_priv.custom_divisor != priv->custom_divisor))) { change_speed(tty, port); mutex_unlock(&priv->cfg_lock); - } - else + } else { mutex_unlock(&priv->cfg_lock); + } return 0; } @@ -1491,8 +1500,6 @@ static void ftdi_determine_type(struct usb_serial_port *port) dev_dbg(&port->dev, "%s: bcdDevice = 0x%x, bNumInterfaces = %u\n", __func__, version, interfaces); if (interfaces > 1) { - int inter; - /* Multiple interfaces.*/ if (version == 0x0800) { priv->chip_type = FT4232H; @@ -1502,20 +1509,26 @@ static void ftdi_determine_type(struct usb_serial_port *port) priv->chip_type = FT2232H; /* Hi-speed - baud clock runs at 120MHz */ priv->baud_base = 120000000 / 2; - } else + } else { priv->chip_type = FT2232C; + } /* Determine interface code. */ - inter = serial->interface->altsetting->desc.bInterfaceNumber; - if (inter == 0) { + switch (serial->interface->altsetting->desc.bInterfaceNumber) { + case 0: priv->interface = INTERFACE_A; - } else if (inter == 1) { + break; + case 1: priv->interface = INTERFACE_B; - } else if (inter == 2) { + break; + case 2: priv->interface = INTERFACE_C; - } else if (inter == 3) { + break; + case 3: priv->interface = INTERFACE_D; + break; } + /* BM-type devices have a bug where bcdDevice gets set * to 0x200 when iSerialNumber is 0. */ if (version < 0x500) { @@ -1598,6 +1611,7 @@ static ssize_t latency_timer_show(struct device *dev, { struct usb_serial_port *port = to_usb_serial_port(dev); struct ftdi_private *priv = usb_get_serial_port_data(port); + if (priv->flags & ASYNC_LOW_LATENCY) return sprintf(buf, "1\n"); else @@ -1710,6 +1724,7 @@ static int ftdi_sio_probe(struct usb_serial *serial, if (quirk && quirk->probe) { int ret = quirk->probe(serial); + if (ret != 0) return ret; } @@ -1724,7 +1739,6 @@ static int ftdi_sio_port_probe(struct usb_serial_port *port) struct ftdi_private *priv; struct ftdi_sio_quirk *quirk = usb_get_serial_data(port->serial); - priv = kzalloc(sizeof(struct ftdi_private), GFP_KERNEL); if (!priv) return -ENOMEM; diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h index f585eb7..c16d330 100644 --- a/drivers/usb/serial/ftdi_sio_ids.h +++ b/drivers/usb/serial/ftdi_sio_ids.h @@ -897,7 +897,7 @@ * Kondo Kagaku Co.Ltd. * http://www.kondo-robot.com/EN */ -#define KONDO_VID 0x165c +#define KONDO_VID 0x165c #define KONDO_USB_SERIAL_PID 0x0002 /* @@ -1284,7 +1284,7 @@ /* * Accesio USB Data Acquisition products (http://www.accesio.com/) */ -#define ACCESIO_COM4SM_PID 0xD578 +#define ACCESIO_COM4SM_PID 0xD578 /* www.sciencescope.co.uk educational dataloggers */ #define FTDI_SCIENCESCOPE_LOGBOOKML_PID 0xFF18 -- 1.9.3 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html