aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-03-17 17:24:26 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-03-17 17:24:26 -0400
commit48d10bda1f2c69980601a61194015bb0790fb7ab (patch)
treee4ea2021560b1f18b335f6e8e20761fb9514cd1b /drivers/usb/serial
parent96b9b1c95660d4bc5510c5d798d3817ae9f0b391 (diff)
parentce53bfc4374cada8b645765e2b4ad5831e760932 (diff)
Merge tag 'usb-4.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
Pull USB updates from Greg KH: "Here is the big USB patchset for 4.6-rc1. The normal mess is here, gadget and xhci fixes and updates, and lots of other driver updates and cleanups as well. Full details are in the shortlog. All have been in linux-next for a while with no reported issues" * tag 'usb-4.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (266 commits) USB: core: let USB device know device node usb: devio: Add ioctl to disallow detaching kernel USB drivers. usb: gadget: f_acm: Fix configfs attr name usb: udc: lpc32xx: remove USB PLL and USB OTG clock management usb: udc: lpc32xx: remove direct access to clock controller registers usb: udc: lpc32xx: switch to clock prepare/unprepare model usb: renesas_usbhs: gadget: fix giveback status code in usbhsg_pipe_disable() usb: gadget: renesas_usb3: Use ARCH_RENESAS usb: dwc2: Fix issues in dwc2_complete_non_isoc_xfer_ddma() usb: dwc2: Add support for Lantiq ARX and XRX SoCs usb: phy: generic: Handle late registration of gadget usb: gadget: bdc_udc: fix race condition in bdc_udc_exit() usb: musb: core: added missing const qualifier to musb_hdrc_platform_data::config usb: dwc2: Move host-specific core functions into hcd.c usb: dwc2: Move register save and restore functions usb: dwc2: Use kmem_cache_free() usb: dwc2: host: If using uframe scheduler, end splits better usb: dwc2: host: Totally redo the microframe scheduler usb: dwc2: host: Properly set even/odd frame usb: dwc2: host: Add dwc2_hcd_get_future_frame_number() call ...
Diffstat (limited to 'drivers/usb/serial')
-rw-r--r--drivers/usb/serial/ch341.c2
-rw-r--r--drivers/usb/serial/cp210x.c306
-rw-r--r--drivers/usb/serial/cyberjack.c3
-rw-r--r--drivers/usb/serial/ftdi_sio.c10
-rw-r--r--drivers/usb/serial/ftdi_sio.h8
-rw-r--r--drivers/usb/serial/garmin_gps.c51
-rw-r--r--drivers/usb/serial/iuu_phoenix.c4
-rw-r--r--drivers/usb/serial/keyspan.c2
-rw-r--r--drivers/usb/serial/kl5kusb105.c3
-rw-r--r--drivers/usb/serial/mos7840.c4
-rw-r--r--drivers/usb/serial/quatech2.c2
-rw-r--r--drivers/usb/serial/safe_serial.c11
12 files changed, 228 insertions, 178 deletions
diff --git a/drivers/usb/serial/ch341.c b/drivers/usb/serial/ch341.c
index c73808f095bb..f139488d0816 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,
370static void ch341_break_ctl(struct tty_struct *tty, int break_state) 370static void ch341_break_ctl(struct tty_struct *tty, int break_state)
371{ 371{
372 const uint16_t ch341_break_reg = 372 const uint16_t ch341_break_reg =
373 CH341_REG_BREAK1 | ((uint16_t) CH341_REG_BREAK2 << 8); 373 ((uint16_t) CH341_REG_BREAK2 << 8) | CH341_REG_BREAK1;
374 struct usb_serial_port *port = tty->driver_data; 374 struct usb_serial_port *port = tty->driver_data;
375 int r; 375 int r;
376 uint16_t reg_contents; 376 uint16_t reg_contents;
diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
index 73a366de5102..fbfe761c7fba 100644
--- a/drivers/usb/serial/cp210x.c
+++ b/drivers/usb/serial/cp210x.c
@@ -327,113 +327,169 @@ struct cp210x_comm_status {
327#define PURGE_ALL 0x000f 327#define PURGE_ALL 0x000f
328 328
329/* 329/*
330 * cp210x_get_config 330 * Reads a variable-sized block of CP210X_ registers, identified by req.
331 * Reads from the CP210x configuration registers 331 * Returns data into buf in native USB byte order.
332 * 'size' is specified in bytes.
333 * 'data' is a pointer to a pre-allocated array of integers large
334 * enough to hold 'size' bytes (with 4 bytes to each integer)
335 */ 332 */
336static int cp210x_get_config(struct usb_serial_port *port, u8 request, 333static int cp210x_read_reg_block(struct usb_serial_port *port, u8 req,
337 unsigned int *data, int size) 334 void *buf, int bufsize)
338{ 335{
339 struct usb_serial *serial = port->serial; 336 struct usb_serial *serial = port->serial;
340 struct cp210x_port_private *port_priv = usb_get_serial_port_data(port); 337 struct cp210x_port_private *port_priv = usb_get_serial_port_data(port);
341 __le32 *buf; 338 void *dmabuf;
342 int result, i, length; 339 int result;
343
344 /* Number of integers required to contain the array */
345 length = (((size - 1) | 3) + 1) / 4;
346 340
347 buf = kcalloc(length, sizeof(__le32), GFP_KERNEL); 341 dmabuf = kmalloc(bufsize, GFP_KERNEL);
348 if (!buf) 342 if (!dmabuf) {
343 /*
344 * FIXME Some callers don't bother to check for error,
345 * at least give them consistent junk until they are fixed
346 */
347 memset(buf, 0, bufsize);
349 return -ENOMEM; 348 return -ENOMEM;
349 }
350 350
351 /* Issue the request, attempting to read 'size' bytes */
352 result = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), 351 result = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0),
353 request, REQTYPE_INTERFACE_TO_HOST, 0x0000, 352 req, REQTYPE_INTERFACE_TO_HOST, 0,
354 port_priv->bInterfaceNumber, buf, size, 353 port_priv->bInterfaceNumber, dmabuf, bufsize,
355 USB_CTRL_GET_TIMEOUT); 354 USB_CTRL_SET_TIMEOUT);
355 if (result == bufsize) {
356 memcpy(buf, dmabuf, bufsize);
357 result = 0;
358 } else {
359 dev_err(&port->dev, "failed get req 0x%x size %d status: %d\n",
360 req, bufsize, result);
361 if (result >= 0)
362 result = -EPROTO;
356 363
357 /* Convert data into an array of integers */ 364 /*
358 for (i = 0; i < length; i++) 365 * FIXME Some callers don't bother to check for error,
359 data[i] = le32_to_cpu(buf[i]); 366 * at least give them consistent junk until they are fixed
367 */
368 memset(buf, 0, bufsize);
369 }
360 370
361 kfree(buf); 371 kfree(dmabuf);
362 372
363 if (result != size) { 373 return result;
364 dev_dbg(&port->dev, "%s - Unable to send config request, request=0x%x size=%d result=%d\n", 374}
365 __func__, request, size, result);
366 if (result > 0)
367 result = -EPROTO;
368 375
369 return result; 376/*
377 * Reads any 32-bit CP210X_ register identified by req.
378 */
379static int cp210x_read_u32_reg(struct usb_serial_port *port, u8 req, u32 *val)
380{
381 __le32 le32_val;
382 int err;
383
384 err = cp210x_read_reg_block(port, req, &le32_val, sizeof(le32_val));
385 if (err) {
386 /*
387 * FIXME Some callers don't bother to check for error,
388 * at least give them consistent junk until they are fixed
389 */
390 *val = 0;
391 return err;
370 } 392 }
371 393
394 *val = le32_to_cpu(le32_val);
395
396 return 0;
397}
398
399/*
400 * Reads any 16-bit CP210X_ register identified by req.
401 */
402static int cp210x_read_u16_reg(struct usb_serial_port *port, u8 req, u16 *val)
403{
404 __le16 le16_val;
405 int err;
406
407 err = cp210x_read_reg_block(port, req, &le16_val, sizeof(le16_val));
408 if (err)
409 return err;
410
411 *val = le16_to_cpu(le16_val);
412
372 return 0; 413 return 0;
373} 414}
374 415
375/* 416/*
376 * cp210x_set_config 417 * Reads any 8-bit CP210X_ register identified by req.
377 * Writes to the CP210x configuration registers 418 */
378 * Values less than 16 bits wide are sent directly 419static int cp210x_read_u8_reg(struct usb_serial_port *port, u8 req, u8 *val)
379 * 'size' is specified in bytes. 420{
421 return cp210x_read_reg_block(port, req, val, sizeof(*val));
422}
423
424/*
425 * Writes any 16-bit CP210X_ register (req) whose value is passed
426 * entirely in the wValue field of the USB request.
380 */ 427 */
381static int cp210x_set_config(struct usb_serial_port *port, u8 request, 428static int cp210x_write_u16_reg(struct usb_serial_port *port, u8 req, u16 val)
382 unsigned int *data, int size)
383{ 429{
384 struct usb_serial *serial = port->serial; 430 struct usb_serial *serial = port->serial;
385 struct cp210x_port_private *port_priv = usb_get_serial_port_data(port); 431 struct cp210x_port_private *port_priv = usb_get_serial_port_data(port);
386 __le32 *buf; 432 int result;
387 int result, i, length; 433
434 result = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
435 req, REQTYPE_HOST_TO_INTERFACE, val,
436 port_priv->bInterfaceNumber, NULL, 0,
437 USB_CTRL_SET_TIMEOUT);
438 if (result < 0) {
439 dev_err(&port->dev, "failed set request 0x%x status: %d\n",
440 req, result);
441 }
442
443 return result;
444}
388 445
389 /* Number of integers required to contain the array */ 446/*
390 length = (((size - 1) | 3) + 1) / 4; 447 * Writes a variable-sized block of CP210X_ registers, identified by req.
448 * Data in buf must be in native USB byte order.
449 */
450static int cp210x_write_reg_block(struct usb_serial_port *port, u8 req,
451 void *buf, int bufsize)
452{
453 struct usb_serial *serial = port->serial;
454 struct cp210x_port_private *port_priv = usb_get_serial_port_data(port);
455 void *dmabuf;
456 int result;
391 457
392 buf = kmalloc(length * sizeof(__le32), GFP_KERNEL); 458 dmabuf = kmalloc(bufsize, GFP_KERNEL);
393 if (!buf) 459 if (!dmabuf)
394 return -ENOMEM; 460 return -ENOMEM;
395 461
396 /* Array of integers into bytes */ 462 memcpy(dmabuf, buf, bufsize);
397 for (i = 0; i < length; i++)
398 buf[i] = cpu_to_le32(data[i]);
399 463
400 if (size > 2) { 464 result = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
401 result = usb_control_msg(serial->dev, 465 req, REQTYPE_HOST_TO_INTERFACE, 0,
402 usb_sndctrlpipe(serial->dev, 0), 466 port_priv->bInterfaceNumber, dmabuf, bufsize,
403 request, REQTYPE_HOST_TO_INTERFACE, 0x0000, 467 USB_CTRL_SET_TIMEOUT);
404 port_priv->bInterfaceNumber, buf, size,
405 USB_CTRL_SET_TIMEOUT);
406 } else {
407 result = usb_control_msg(serial->dev,
408 usb_sndctrlpipe(serial->dev, 0),
409 request, REQTYPE_HOST_TO_INTERFACE, data[0],
410 port_priv->bInterfaceNumber, NULL, 0,
411 USB_CTRL_SET_TIMEOUT);
412 }
413 468
414 kfree(buf); 469 kfree(dmabuf);
415 470
416 if ((size > 2 && result != size) || result < 0) { 471 if (result == bufsize) {
417 dev_dbg(&port->dev, "%s - Unable to send request, request=0x%x size=%d result=%d\n", 472 result = 0;
418 __func__, request, size, result); 473 } else {
419 if (result > 0) 474 dev_err(&port->dev, "failed set req 0x%x size %d status: %d\n",
475 req, bufsize, result);
476 if (result >= 0)
420 result = -EPROTO; 477 result = -EPROTO;
421
422 return result;
423 } 478 }
424 479
425 return 0; 480 return result;
426} 481}
427 482
428/* 483/*
429 * cp210x_set_config_single 484 * Writes any 32-bit CP210X_ register identified by req.
430 * Convenience function for calling cp210x_set_config on single data values
431 * without requiring an integer pointer
432 */ 485 */
433static inline int cp210x_set_config_single(struct usb_serial_port *port, 486static int cp210x_write_u32_reg(struct usb_serial_port *port, u8 req, u32 val)
434 u8 request, unsigned int data)
435{ 487{
436 return cp210x_set_config(port, request, &data, 2); 488 __le32 le32_val;
489
490 le32_val = cpu_to_le32(val);
491
492 return cp210x_write_reg_block(port, req, &le32_val, sizeof(le32_val));
437} 493}
438 494
439/* 495/*
@@ -445,47 +501,46 @@ static inline int cp210x_set_config_single(struct usb_serial_port *port,
445static int cp210x_detect_swapped_line_ctl(struct usb_serial_port *port) 501static int cp210x_detect_swapped_line_ctl(struct usb_serial_port *port)
446{ 502{
447 struct cp210x_port_private *port_priv = usb_get_serial_port_data(port); 503 struct cp210x_port_private *port_priv = usb_get_serial_port_data(port);
448 unsigned int line_ctl_save; 504 u16 line_ctl_save;
449 unsigned int line_ctl_test; 505 u16 line_ctl_test;
450 int err; 506 int err;
451 507
452 err = cp210x_get_config(port, CP210X_GET_LINE_CTL, &line_ctl_save, 2); 508 err = cp210x_read_u16_reg(port, CP210X_GET_LINE_CTL, &line_ctl_save);
453 if (err) 509 if (err)
454 return err; 510 return err;
455 511
456 line_ctl_test = 0x800; 512 err = cp210x_write_u16_reg(port, CP210X_SET_LINE_CTL, 0x800);
457 err = cp210x_set_config(port, CP210X_SET_LINE_CTL, &line_ctl_test, 2);
458 if (err) 513 if (err)
459 return err; 514 return err;
460 515
461 err = cp210x_get_config(port, CP210X_GET_LINE_CTL, &line_ctl_test, 2); 516 err = cp210x_read_u16_reg(port, CP210X_GET_LINE_CTL, &line_ctl_test);
462 if (err) 517 if (err)
463 return err; 518 return err;
464 519
465 if (line_ctl_test == 8) { 520 if (line_ctl_test == 8) {
466 port_priv->has_swapped_line_ctl = true; 521 port_priv->has_swapped_line_ctl = true;
467 line_ctl_save = swab16((u16)line_ctl_save); 522 line_ctl_save = swab16(line_ctl_save);
468 } 523 }
469 524
470 return cp210x_set_config(port, CP210X_SET_LINE_CTL, &line_ctl_save, 2); 525 return cp210x_write_u16_reg(port, CP210X_SET_LINE_CTL, line_ctl_save);
471} 526}
472 527
473/* 528/*
474 * Must always be called instead of cp210x_get_config(CP210X_GET_LINE_CTL) 529 * Must always be called instead of cp210x_read_u16_reg(CP210X_GET_LINE_CTL)
475 * to workaround cp2108 bug and get correct value. 530 * to workaround cp2108 bug and get correct value.
476 */ 531 */
477static int cp210x_get_line_ctl(struct usb_serial_port *port, unsigned int *ctl) 532static int cp210x_get_line_ctl(struct usb_serial_port *port, u16 *ctl)
478{ 533{
479 struct cp210x_port_private *port_priv = usb_get_serial_port_data(port); 534 struct cp210x_port_private *port_priv = usb_get_serial_port_data(port);
480 int err; 535 int err;
481 536
482 err = cp210x_get_config(port, CP210X_GET_LINE_CTL, ctl, 2); 537 err = cp210x_read_u16_reg(port, CP210X_GET_LINE_CTL, ctl);
483 if (err) 538 if (err)
484 return err; 539 return err;
485 540
486 /* Workaround swapped bytes in 16-bit value from CP210X_GET_LINE_CTL */ 541 /* Workaround swapped bytes in 16-bit value from CP210X_GET_LINE_CTL */
487 if (port_priv->has_swapped_line_ctl) 542 if (port_priv->has_swapped_line_ctl)
488 *ctl = swab16((u16)(*ctl)); 543 *ctl = swab16(*ctl);
489 544
490 return 0; 545 return 0;
491} 546}
@@ -536,8 +591,7 @@ static int cp210x_open(struct tty_struct *tty, struct usb_serial_port *port)
536{ 591{
537 int result; 592 int result;
538 593
539 result = cp210x_set_config_single(port, CP210X_IFC_ENABLE, 594 result = cp210x_write_u16_reg(port, CP210X_IFC_ENABLE, UART_ENABLE);
540 UART_ENABLE);
541 if (result) { 595 if (result) {
542 dev_err(&port->dev, "%s - Unable to enable UART\n", __func__); 596 dev_err(&port->dev, "%s - Unable to enable UART\n", __func__);
543 return result; 597 return result;
@@ -555,15 +609,12 @@ static int cp210x_open(struct tty_struct *tty, struct usb_serial_port *port)
555 609
556static void cp210x_close(struct usb_serial_port *port) 610static void cp210x_close(struct usb_serial_port *port)
557{ 611{
558 unsigned int purge_ctl;
559
560 usb_serial_generic_close(port); 612 usb_serial_generic_close(port);
561 613
562 /* Clear both queues; cp2108 needs this to avoid an occasional hang */ 614 /* Clear both queues; cp2108 needs this to avoid an occasional hang */
563 purge_ctl = PURGE_ALL; 615 cp210x_write_u16_reg(port, CP210X_PURGE, PURGE_ALL);
564 cp210x_set_config(port, CP210X_PURGE, &purge_ctl, 2);
565 616
566 cp210x_set_config_single(port, CP210X_IFC_ENABLE, UART_DISABLE); 617 cp210x_write_u16_reg(port, CP210X_IFC_ENABLE, UART_DISABLE);
567} 618}
568 619
569/* 620/*
@@ -641,11 +692,12 @@ static void cp210x_get_termios_port(struct usb_serial_port *port,
641 unsigned int *cflagp, unsigned int *baudp) 692 unsigned int *cflagp, unsigned int *baudp)
642{ 693{
643 struct device *dev = &port->dev; 694 struct device *dev = &port->dev;
644 unsigned int cflag, modem_ctl[4]; 695 unsigned int cflag;
645 unsigned int baud; 696 u8 modem_ctl[16];
646 unsigned int bits; 697 u32 baud;
698 u16 bits;
647 699
648 cp210x_get_config(port, CP210X_GET_BAUDRATE, &baud, 4); 700 cp210x_read_u32_reg(port, CP210X_GET_BAUDRATE, &baud);
649 701
650 dev_dbg(dev, "%s - baud rate = %d\n", __func__, baud); 702 dev_dbg(dev, "%s - baud rate = %d\n", __func__, baud);
651 *baudp = baud; 703 *baudp = baud;
@@ -676,14 +728,14 @@ static void cp210x_get_termios_port(struct usb_serial_port *port,
676 cflag |= CS8; 728 cflag |= CS8;
677 bits &= ~BITS_DATA_MASK; 729 bits &= ~BITS_DATA_MASK;
678 bits |= BITS_DATA_8; 730 bits |= BITS_DATA_8;
679 cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2); 731 cp210x_write_u16_reg(port, CP210X_SET_LINE_CTL, bits);
680 break; 732 break;
681 default: 733 default:
682 dev_dbg(dev, "%s - Unknown number of data bits, using 8\n", __func__); 734 dev_dbg(dev, "%s - Unknown number of data bits, using 8\n", __func__);
683 cflag |= CS8; 735 cflag |= CS8;
684 bits &= ~BITS_DATA_MASK; 736 bits &= ~BITS_DATA_MASK;
685 bits |= BITS_DATA_8; 737 bits |= BITS_DATA_8;
686 cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2); 738 cp210x_write_u16_reg(port, CP210X_SET_LINE_CTL, bits);
687 break; 739 break;
688 } 740 }
689 741
@@ -714,7 +766,7 @@ static void cp210x_get_termios_port(struct usb_serial_port *port,
714 dev_dbg(dev, "%s - Unknown parity mode, disabling parity\n", __func__); 766 dev_dbg(dev, "%s - Unknown parity mode, disabling parity\n", __func__);
715 cflag &= ~PARENB; 767 cflag &= ~PARENB;
716 bits &= ~BITS_PARITY_MASK; 768 bits &= ~BITS_PARITY_MASK;
717 cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2); 769 cp210x_write_u16_reg(port, CP210X_SET_LINE_CTL, bits);
718 break; 770 break;
719 } 771 }
720 772
@@ -726,7 +778,7 @@ static void cp210x_get_termios_port(struct usb_serial_port *port,
726 case BITS_STOP_1_5: 778 case BITS_STOP_1_5:
727 dev_dbg(dev, "%s - stop bits = 1.5 (not supported, using 1 stop bit)\n", __func__); 779 dev_dbg(dev, "%s - stop bits = 1.5 (not supported, using 1 stop bit)\n", __func__);
728 bits &= ~BITS_STOP_MASK; 780 bits &= ~BITS_STOP_MASK;
729 cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2); 781 cp210x_write_u16_reg(port, CP210X_SET_LINE_CTL, bits);
730 break; 782 break;
731 case BITS_STOP_2: 783 case BITS_STOP_2:
732 dev_dbg(dev, "%s - stop bits = 2\n", __func__); 784 dev_dbg(dev, "%s - stop bits = 2\n", __func__);
@@ -735,12 +787,13 @@ static void cp210x_get_termios_port(struct usb_serial_port *port,
735 default: 787 default:
736 dev_dbg(dev, "%s - Unknown number of stop bits, using 1 stop bit\n", __func__); 788 dev_dbg(dev, "%s - Unknown number of stop bits, using 1 stop bit\n", __func__);
737 bits &= ~BITS_STOP_MASK; 789 bits &= ~BITS_STOP_MASK;
738 cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2); 790 cp210x_write_u16_reg(port, CP210X_SET_LINE_CTL, bits);
739 break; 791 break;
740 } 792 }
741 793
742 cp210x_get_config(port, CP210X_GET_FLOW, modem_ctl, 16); 794 cp210x_read_reg_block(port, CP210X_GET_FLOW, modem_ctl,
743 if (modem_ctl[0] & 0x0008) { 795 sizeof(modem_ctl));
796 if (modem_ctl[0] & 0x08) {
744 dev_dbg(dev, "%s - flow control = CRTSCTS\n", __func__); 797 dev_dbg(dev, "%s - flow control = CRTSCTS\n", __func__);
745 cflag |= CRTSCTS; 798 cflag |= CRTSCTS;
746 } else { 799 } else {
@@ -792,8 +845,7 @@ static void cp210x_change_speed(struct tty_struct *tty,
792 baud = cp210x_quantise_baudrate(baud); 845 baud = cp210x_quantise_baudrate(baud);
793 846
794 dev_dbg(&port->dev, "%s - setting baud rate to %u\n", __func__, baud); 847 dev_dbg(&port->dev, "%s - setting baud rate to %u\n", __func__, baud);
795 if (cp210x_set_config(port, CP210X_SET_BAUDRATE, &baud, 848 if (cp210x_write_u32_reg(port, CP210X_SET_BAUDRATE, baud)) {
796 sizeof(baud))) {
797 dev_warn(&port->dev, "failed to set baud rate to %u\n", baud); 849 dev_warn(&port->dev, "failed to set baud rate to %u\n", baud);
798 if (old_termios) 850 if (old_termios)
799 baud = old_termios->c_ospeed; 851 baud = old_termios->c_ospeed;
@@ -809,8 +861,8 @@ static void cp210x_set_termios(struct tty_struct *tty,
809{ 861{
810 struct device *dev = &port->dev; 862 struct device *dev = &port->dev;
811 unsigned int cflag, old_cflag; 863 unsigned int cflag, old_cflag;
812 unsigned int bits; 864 u16 bits;
813 unsigned int modem_ctl[4]; 865 u8 modem_ctl[16];
814 866
815 cflag = tty->termios.c_cflag; 867 cflag = tty->termios.c_cflag;
816 old_cflag = old_termios->c_cflag; 868 old_cflag = old_termios->c_cflag;
@@ -848,7 +900,7 @@ static void cp210x_set_termios(struct tty_struct *tty,
848 bits |= BITS_DATA_8; 900 bits |= BITS_DATA_8;
849 break; 901 break;
850 } 902 }
851 if (cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2)) 903 if (cp210x_write_u16_reg(port, CP210X_SET_LINE_CTL, bits))
852 dev_dbg(dev, "Number of data bits requested not supported by device\n"); 904 dev_dbg(dev, "Number of data bits requested not supported by device\n");
853 } 905 }
854 906
@@ -875,7 +927,7 @@ static void cp210x_set_termios(struct tty_struct *tty,
875 } 927 }
876 } 928 }
877 } 929 }
878 if (cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2)) 930 if (cp210x_write_u16_reg(port, CP210X_SET_LINE_CTL, bits))
879 dev_dbg(dev, "Parity mode not supported by device\n"); 931 dev_dbg(dev, "Parity mode not supported by device\n");
880 } 932 }
881 933
@@ -889,32 +941,40 @@ static void cp210x_set_termios(struct tty_struct *tty,
889 bits |= BITS_STOP_1; 941 bits |= BITS_STOP_1;
890 dev_dbg(dev, "%s - stop bits = 1\n", __func__); 942 dev_dbg(dev, "%s - stop bits = 1\n", __func__);
891 } 943 }
892 if (cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2)) 944 if (cp210x_write_u16_reg(port, CP210X_SET_LINE_CTL, bits))
893 dev_dbg(dev, "Number of stop bits requested not supported by device\n"); 945 dev_dbg(dev, "Number of stop bits requested not supported by device\n");
894 } 946 }
895 947
896 if ((cflag & CRTSCTS) != (old_cflag & CRTSCTS)) { 948 if ((cflag & CRTSCTS) != (old_cflag & CRTSCTS)) {
897 cp210x_get_config(port, CP210X_GET_FLOW, modem_ctl, 16); 949
898 dev_dbg(dev, "%s - read modem controls = 0x%.4x 0x%.4x 0x%.4x 0x%.4x\n", 950 /* Only bytes 0, 4 and 7 out of first 8 have functional bits */
899 __func__, modem_ctl[0], modem_ctl[1], 951
900 modem_ctl[2], modem_ctl[3]); 952 cp210x_read_reg_block(port, CP210X_GET_FLOW, modem_ctl,
953 sizeof(modem_ctl));
954 dev_dbg(dev, "%s - read modem controls = %02x .. .. .. %02x .. .. %02x\n",
955 __func__, modem_ctl[0], modem_ctl[4], modem_ctl[7]);
901 956
902 if (cflag & CRTSCTS) { 957 if (cflag & CRTSCTS) {
903 modem_ctl[0] &= ~0x7B; 958 modem_ctl[0] &= ~0x7B;
904 modem_ctl[0] |= 0x09; 959 modem_ctl[0] |= 0x09;
905 modem_ctl[1] = 0x80; 960 modem_ctl[4] = 0x80;
961 /* FIXME - why clear reserved bits just read? */
962 modem_ctl[5] = 0;
963 modem_ctl[6] = 0;
964 modem_ctl[7] = 0;
906 dev_dbg(dev, "%s - flow control = CRTSCTS\n", __func__); 965 dev_dbg(dev, "%s - flow control = CRTSCTS\n", __func__);
907 } else { 966 } else {
908 modem_ctl[0] &= ~0x7B; 967 modem_ctl[0] &= ~0x7B;
909 modem_ctl[0] |= 0x01; 968 modem_ctl[0] |= 0x01;
910 modem_ctl[1] |= 0x40; 969 /* FIXME - OR here instead of assignment looks wrong */
970 modem_ctl[4] |= 0x40;
911 dev_dbg(dev, "%s - flow control = NONE\n", __func__); 971 dev_dbg(dev, "%s - flow control = NONE\n", __func__);
912 } 972 }
913 973
914 dev_dbg(dev, "%s - write modem controls = 0x%.4x 0x%.4x 0x%.4x 0x%.4x\n", 974 dev_dbg(dev, "%s - write modem controls = %02x .. .. .. %02x .. .. %02x\n",
915 __func__, modem_ctl[0], modem_ctl[1], 975 __func__, modem_ctl[0], modem_ctl[4], modem_ctl[7]);
916 modem_ctl[2], modem_ctl[3]); 976 cp210x_write_reg_block(port, CP210X_SET_FLOW, modem_ctl,
917 cp210x_set_config(port, CP210X_SET_FLOW, modem_ctl, 16); 977 sizeof(modem_ctl));
918 } 978 }
919 979
920} 980}
@@ -929,7 +989,7 @@ static int cp210x_tiocmset(struct tty_struct *tty,
929static int cp210x_tiocmset_port(struct usb_serial_port *port, 989static int cp210x_tiocmset_port(struct usb_serial_port *port,
930 unsigned int set, unsigned int clear) 990 unsigned int set, unsigned int clear)
931{ 991{
932 unsigned int control = 0; 992 u16 control = 0;
933 993
934 if (set & TIOCM_RTS) { 994 if (set & TIOCM_RTS) {
935 control |= CONTROL_RTS; 995 control |= CONTROL_RTS;
@@ -950,7 +1010,7 @@ static int cp210x_tiocmset_port(struct usb_serial_port *port,
950 1010
951 dev_dbg(&port->dev, "%s - control = 0x%.4x\n", __func__, control); 1011 dev_dbg(&port->dev, "%s - control = 0x%.4x\n", __func__, control);
952 1012
953 return cp210x_set_config(port, CP210X_SET_MHS, &control, 2); 1013 return cp210x_write_u16_reg(port, CP210X_SET_MHS, control);
954} 1014}
955 1015
956static void cp210x_dtr_rts(struct usb_serial_port *p, int on) 1016static void cp210x_dtr_rts(struct usb_serial_port *p, int on)
@@ -964,10 +1024,10 @@ static void cp210x_dtr_rts(struct usb_serial_port *p, int on)
964static int cp210x_tiocmget(struct tty_struct *tty) 1024static int cp210x_tiocmget(struct tty_struct *tty)
965{ 1025{
966 struct usb_serial_port *port = tty->driver_data; 1026 struct usb_serial_port *port = tty->driver_data;
967 unsigned int control; 1027 u8 control;
968 int result; 1028 int result;
969 1029
970 cp210x_get_config(port, CP210X_GET_MDMSTS, &control, 1); 1030 cp210x_read_u8_reg(port, CP210X_GET_MDMSTS, &control);
971 1031
972 result = ((control & CONTROL_DTR) ? TIOCM_DTR : 0) 1032 result = ((control & CONTROL_DTR) ? TIOCM_DTR : 0)
973 |((control & CONTROL_RTS) ? TIOCM_RTS : 0) 1033 |((control & CONTROL_RTS) ? TIOCM_RTS : 0)
@@ -984,7 +1044,7 @@ static int cp210x_tiocmget(struct tty_struct *tty)
984static void cp210x_break_ctl(struct tty_struct *tty, int break_state) 1044static void cp210x_break_ctl(struct tty_struct *tty, int break_state)
985{ 1045{
986 struct usb_serial_port *port = tty->driver_data; 1046 struct usb_serial_port *port = tty->driver_data;
987 unsigned int state; 1047 u16 state;
988 1048
989 if (break_state == 0) 1049 if (break_state == 0)
990 state = BREAK_OFF; 1050 state = BREAK_OFF;
@@ -992,7 +1052,7 @@ static void cp210x_break_ctl(struct tty_struct *tty, int break_state)
992 state = BREAK_ON; 1052 state = BREAK_ON;
993 dev_dbg(&port->dev, "%s - turning break %s\n", __func__, 1053 dev_dbg(&port->dev, "%s - turning break %s\n", __func__,
994 state == BREAK_OFF ? "off" : "on"); 1054 state == BREAK_OFF ? "off" : "on");
995 cp210x_set_config(port, CP210X_SET_BREAK, &state, 2); 1055 cp210x_write_u16_reg(port, CP210X_SET_BREAK, state);
996} 1056}
997 1057
998static int cp210x_port_probe(struct usb_serial_port *port) 1058static int cp210x_port_probe(struct usb_serial_port *port)
diff --git a/drivers/usb/serial/cyberjack.c b/drivers/usb/serial/cyberjack.c
index 2916dea3ede8..5f17a3b9916d 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,
140{ 140{
141 struct cyberjack_private *priv; 141 struct cyberjack_private *priv;
142 unsigned long flags; 142 unsigned long flags;
143 int result = 0;
144 143
145 dev_dbg(&port->dev, "%s - usb_clear_halt\n", __func__); 144 dev_dbg(&port->dev, "%s - usb_clear_halt\n", __func__);
146 usb_clear_halt(port->serial->dev, port->write_urb->pipe); 145 usb_clear_halt(port->serial->dev, port->write_urb->pipe);
@@ -152,7 +151,7 @@ static int cyberjack_open(struct tty_struct *tty,
152 priv->wrsent = 0; 151 priv->wrsent = 0;
153 spin_unlock_irqrestore(&priv->lock, flags); 152 spin_unlock_irqrestore(&priv->lock, flags);
154 153
155 return result; 154 return 0;
156} 155}
157 156
158static void cyberjack_close(struct usb_serial_port *port) 157static void cyberjack_close(struct usb_serial_port *port)
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 8c660ae401d8..427ae43ee898 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,
1320 if (baud <= 3000000) { 1320 if (baud <= 3000000) {
1321 __u16 product_id = le16_to_cpu( 1321 __u16 product_id = le16_to_cpu(
1322 port->serial->dev->descriptor.idProduct); 1322 port->serial->dev->descriptor.idProduct);
1323 if (((FTDI_NDI_HUC_PID == product_id) || 1323 if (((product_id == FTDI_NDI_HUC_PID) ||
1324 (FTDI_NDI_SPECTRA_SCU_PID == product_id) || 1324 (product_id == FTDI_NDI_SPECTRA_SCU_PID) ||
1325 (FTDI_NDI_FUTURE_2_PID == product_id) || 1325 (product_id == FTDI_NDI_FUTURE_2_PID) ||
1326 (FTDI_NDI_FUTURE_3_PID == product_id) || 1326 (product_id == FTDI_NDI_FUTURE_3_PID) ||
1327 (FTDI_NDI_AURORA_SCU_PID == product_id)) && 1327 (product_id == FTDI_NDI_AURORA_SCU_PID)) &&
1328 (baud == 19200)) { 1328 (baud == 19200)) {
1329 baud = 1200000; 1329 baud = 1200000;
1330 } 1330 }
diff --git a/drivers/usb/serial/ftdi_sio.h b/drivers/usb/serial/ftdi_sio.h
index ed58c6fa8dbe..bbcc13df11ac 100644
--- a/drivers/usb/serial/ftdi_sio.h
+++ b/drivers/usb/serial/ftdi_sio.h
@@ -239,11 +239,11 @@ enum ftdi_sio_baudrate {
239 */ 239 */
240 240
241#define FTDI_SIO_SET_DTR_MASK 0x1 241#define FTDI_SIO_SET_DTR_MASK 0x1
242#define FTDI_SIO_SET_DTR_HIGH (1 | (FTDI_SIO_SET_DTR_MASK << 8)) 242#define FTDI_SIO_SET_DTR_HIGH ((FTDI_SIO_SET_DTR_MASK << 8) | 1)
243#define FTDI_SIO_SET_DTR_LOW (0 | (FTDI_SIO_SET_DTR_MASK << 8)) 243#define FTDI_SIO_SET_DTR_LOW ((FTDI_SIO_SET_DTR_MASK << 8) | 0)
244#define FTDI_SIO_SET_RTS_MASK 0x2 244#define FTDI_SIO_SET_RTS_MASK 0x2
245#define FTDI_SIO_SET_RTS_HIGH (2 | (FTDI_SIO_SET_RTS_MASK << 8)) 245#define FTDI_SIO_SET_RTS_HIGH ((FTDI_SIO_SET_RTS_MASK << 8) | 2)
246#define FTDI_SIO_SET_RTS_LOW (0 | (FTDI_SIO_SET_RTS_MASK << 8)) 246#define FTDI_SIO_SET_RTS_LOW ((FTDI_SIO_SET_RTS_MASK << 8) | 0)
247 247
248/* 248/*
249 * ControlValue 249 * ControlValue
diff --git a/drivers/usb/serial/garmin_gps.c b/drivers/usb/serial/garmin_gps.c
index db591d19d416..97cabf803c2f 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)
237 */ 237 */
238static inline int isAbortTrfCmnd(const unsigned char *buf) 238static inline int isAbortTrfCmnd(const unsigned char *buf)
239{ 239{
240 if (0 == memcmp(buf, GARMIN_STOP_TRANSFER_REQ, 240 if (memcmp(buf, GARMIN_STOP_TRANSFER_REQ,
241 sizeof(GARMIN_STOP_TRANSFER_REQ)) || 241 sizeof(GARMIN_STOP_TRANSFER_REQ)) == 0 ||
242 0 == memcmp(buf, GARMIN_STOP_TRANSFER_REQ_V2, 242 memcmp(buf, GARMIN_STOP_TRANSFER_REQ_V2,
243 sizeof(GARMIN_STOP_TRANSFER_REQ_V2))) 243 sizeof(GARMIN_STOP_TRANSFER_REQ_V2)) == 0)
244 return 1; 244 return 1;
245 else 245 else
246 return 0; 246 return 0;
@@ -350,7 +350,7 @@ static int gsp_send_ack(struct garmin_data *garmin_data_p, __u8 pkt_id)
350 unsigned l = 0; 350 unsigned l = 0;
351 351
352 dev_dbg(&garmin_data_p->port->dev, "%s - pkt-id: 0x%X.\n", __func__, 352 dev_dbg(&garmin_data_p->port->dev, "%s - pkt-id: 0x%X.\n", __func__,
353 0xFF & pkt_id); 353 pkt_id);
354 354
355 *ptr++ = DLE; 355 *ptr++ = DLE;
356 *ptr++ = ACK; 356 *ptr++ = ACK;
@@ -366,7 +366,7 @@ static int gsp_send_ack(struct garmin_data *garmin_data_p, __u8 pkt_id)
366 *ptr++ = DLE; 366 *ptr++ = DLE;
367 367
368 *ptr++ = 0; 368 *ptr++ = 0;
369 *ptr++ = 0xFF & (-cksum); 369 *ptr++ = (-cksum) & 0xFF;
370 *ptr++ = DLE; 370 *ptr++ = DLE;
371 *ptr++ = ETX; 371 *ptr++ = ETX;
372 372
@@ -423,9 +423,9 @@ static int gsp_rec_packet(struct garmin_data *garmin_data_p, int count)
423 n++; 423 n++;
424 } 424 }
425 425
426 if ((0xff & (cksum + *recpkt)) != 0) { 426 if (((cksum + *recpkt) & 0xff) != 0) {
427 dev_dbg(dev, "%s - invalid checksum, expected %02x, got %02x\n", 427 dev_dbg(dev, "%s - invalid checksum, expected %02x, got %02x\n",
428 __func__, 0xff & -cksum, 0xff & *recpkt); 428 __func__, -cksum & 0xff, *recpkt);
429 return -EINVPKT; 429 return -EINVPKT;
430 } 430 }
431 431
@@ -528,7 +528,7 @@ static int gsp_receive(struct garmin_data *garmin_data_p,
528 dev_dbg(dev, "NAK packet complete.\n"); 528 dev_dbg(dev, "NAK packet complete.\n");
529 } else { 529 } else {
530 dev_dbg(dev, "packet complete - id=0x%X.\n", 530 dev_dbg(dev, "packet complete - id=0x%X.\n",
531 0xFF & data); 531 data);
532 gsp_rec_packet(garmin_data_p, size); 532 gsp_rec_packet(garmin_data_p, size);
533 } 533 }
534 534
@@ -636,7 +636,7 @@ static int gsp_send(struct garmin_data *garmin_data_p,
636 636
637 garmin_data_p->outsize = 0; 637 garmin_data_p->outsize = 0;
638 638
639 if (GARMIN_LAYERID_APPL != getLayerId(garmin_data_p->outbuffer)) { 639 if (getLayerId(garmin_data_p->outbuffer) != GARMIN_LAYERID_APPL) {
640 dev_dbg(dev, "not an application packet (%d)\n", 640 dev_dbg(dev, "not an application packet (%d)\n",
641 getLayerId(garmin_data_p->outbuffer)); 641 getLayerId(garmin_data_p->outbuffer));
642 return -1; 642 return -1;
@@ -688,7 +688,7 @@ static int gsp_send(struct garmin_data *garmin_data_p,
688 *dst++ = DLE; 688 *dst++ = DLE;
689 } 689 }
690 690
691 cksum = 0xFF & -cksum; 691 cksum = -cksum & 0xFF;
692 *dst++ = cksum; 692 *dst++ = cksum;
693 if (cksum == DLE) 693 if (cksum == DLE)
694 *dst++ = DLE; 694 *dst++ = DLE;
@@ -860,7 +860,6 @@ static int process_resetdev_request(struct usb_serial_port *port)
860static int garmin_clear(struct garmin_data *garmin_data_p) 860static int garmin_clear(struct garmin_data *garmin_data_p)
861{ 861{
862 unsigned long flags; 862 unsigned long flags;
863 int status = 0;
864 863
865 /* flush all queued data */ 864 /* flush all queued data */
866 pkt_clear(garmin_data_p); 865 pkt_clear(garmin_data_p);
@@ -870,7 +869,7 @@ static int garmin_clear(struct garmin_data *garmin_data_p)
870 garmin_data_p->outsize = 0; 869 garmin_data_p->outsize = 0;
871 spin_unlock_irqrestore(&garmin_data_p->lock, flags); 870 spin_unlock_irqrestore(&garmin_data_p->lock, flags);
872 871
873 return status; 872 return 0;
874} 873}
875 874
876 875
@@ -970,7 +969,7 @@ static void garmin_write_bulk_callback(struct urb *urb)
970 struct garmin_data *garmin_data_p = 969 struct garmin_data *garmin_data_p =
971 usb_get_serial_port_data(port); 970 usb_get_serial_port_data(port);
972 971
973 if (GARMIN_LAYERID_APPL == getLayerId(urb->transfer_buffer)) { 972 if (getLayerId(urb->transfer_buffer) == GARMIN_LAYERID_APPL) {
974 973
975 if (garmin_data_p->mode == MODE_GARMIN_SERIAL) { 974 if (garmin_data_p->mode == MODE_GARMIN_SERIAL) {
976 gsp_send_ack(garmin_data_p, 975 gsp_send_ack(garmin_data_p,
@@ -1025,7 +1024,7 @@ static int garmin_write_bulk(struct usb_serial_port *port,
1025 dismiss_ack ? NULL : port); 1024 dismiss_ack ? NULL : port);
1026 urb->transfer_flags |= URB_ZERO_PACKET; 1025 urb->transfer_flags |= URB_ZERO_PACKET;
1027 1026
1028 if (GARMIN_LAYERID_APPL == getLayerId(buffer)) { 1027 if (getLayerId(buffer) == GARMIN_LAYERID_APPL) {
1029 1028
1030 spin_lock_irqsave(&garmin_data_p->lock, flags); 1029 spin_lock_irqsave(&garmin_data_p->lock, flags);
1031 garmin_data_p->flags |= APP_REQ_SEEN; 1030 garmin_data_p->flags |= APP_REQ_SEEN;
@@ -1077,9 +1076,9 @@ static int garmin_write(struct tty_struct *tty, struct usb_serial_port *port,
1077 pktsiz = getDataLength(garmin_data_p->privpkt); 1076 pktsiz = getDataLength(garmin_data_p->privpkt);
1078 pktid = getPacketId(garmin_data_p->privpkt); 1077 pktid = getPacketId(garmin_data_p->privpkt);
1079 1078
1080 if (count == (GARMIN_PKTHDR_LENGTH+pktsiz) 1079 if (count == (GARMIN_PKTHDR_LENGTH + pktsiz) &&
1081 && GARMIN_LAYERID_PRIVATE == 1080 getLayerId(garmin_data_p->privpkt) ==
1082 getLayerId(garmin_data_p->privpkt)) { 1081 GARMIN_LAYERID_PRIVATE) {
1083 1082
1084 dev_dbg(dev, "%s - processing private request %d\n", 1083 dev_dbg(dev, "%s - processing private request %d\n",
1085 __func__, pktid); 1084 __func__, pktid);
@@ -1192,7 +1191,7 @@ static void garmin_read_bulk_callback(struct urb *urb)
1192 garmin_read_process(garmin_data_p, data, urb->actual_length, 1); 1191 garmin_read_process(garmin_data_p, data, urb->actual_length, 1);
1193 1192
1194 if (urb->actual_length == 0 && 1193 if (urb->actual_length == 0 &&
1195 0 != (garmin_data_p->flags & FLAGS_BULK_IN_RESTART)) { 1194 (garmin_data_p->flags & FLAGS_BULK_IN_RESTART) != 0) {
1196 spin_lock_irqsave(&garmin_data_p->lock, flags); 1195 spin_lock_irqsave(&garmin_data_p->lock, flags);
1197 garmin_data_p->flags &= ~FLAGS_BULK_IN_RESTART; 1196 garmin_data_p->flags &= ~FLAGS_BULK_IN_RESTART;
1198 spin_unlock_irqrestore(&garmin_data_p->lock, flags); 1197 spin_unlock_irqrestore(&garmin_data_p->lock, flags);
@@ -1203,7 +1202,7 @@ static void garmin_read_bulk_callback(struct urb *urb)
1203 __func__, retval); 1202 __func__, retval);
1204 } else if (urb->actual_length > 0) { 1203 } else if (urb->actual_length > 0) {
1205 /* Continue trying to read until nothing more is received */ 1204 /* Continue trying to read until nothing more is received */
1206 if (0 == (garmin_data_p->flags & FLAGS_THROTTLED)) { 1205 if ((garmin_data_p->flags & FLAGS_THROTTLED) == 0) {
1207 retval = usb_submit_urb(port->read_urb, GFP_ATOMIC); 1206 retval = usb_submit_urb(port->read_urb, GFP_ATOMIC);
1208 if (retval) 1207 if (retval)
1209 dev_err(&port->dev, 1208 dev_err(&port->dev,
@@ -1249,12 +1248,12 @@ static void garmin_read_int_callback(struct urb *urb)
1249 urb->transfer_buffer); 1248 urb->transfer_buffer);
1250 1249
1251 if (urb->actual_length == sizeof(GARMIN_BULK_IN_AVAIL_REPLY) && 1250 if (urb->actual_length == sizeof(GARMIN_BULK_IN_AVAIL_REPLY) &&
1252 0 == memcmp(data, GARMIN_BULK_IN_AVAIL_REPLY, 1251 memcmp(data, GARMIN_BULK_IN_AVAIL_REPLY,
1253 sizeof(GARMIN_BULK_IN_AVAIL_REPLY))) { 1252 sizeof(GARMIN_BULK_IN_AVAIL_REPLY)) == 0) {
1254 1253
1255 dev_dbg(&port->dev, "%s - bulk data available.\n", __func__); 1254 dev_dbg(&port->dev, "%s - bulk data available.\n", __func__);
1256 1255
1257 if (0 == (garmin_data_p->flags & FLAGS_BULK_IN_ACTIVE)) { 1256 if ((garmin_data_p->flags & FLAGS_BULK_IN_ACTIVE) == 0) {
1258 1257
1259 /* bulk data available */ 1258 /* bulk data available */
1260 retval = usb_submit_urb(port->read_urb, GFP_ATOMIC); 1259 retval = usb_submit_urb(port->read_urb, GFP_ATOMIC);
@@ -1276,8 +1275,8 @@ static void garmin_read_int_callback(struct urb *urb)
1276 } 1275 }
1277 1276
1278 } else if (urb->actual_length == (4+sizeof(GARMIN_START_SESSION_REPLY)) 1277 } else if (urb->actual_length == (4+sizeof(GARMIN_START_SESSION_REPLY))
1279 && 0 == memcmp(data, GARMIN_START_SESSION_REPLY, 1278 && memcmp(data, GARMIN_START_SESSION_REPLY,
1280 sizeof(GARMIN_START_SESSION_REPLY))) { 1279 sizeof(GARMIN_START_SESSION_REPLY)) == 0) {
1281 1280
1282 spin_lock_irqsave(&garmin_data_p->lock, flags); 1281 spin_lock_irqsave(&garmin_data_p->lock, flags);
1283 garmin_data_p->flags |= FLAGS_SESSION_REPLY1_SEEN; 1282 garmin_data_p->flags |= FLAGS_SESSION_REPLY1_SEEN;
@@ -1356,7 +1355,7 @@ static void garmin_unthrottle(struct tty_struct *tty)
1356 if (garmin_data_p->mode == MODE_NATIVE) 1355 if (garmin_data_p->mode == MODE_NATIVE)
1357 garmin_flush_queue(garmin_data_p); 1356 garmin_flush_queue(garmin_data_p);
1358 1357
1359 if (0 != (garmin_data_p->flags & FLAGS_BULK_IN_ACTIVE)) { 1358 if ((garmin_data_p->flags & FLAGS_BULK_IN_ACTIVE) != 0) {
1360 status = usb_submit_urb(port->read_urb, GFP_KERNEL); 1359 status = usb_submit_urb(port->read_urb, GFP_KERNEL);
1361 if (status) 1360 if (status)
1362 dev_err(&port->dev, 1361 dev_err(&port->dev,
diff --git a/drivers/usb/serial/iuu_phoenix.c b/drivers/usb/serial/iuu_phoenix.c
index 5ad4a0fb4b26..344b4eea4bd5 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)
360 int result; 360 int result;
361 char *buf_ptr = port->write_urb->transfer_buffer; 361 char *buf_ptr = port->write_urb->transfer_buffer;
362 *buf_ptr++ = IUU_SET_LED; 362 *buf_ptr++ = IUU_SET_LED;
363 if (xmas == 1) { 363 if (xmas) {
364 get_random_bytes(buf_ptr, 6); 364 get_random_bytes(buf_ptr, 6);
365 *(buf_ptr+7) = 1; 365 *(buf_ptr+7) = 1;
366 } else { 366 } else {
@@ -380,7 +380,7 @@ static void iuu_led_activity_off(struct urb *urb)
380 struct usb_serial_port *port = urb->context; 380 struct usb_serial_port *port = urb->context;
381 int result; 381 int result;
382 char *buf_ptr = port->write_urb->transfer_buffer; 382 char *buf_ptr = port->write_urb->transfer_buffer;
383 if (xmas == 1) { 383 if (xmas) {
384 iuu_rxcmd(urb); 384 iuu_rxcmd(urb);
385 return; 385 return;
386 } else { 386 } else {
diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c
index e07b15ed5814..b6bd8e4a6486 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,
1963 if (d_details->product_id == keyspan_usa49wg_product_id) { 1963 if (d_details->product_id == keyspan_usa49wg_product_id) {
1964 dr = (void *)(s_priv->ctrl_buf); 1964 dr = (void *)(s_priv->ctrl_buf);
1965 dr->bRequestType = USB_TYPE_VENDOR | USB_DIR_OUT; 1965 dr->bRequestType = USB_TYPE_VENDOR | USB_DIR_OUT;
1966 dr->bRequest = 0xB0; /* 49wg control message */; 1966 dr->bRequest = 0xB0; /* 49wg control message */
1967 dr->wValue = 0; 1967 dr->wValue = 0;
1968 dr->wIndex = 0; 1968 dr->wIndex = 0;
1969 dr->wLength = cpu_to_le16(sizeof(msg)); 1969 dr->wLength = cpu_to_le16(sizeof(msg));
diff --git a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c
index e020ad28a00c..fc5d3a791e08 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,
472 /* maybe this should be simulated by sending read 472 /* maybe this should be simulated by sending read
473 * disable and read enable messages? 473 * disable and read enable messages?
474 */ 474 */
475 ;
476#if 0 475#if 0
477 priv->control_state &= ~(TIOCM_DTR | TIOCM_RTS); 476 priv->control_state &= ~(TIOCM_DTR | TIOCM_RTS);
478 mct_u232_set_modem_ctrl(serial, priv->control_state); 477 mct_u232_set_modem_ctrl(serial, priv->control_state);
@@ -527,7 +526,6 @@ static void klsi_105_set_termios(struct tty_struct *tty,
527 526
528 mct_u232_set_line_ctrl(serial, priv->last_lcr); 527 mct_u232_set_line_ctrl(serial, priv->last_lcr);
529#endif 528#endif
530 ;
531 } 529 }
532 /* 530 /*
533 * Set flow control: well, I do not really now how to handle DTR/RTS. 531 * 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,
546 priv->control_state &= ~(TIOCM_DTR | TIOCM_RTS); 544 priv->control_state &= ~(TIOCM_DTR | TIOCM_RTS);
547 mct_u232_set_modem_ctrl(serial, priv->control_state); 545 mct_u232_set_modem_ctrl(serial, priv->control_state);
548#endif 546#endif
549 ;
550 } 547 }
551 memcpy(cfg, &priv->cfg, sizeof(*cfg)); 548 memcpy(cfg, &priv->cfg, sizeof(*cfg));
552 spin_unlock_irqrestore(&priv->lock, flags); 549 spin_unlock_irqrestore(&priv->lock, flags);
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
index 02ea975754f5..ed378fb232e7 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,
1842 Data = 0x0c; 1842 Data = 0x0c;
1843 mos7840_set_uart_reg(port, INTERRUPT_ENABLE_REGISTER, Data); 1843 mos7840_set_uart_reg(port, INTERRUPT_ENABLE_REGISTER, Data);
1844 1844
1845 if (mos7840_port->read_urb_busy == false) { 1845 if (!mos7840_port->read_urb_busy) {
1846 mos7840_port->read_urb_busy = true; 1846 mos7840_port->read_urb_busy = true;
1847 status = usb_submit_urb(mos7840_port->read_urb, GFP_KERNEL); 1847 status = usb_submit_urb(mos7840_port->read_urb, GFP_KERNEL);
1848 if (status) { 1848 if (status) {
@@ -1906,7 +1906,7 @@ static void mos7840_set_termios(struct tty_struct *tty,
1906 return; 1906 return;
1907 } 1907 }
1908 1908
1909 if (mos7840_port->read_urb_busy == false) { 1909 if (!mos7840_port->read_urb_busy) {
1910 mos7840_port->read_urb_busy = true; 1910 mos7840_port->read_urb_busy = true;
1911 status = usb_submit_urb(mos7840_port->read_urb, GFP_KERNEL); 1911 status = usb_submit_urb(mos7840_port->read_urb, GFP_KERNEL);
1912 if (status) { 1912 if (status) {
diff --git a/drivers/usb/serial/quatech2.c b/drivers/usb/serial/quatech2.c
index 504f5bff79c0..2df8ad5ede89 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,
973 973
974 data = write_urb->transfer_buffer; 974 data = write_urb->transfer_buffer;
975 spin_lock_irqsave(&port_priv->urb_lock, flags); 975 spin_lock_irqsave(&port_priv->urb_lock, flags);
976 if (port_priv->urb_in_use == true) { 976 if (port_priv->urb_in_use) {
977 dev_err(&port->dev, "qt2_write - urb is in use\n"); 977 dev_err(&port->dev, "qt2_write - urb is in use\n");
978 goto write_out; 978 goto write_out;
979 } 979 }
diff --git a/drivers/usb/serial/safe_serial.c b/drivers/usb/serial/safe_serial.c
index b2dff0f14743..93c6c9b08daa 100644
--- a/drivers/usb/serial/safe_serial.c
+++ b/drivers/usb/serial/safe_serial.c
@@ -76,13 +76,8 @@
76#include <linux/usb.h> 76#include <linux/usb.h>
77#include <linux/usb/serial.h> 77#include <linux/usb/serial.h>
78 78
79 79static bool safe = true;
80#ifndef CONFIG_USB_SERIAL_SAFE_PADDED 80static bool padded = IS_ENABLED(CONFIG_USB_SERIAL_SAFE_PADDED);
81#define CONFIG_USB_SERIAL_SAFE_PADDED 0
82#endif
83
84static bool safe = 1;
85static bool padded = CONFIG_USB_SERIAL_SAFE_PADDED;
86 81
87#define DRIVER_AUTHOR "sl@lineo.com, tbr@lineo.com, Johan Hovold <jhovold@gmail.com>" 82#define DRIVER_AUTHOR "sl@lineo.com, tbr@lineo.com, Johan Hovold <jhovold@gmail.com>"
88#define DRIVER_DESC "USB Safe Encapsulated Serial" 83#define DRIVER_DESC "USB Safe Encapsulated Serial"
@@ -278,7 +273,7 @@ static int safe_startup(struct usb_serial *serial)
278 case LINEO_SAFESERIAL_CRC: 273 case LINEO_SAFESERIAL_CRC:
279 break; 274 break;
280 case LINEO_SAFESERIAL_CRC_PADDED: 275 case LINEO_SAFESERIAL_CRC_PADDED:
281 padded = 1; 276 padded = true;
282 break; 277 break;
283 default: 278 default:
284 return -EINVAL; 279 return -EINVAL;