aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/cypress_m8.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-10-01 16:23:01 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-10-01 16:23:01 -0400
commitd9a807461fc8cc0d6ba589ea0730d139122af012 (patch)
tree9d8c7a044659d821748dd40718a22557c04e4299 /drivers/usb/serial/cypress_m8.c
parent3498d13b8090c0b0ef911409fbc503a7c4cca6ef (diff)
parent70c048a238c780c226eb4b115ebaa908cb3b34ec (diff)
Merge tag 'usb-3.6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
Pull USB changes from Greg Kroah-Hartman: "Here is the big USB pull request for 3.7-rc1 There are lots of gadget driver changes (including copying a bunch of files into the drivers/staging/ccg/ directory so that the other gadget drivers can be fixed up properly without breaking that driver), and we remove the old obsolete ub.c driver from the tree. There are also the usual XHCI set of updates, and other various driver changes and updates. We also are trying hard to remove the old dbg() macro, but the final bits of that removal will be coming in through the networking tree before we can delete it for good. All of these patches have been in the linux-next tree. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>" Fix up several annoying - but fairly mindless - conflicts due to the termios structure having moved into the tty device, and often clashing with dbg -> dev_dbg conversion. * tag 'usb-3.6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (339 commits) USB: ezusb: move ezusb.c from drivers/usb/serial to drivers/usb/misc USB: uas: fix gcc warning USB: uas: fix locking USB: Fix race condition when removing host controllers USB: uas: add locking USB: uas: fix abort USB: uas: remove aborted field, replace with status bit. USB: uas: fix task management USB: uas: keep track of command urbs xhci: Intel Panther Point BEI quirk. powerpc/usb: remove checking PHY_CLK_VALID for UTMI PHY USB: ftdi_sio: add TIAO USB Multi-Protocol Adapter (TUMPA) support Revert "usb : Add sysfs files to control port power." USB: serial: remove vizzini driver usb: host: xhci: Fix Null pointer dereferencing with 71c731a for non-x86 systems Increase XHCI suspend timeout to 16ms USB: ohci-at91: fix null pointer in ohci_hcd_at91_overcurrent_irq USB: sierra_ms: don't keep unused variable fsl/usb: Add support for USB controller version 2.4 USB: qcaux: add Pantech vendor class match ...
Diffstat (limited to 'drivers/usb/serial/cypress_m8.c')
-rw-r--r--drivers/usb/serial/cypress_m8.c157
1 files changed, 76 insertions, 81 deletions
diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c
index be34f153e56..1befce21e17 100644
--- a/drivers/usb/serial/cypress_m8.c
+++ b/drivers/usb/serial/cypress_m8.c
@@ -46,7 +46,6 @@
46#include "cypress_m8.h" 46#include "cypress_m8.h"
47 47
48 48
49static bool debug;
50static bool stats; 49static bool stats;
51static int interval; 50static int interval;
52static bool unstable_bauds; 51static bool unstable_bauds;
@@ -263,8 +262,9 @@ static int analyze_baud_rate(struct usb_serial_port *port, speed_t new_rate)
263 * safest speed for a part like that. 262 * safest speed for a part like that.
264 */ 263 */
265 if (new_rate > 4800) { 264 if (new_rate > 4800) {
266 dbg("%s - failed setting baud rate, device incapable " 265 dev_dbg(&port->dev,
267 "speed %d", __func__, new_rate); 266 "%s - failed setting baud rate, device incapable speed %d\n",
267 __func__, new_rate);
268 return -1; 268 return -1;
269 } 269 }
270 } 270 }
@@ -274,8 +274,9 @@ static int analyze_baud_rate(struct usb_serial_port *port, speed_t new_rate)
274 /* 300 and 600 baud rates are supported under 274 /* 300 and 600 baud rates are supported under
275 * the generic firmware, but are not used with 275 * the generic firmware, but are not used with
276 * NMEA and SiRF protocols */ 276 * NMEA and SiRF protocols */
277 dbg("%s - failed setting baud rate, unsupported speed " 277 dev_dbg(&port->dev,
278 "of %d on Earthmate GPS", __func__, new_rate); 278 "%s - failed setting baud rate, unsupported speed of %d on Earthmate GPS",
279 __func__, new_rate);
279 return -1; 280 return -1;
280 } 281 }
281 break; 282 break;
@@ -294,6 +295,7 @@ static int cypress_serial_control(struct tty_struct *tty,
294{ 295{
295 int new_baudrate = 0, retval = 0, tries = 0; 296 int new_baudrate = 0, retval = 0, tries = 0;
296 struct cypress_private *priv; 297 struct cypress_private *priv;
298 struct device *dev = &port->dev;
297 u8 *feature_buffer; 299 u8 *feature_buffer;
298 const unsigned int feature_len = 5; 300 const unsigned int feature_len = 5;
299 unsigned long flags; 301 unsigned long flags;
@@ -312,16 +314,16 @@ static int cypress_serial_control(struct tty_struct *tty,
312 /* 0 means 'Hang up' so doesn't change the true bit rate */ 314 /* 0 means 'Hang up' so doesn't change the true bit rate */
313 new_baudrate = priv->baud_rate; 315 new_baudrate = priv->baud_rate;
314 if (baud_rate && baud_rate != priv->baud_rate) { 316 if (baud_rate && baud_rate != priv->baud_rate) {
315 dbg("%s - baud rate is changing", __func__); 317 dev_dbg(dev, "%s - baud rate is changing\n", __func__);
316 retval = analyze_baud_rate(port, baud_rate); 318 retval = analyze_baud_rate(port, baud_rate);
317 if (retval >= 0) { 319 if (retval >= 0) {
318 new_baudrate = retval; 320 new_baudrate = retval;
319 dbg("%s - New baud rate set to %d", 321 dev_dbg(dev, "%s - New baud rate set to %d\n",
320 __func__, new_baudrate); 322 __func__, new_baudrate);
321 } 323 }
322 } 324 }
323 dbg("%s - baud rate is being sent as %d", 325 dev_dbg(dev, "%s - baud rate is being sent as %d\n", __func__,
324 __func__, new_baudrate); 326 new_baudrate);
325 327
326 /* fill the feature_buffer with new configuration */ 328 /* fill the feature_buffer with new configuration */
327 put_unaligned_le32(new_baudrate, feature_buffer); 329 put_unaligned_le32(new_baudrate, feature_buffer);
@@ -333,9 +335,8 @@ static int cypress_serial_control(struct tty_struct *tty,
333 /* 1 bit gap */ 335 /* 1 bit gap */
334 feature_buffer[4] |= (reset << 7); /* assign reset at end of byte, 1 bit space */ 336 feature_buffer[4] |= (reset << 7); /* assign reset at end of byte, 1 bit space */
335 337
336 dbg("%s - device is being sent this feature report:", 338 dev_dbg(dev, "%s - device is being sent this feature report:\n", __func__);
337 __func__); 339 dev_dbg(dev, "%s - %02X - %02X - %02X - %02X - %02X\n", __func__,
338 dbg("%s - %02X - %02X - %02X - %02X - %02X", __func__,
339 feature_buffer[0], feature_buffer[1], 340 feature_buffer[0], feature_buffer[1],
340 feature_buffer[2], feature_buffer[3], 341 feature_buffer[2], feature_buffer[3],
341 feature_buffer[4]); 342 feature_buffer[4]);
@@ -355,8 +356,8 @@ static int cypress_serial_control(struct tty_struct *tty,
355 retval != -ENODEV); 356 retval != -ENODEV);
356 357
357 if (retval != feature_len) { 358 if (retval != feature_len) {
358 dev_err(&port->dev, "%s - failed sending serial " 359 dev_err(dev, "%s - failed sending serial line settings - %d\n",
359 "line settings - %d\n", __func__, retval); 360 __func__, retval);
360 cypress_set_dead(port); 361 cypress_set_dead(port);
361 } else { 362 } else {
362 spin_lock_irqsave(&priv->lock, flags); 363 spin_lock_irqsave(&priv->lock, flags);
@@ -377,7 +378,7 @@ static int cypress_serial_control(struct tty_struct *tty,
377 retval = -ENOTTY; 378 retval = -ENOTTY;
378 goto out; 379 goto out;
379 } 380 }
380 dbg("%s - retreiving serial line settings", __func__); 381 dev_dbg(dev, "%s - retreiving serial line settings\n", __func__);
381 do { 382 do {
382 retval = usb_control_msg(port->serial->dev, 383 retval = usb_control_msg(port->serial->dev,
383 usb_rcvctrlpipe(port->serial->dev, 0), 384 usb_rcvctrlpipe(port->serial->dev, 0),
@@ -392,8 +393,8 @@ static int cypress_serial_control(struct tty_struct *tty,
392 && retval != -ENODEV); 393 && retval != -ENODEV);
393 394
394 if (retval != feature_len) { 395 if (retval != feature_len) {
395 dev_err(&port->dev, "%s - failed to retrieve serial " 396 dev_err(dev, "%s - failed to retrieve serial line settings - %d\n",
396 "line settings - %d\n", __func__, retval); 397 __func__, retval);
397 cypress_set_dead(port); 398 cypress_set_dead(port);
398 goto out; 399 goto out;
399 } else { 400 } else {
@@ -474,14 +475,14 @@ static int generic_startup(struct usb_serial *serial)
474 if (interval > 0) { 475 if (interval > 0) {
475 priv->write_urb_interval = interval; 476 priv->write_urb_interval = interval;
476 priv->read_urb_interval = interval; 477 priv->read_urb_interval = interval;
477 dbg("%s - port %d read & write intervals forced to %d", 478 dev_dbg(&port->dev, "%s - read & write intervals forced to %d\n",
478 __func__, port->number, interval); 479 __func__, interval);
479 } else { 480 } else {
480 priv->write_urb_interval = port->interrupt_out_urb->interval; 481 priv->write_urb_interval = port->interrupt_out_urb->interval;
481 priv->read_urb_interval = port->interrupt_in_urb->interval; 482 priv->read_urb_interval = port->interrupt_in_urb->interval;
482 dbg("%s - port %d intervals: read=%d write=%d", 483 dev_dbg(&port->dev, "%s - intervals: read=%d write=%d\n",
483 __func__, port->number, 484 __func__, priv->read_urb_interval,
484 priv->read_urb_interval, priv->write_urb_interval); 485 priv->write_urb_interval);
485 } 486 }
486 usb_set_serial_port_data(port, priv); 487 usb_set_serial_port_data(port, priv);
487 488
@@ -495,8 +496,7 @@ static int cypress_earthmate_startup(struct usb_serial *serial)
495 struct usb_serial_port *port = serial->port[0]; 496 struct usb_serial_port *port = serial->port[0];
496 497
497 if (generic_startup(serial)) { 498 if (generic_startup(serial)) {
498 dbg("%s - Failed setting up port %d", __func__, 499 dev_dbg(&port->dev, "%s - Failed setting up port\n", __func__);
499 port->number);
500 return 1; 500 return 1;
501 } 501 }
502 502
@@ -511,8 +511,9 @@ static int cypress_earthmate_startup(struct usb_serial *serial)
511 handle GET_CONFIG requests; everything they've 511 handle GET_CONFIG requests; everything they've
512 produced since that time crashes if this command is 512 produced since that time crashes if this command is
513 attempted :-( */ 513 attempted :-( */
514 dbg("%s - Marking this device as unsafe for GET_CONFIG " 514 dev_dbg(&port->dev,
515 "commands", __func__); 515 "%s - Marking this device as unsafe for GET_CONFIG commands\n",
516 __func__);
516 priv->get_cfg_unsafe = !0; 517 priv->get_cfg_unsafe = !0;
517 } 518 }
518 519
@@ -523,14 +524,14 @@ static int cypress_earthmate_startup(struct usb_serial *serial)
523static int cypress_hidcom_startup(struct usb_serial *serial) 524static int cypress_hidcom_startup(struct usb_serial *serial)
524{ 525{
525 struct cypress_private *priv; 526 struct cypress_private *priv;
527 struct usb_serial_port *port = serial->port[0];
526 528
527 if (generic_startup(serial)) { 529 if (generic_startup(serial)) {
528 dbg("%s - Failed setting up port %d", __func__, 530 dev_dbg(&port->dev, "%s - Failed setting up port\n", __func__);
529 serial->port[0]->number);
530 return 1; 531 return 1;
531 } 532 }
532 533
533 priv = usb_get_serial_port_data(serial->port[0]); 534 priv = usb_get_serial_port_data(port);
534 priv->chiptype = CT_CYPHIDCOM; 535 priv->chiptype = CT_CYPHIDCOM;
535 536
536 return 0; 537 return 0;
@@ -540,14 +541,14 @@ static int cypress_hidcom_startup(struct usb_serial *serial)
540static int cypress_ca42v2_startup(struct usb_serial *serial) 541static int cypress_ca42v2_startup(struct usb_serial *serial)
541{ 542{
542 struct cypress_private *priv; 543 struct cypress_private *priv;
544 struct usb_serial_port *port = serial->port[0];
543 545
544 if (generic_startup(serial)) { 546 if (generic_startup(serial)) {
545 dbg("%s - Failed setting up port %d", __func__, 547 dev_dbg(&port->dev, "%s - Failed setting up port\n", __func__);
546 serial->port[0]->number);
547 return 1; 548 return 1;
548 } 549 }
549 550
550 priv = usb_get_serial_port_data(serial->port[0]); 551 priv = usb_get_serial_port_data(port);
551 priv->chiptype = CT_CA42V2; 552 priv->chiptype = CT_CA42V2;
552 553
553 return 0; 554 return 0;
@@ -649,7 +650,7 @@ static void cypress_close(struct usb_serial_port *port)
649 kfifo_reset_out(&priv->write_fifo); 650 kfifo_reset_out(&priv->write_fifo);
650 spin_unlock_irqrestore(&priv->lock, flags); 651 spin_unlock_irqrestore(&priv->lock, flags);
651 652
652 dbg("%s - stopping urbs", __func__); 653 dev_dbg(&port->dev, "%s - stopping urbs\n", __func__);
653 usb_kill_urb(port->interrupt_in_urb); 654 usb_kill_urb(port->interrupt_in_urb);
654 usb_kill_urb(port->interrupt_out_urb); 655 usb_kill_urb(port->interrupt_out_urb);
655 656
@@ -665,7 +666,7 @@ static int cypress_write(struct tty_struct *tty, struct usb_serial_port *port,
665{ 666{
666 struct cypress_private *priv = usb_get_serial_port_data(port); 667 struct cypress_private *priv = usb_get_serial_port_data(port);
667 668
668 dbg("%s - port %d, %d bytes", __func__, port->number, count); 669 dev_dbg(&port->dev, "%s - port %d, %d bytes\n", __func__, port->number, count);
669 670
670 /* line control commands, which need to be executed immediately, 671 /* line control commands, which need to be executed immediately,
671 are not put into the buffer for obvious reasons. 672 are not put into the buffer for obvious reasons.
@@ -691,17 +692,18 @@ static void cypress_send(struct usb_serial_port *port)
691{ 692{
692 int count = 0, result, offset, actual_size; 693 int count = 0, result, offset, actual_size;
693 struct cypress_private *priv = usb_get_serial_port_data(port); 694 struct cypress_private *priv = usb_get_serial_port_data(port);
695 struct device *dev = &port->dev;
694 unsigned long flags; 696 unsigned long flags;
695 697
696 if (!priv->comm_is_ok) 698 if (!priv->comm_is_ok)
697 return; 699 return;
698 700
699 dbg("%s - interrupt out size is %d", __func__, 701 dev_dbg(dev, "%s - interrupt out size is %d\n", __func__,
700 port->interrupt_out_size); 702 port->interrupt_out_size);
701 703
702 spin_lock_irqsave(&priv->lock, flags); 704 spin_lock_irqsave(&priv->lock, flags);
703 if (priv->write_urb_in_use) { 705 if (priv->write_urb_in_use) {
704 dbg("%s - can't write, urb in use", __func__); 706 dev_dbg(dev, "%s - can't write, urb in use\n", __func__);
705 spin_unlock_irqrestore(&priv->lock, flags); 707 spin_unlock_irqrestore(&priv->lock, flags);
706 return; 708 return;
707 } 709 }
@@ -731,7 +733,7 @@ static void cypress_send(struct usb_serial_port *port)
731 733
732 if (priv->cmd_ctrl) { 734 if (priv->cmd_ctrl) {
733 priv->cmd_count++; 735 priv->cmd_count++;
734 dbg("%s - line control command being issued", __func__); 736 dev_dbg(dev, "%s - line control command being issued\n", __func__);
735 spin_unlock_irqrestore(&priv->lock, flags); 737 spin_unlock_irqrestore(&priv->lock, flags);
736 goto send; 738 goto send;
737 } else 739 } else
@@ -753,7 +755,7 @@ static void cypress_send(struct usb_serial_port *port)
753 port->interrupt_out_buffer[0] |= count; 755 port->interrupt_out_buffer[0] |= count;
754 } 756 }
755 757
756 dbg("%s - count is %d", __func__, count); 758 dev_dbg(dev, "%s - count is %d\n", __func__, count);
757 759
758send: 760send:
759 spin_lock_irqsave(&priv->lock, flags); 761 spin_lock_irqsave(&priv->lock, flags);
@@ -766,9 +768,8 @@ send:
766 actual_size = count + 768 actual_size = count +
767 (priv->pkt_fmt == packet_format_1 ? 2 : 1); 769 (priv->pkt_fmt == packet_format_1 ? 2 : 1);
768 770
769 usb_serial_debug_data(debug, &port->dev, __func__, 771 usb_serial_debug_data(dev, __func__, port->interrupt_out_size,
770 port->interrupt_out_size, 772 port->interrupt_out_urb->transfer_buffer);
771 port->interrupt_out_urb->transfer_buffer);
772 773
773 usb_fill_int_urb(port->interrupt_out_urb, port->serial->dev, 774 usb_fill_int_urb(port->interrupt_out_urb, port->serial->dev,
774 usb_sndintpipe(port->serial->dev, port->interrupt_out_endpointAddress), 775 usb_sndintpipe(port->serial->dev, port->interrupt_out_endpointAddress),
@@ -807,7 +808,7 @@ static int cypress_write_room(struct tty_struct *tty)
807 room = kfifo_avail(&priv->write_fifo); 808 room = kfifo_avail(&priv->write_fifo);
808 spin_unlock_irqrestore(&priv->lock, flags); 809 spin_unlock_irqrestore(&priv->lock, flags);
809 810
810 dbg("%s - returns %d", __func__, room); 811 dev_dbg(&port->dev, "%s - returns %d\n", __func__, room);
811 return room; 812 return room;
812} 813}
813 814
@@ -832,7 +833,7 @@ static int cypress_tiocmget(struct tty_struct *tty)
832 | ((status & UART_RI) ? TIOCM_RI : 0) 833 | ((status & UART_RI) ? TIOCM_RI : 0)
833 | ((status & UART_CD) ? TIOCM_CD : 0); 834 | ((status & UART_CD) ? TIOCM_CD : 0);
834 835
835 dbg("%s - result = %x", __func__, result); 836 dev_dbg(&port->dev, "%s - result = %x\n", __func__, result);
836 837
837 return result; 838 return result;
838} 839}
@@ -867,7 +868,7 @@ static int cypress_ioctl(struct tty_struct *tty,
867 struct usb_serial_port *port = tty->driver_data; 868 struct usb_serial_port *port = tty->driver_data;
868 struct cypress_private *priv = usb_get_serial_port_data(port); 869 struct cypress_private *priv = usb_get_serial_port_data(port);
869 870
870 dbg("%s - port %d, cmd 0x%.4x", __func__, port->number, cmd); 871 dev_dbg(&port->dev, "%s - port %d, cmd 0x%.4x\n", __func__, port->number, cmd);
871 872
872 switch (cmd) { 873 switch (cmd) {
873 /* This code comes from drivers/char/serial.c and ftdi_sio.c */ 874 /* This code comes from drivers/char/serial.c and ftdi_sio.c */
@@ -902,7 +903,7 @@ static int cypress_ioctl(struct tty_struct *tty,
902 default: 903 default:
903 break; 904 break;
904 } 905 }
905 dbg("%s - arg not supported - it was 0x%04x - check include/asm/ioctls.h", __func__, cmd); 906 dev_dbg(&port->dev, "%s - arg not supported - it was 0x%04x - check include/asm/ioctls.h\n", __func__, cmd);
906 return -ENOIOCTLCMD; 907 return -ENOIOCTLCMD;
907} /* cypress_ioctl */ 908} /* cypress_ioctl */
908 909
@@ -911,6 +912,7 @@ static void cypress_set_termios(struct tty_struct *tty,
911 struct usb_serial_port *port, struct ktermios *old_termios) 912 struct usb_serial_port *port, struct ktermios *old_termios)
912{ 913{
913 struct cypress_private *priv = usb_get_serial_port_data(port); 914 struct cypress_private *priv = usb_get_serial_port_data(port);
915 struct device *dev = &port->dev;
914 int data_bits, stop_bits, parity_type, parity_enable; 916 int data_bits, stop_bits, parity_type, parity_enable;
915 unsigned cflag, iflag; 917 unsigned cflag, iflag;
916 unsigned long flags; 918 unsigned long flags;
@@ -984,23 +986,21 @@ static void cypress_set_termios(struct tty_struct *tty,
984 data_bits = 3; 986 data_bits = 3;
985 break; 987 break;
986 default: 988 default:
987 dev_err(&port->dev, "%s - CSIZE was set, but not CS5-CS8\n", 989 dev_err(dev, "%s - CSIZE was set, but not CS5-CS8\n", __func__);
988 __func__);
989 data_bits = 3; 990 data_bits = 3;
990 } 991 }
991 spin_lock_irqsave(&priv->lock, flags); 992 spin_lock_irqsave(&priv->lock, flags);
992 oldlines = priv->line_control; 993 oldlines = priv->line_control;
993 if ((cflag & CBAUD) == B0) { 994 if ((cflag & CBAUD) == B0) {
994 /* drop dtr and rts */ 995 /* drop dtr and rts */
995 dbg("%s - dropping the lines, baud rate 0bps", __func__); 996 dev_dbg(dev, "%s - dropping the lines, baud rate 0bps\n", __func__);
996 priv->line_control &= ~(CONTROL_DTR | CONTROL_RTS); 997 priv->line_control &= ~(CONTROL_DTR | CONTROL_RTS);
997 } else 998 } else
998 priv->line_control = (CONTROL_DTR | CONTROL_RTS); 999 priv->line_control = (CONTROL_DTR | CONTROL_RTS);
999 spin_unlock_irqrestore(&priv->lock, flags); 1000 spin_unlock_irqrestore(&priv->lock, flags);
1000 1001
1001 dbg("%s - sending %d stop_bits, %d parity_enable, %d parity_type, " 1002 dev_dbg(dev, "%s - sending %d stop_bits, %d parity_enable, %d parity_type, %d data_bits (+5)\n",
1002 "%d data_bits (+5)", __func__, stop_bits, 1003 __func__, stop_bits, parity_enable, parity_type, data_bits);
1003 parity_enable, parity_type, data_bits);
1004 1004
1005 cypress_serial_control(tty, port, tty_get_baud_rate(tty), 1005 cypress_serial_control(tty, port, tty_get_baud_rate(tty),
1006 data_bits, stop_bits, 1006 data_bits, stop_bits,
@@ -1017,8 +1017,7 @@ static void cypress_set_termios(struct tty_struct *tty,
1017 1017
1018 spin_lock_irqsave(&priv->lock, flags); 1018 spin_lock_irqsave(&priv->lock, flags);
1019 if (priv->chiptype == CT_EARTHMATE && priv->baud_rate == 4800) { 1019 if (priv->chiptype == CT_EARTHMATE && priv->baud_rate == 4800) {
1020 dbg("Using custom termios settings for a baud rate of " 1020 dev_dbg(dev, "Using custom termios settings for a baud rate of 4800bps.\n");
1021 "4800bps.");
1022 /* define custom termios settings for NMEA protocol */ 1021 /* define custom termios settings for NMEA protocol */
1023 1022
1024 tty->termios.c_iflag /* input modes - */ 1023 tty->termios.c_iflag /* input modes - */
@@ -1067,7 +1066,7 @@ static int cypress_chars_in_buffer(struct tty_struct *tty)
1067 chars = kfifo_len(&priv->write_fifo); 1066 chars = kfifo_len(&priv->write_fifo);
1068 spin_unlock_irqrestore(&priv->lock, flags); 1067 spin_unlock_irqrestore(&priv->lock, flags);
1069 1068
1070 dbg("%s - returns %d", __func__, chars); 1069 dev_dbg(&port->dev, "%s - returns %d\n", __func__, chars);
1071 return chars; 1070 return chars;
1072} 1071}
1073 1072
@@ -1112,6 +1111,7 @@ static void cypress_read_int_callback(struct urb *urb)
1112{ 1111{
1113 struct usb_serial_port *port = urb->context; 1112 struct usb_serial_port *port = urb->context;
1114 struct cypress_private *priv = usb_get_serial_port_data(port); 1113 struct cypress_private *priv = usb_get_serial_port_data(port);
1114 struct device *dev = &urb->dev->dev;
1115 struct tty_struct *tty; 1115 struct tty_struct *tty;
1116 unsigned char *data = urb->transfer_buffer; 1116 unsigned char *data = urb->transfer_buffer;
1117 unsigned long flags; 1117 unsigned long flags;
@@ -1135,16 +1135,15 @@ static void cypress_read_int_callback(struct urb *urb)
1135 /* FALLS THROUGH */ 1135 /* FALLS THROUGH */
1136 default: 1136 default:
1137 /* something ugly is going on... */ 1137 /* something ugly is going on... */
1138 dev_err(&urb->dev->dev, 1138 dev_err(dev, "%s - unexpected nonzero read status received: %d\n",
1139 "%s - unexpected nonzero read status received: %d\n", 1139 __func__, status);
1140 __func__, status);
1141 cypress_set_dead(port); 1140 cypress_set_dead(port);
1142 return; 1141 return;
1143 } 1142 }
1144 1143
1145 spin_lock_irqsave(&priv->lock, flags); 1144 spin_lock_irqsave(&priv->lock, flags);
1146 if (priv->rx_flags & THROTTLED) { 1145 if (priv->rx_flags & THROTTLED) {
1147 dbg("%s - now throttling", __func__); 1146 dev_dbg(dev, "%s - now throttling\n", __func__);
1148 priv->rx_flags |= ACTUALLY_THROTTLED; 1147 priv->rx_flags |= ACTUALLY_THROTTLED;
1149 spin_unlock_irqrestore(&priv->lock, flags); 1148 spin_unlock_irqrestore(&priv->lock, flags);
1150 return; 1149 return;
@@ -1153,7 +1152,7 @@ static void cypress_read_int_callback(struct urb *urb)
1153 1152
1154 tty = tty_port_tty_get(&port->port); 1153 tty = tty_port_tty_get(&port->port);
1155 if (!tty) { 1154 if (!tty) {
1156 dbg("%s - bad tty pointer - exiting", __func__); 1155 dev_dbg(dev, "%s - bad tty pointer - exiting\n", __func__);
1157 return; 1156 return;
1158 } 1157 }
1159 1158
@@ -1180,13 +1179,13 @@ static void cypress_read_int_callback(struct urb *urb)
1180 } 1179 }
1181 spin_unlock_irqrestore(&priv->lock, flags); 1180 spin_unlock_irqrestore(&priv->lock, flags);
1182 if (result < bytes) { 1181 if (result < bytes) {
1183 dbg("%s - wrong packet size - received %d bytes but packet " 1182 dev_dbg(dev,
1184 "said %d bytes", __func__, result, bytes); 1183 "%s - wrong packet size - received %d bytes but packet said %d bytes\n",
1184 __func__, result, bytes);
1185 goto continue_read; 1185 goto continue_read;
1186 } 1186 }
1187 1187
1188 usb_serial_debug_data(debug, &port->dev, __func__, 1188 usb_serial_debug_data(&port->dev, __func__, urb->actual_length, data);
1189 urb->actual_length, data);
1190 1189
1191 spin_lock_irqsave(&priv->lock, flags); 1190 spin_lock_irqsave(&priv->lock, flags);
1192 /* check to see if status has changed */ 1191 /* check to see if status has changed */
@@ -1202,7 +1201,7 @@ static void cypress_read_int_callback(struct urb *urb)
1202 * though */ 1201 * though */
1203 if (tty && !(tty->termios.c_cflag & CLOCAL) && 1202 if (tty && !(tty->termios.c_cflag & CLOCAL) &&
1204 !(priv->current_status & UART_CD)) { 1203 !(priv->current_status & UART_CD)) {
1205 dbg("%s - calling hangup", __func__); 1204 dev_dbg(dev, "%s - calling hangup\n", __func__);
1206 tty_hangup(tty); 1205 tty_hangup(tty);
1207 goto continue_read; 1206 goto continue_read;
1208 } 1207 }
@@ -1215,7 +1214,7 @@ static void cypress_read_int_callback(struct urb *urb)
1215 if (priv->current_status & CYP_ERROR) { 1214 if (priv->current_status & CYP_ERROR) {
1216 spin_unlock_irqrestore(&priv->lock, flags); 1215 spin_unlock_irqrestore(&priv->lock, flags);
1217 tty_flag = TTY_PARITY; 1216 tty_flag = TTY_PARITY;
1218 dbg("%s - Parity Error detected", __func__); 1217 dev_dbg(dev, "%s - Parity Error detected\n", __func__);
1219 } else 1218 } else
1220 spin_unlock_irqrestore(&priv->lock, flags); 1219 spin_unlock_irqrestore(&priv->lock, flags);
1221 1220
@@ -1246,9 +1245,8 @@ continue_read:
1246 priv->read_urb_interval); 1245 priv->read_urb_interval);
1247 result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); 1246 result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC);
1248 if (result && result != -EPERM) { 1247 if (result && result != -EPERM) {
1249 dev_err(&urb->dev->dev, "%s - failed resubmitting " 1248 dev_err(dev, "%s - failed resubmitting read urb, error %d\n",
1250 "read urb, error %d\n", __func__, 1249 __func__, result);
1251 result);
1252 cypress_set_dead(port); 1250 cypress_set_dead(port);
1253 } 1251 }
1254 } 1252 }
@@ -1259,6 +1257,7 @@ static void cypress_write_int_callback(struct urb *urb)
1259{ 1257{
1260 struct usb_serial_port *port = urb->context; 1258 struct usb_serial_port *port = urb->context;
1261 struct cypress_private *priv = usb_get_serial_port_data(port); 1259 struct cypress_private *priv = usb_get_serial_port_data(port);
1260 struct device *dev = &urb->dev->dev;
1262 int result; 1261 int result;
1263 int status = urb->status; 1262 int status = urb->status;
1264 1263
@@ -1270,8 +1269,8 @@ static void cypress_write_int_callback(struct urb *urb)
1270 case -ENOENT: 1269 case -ENOENT:
1271 case -ESHUTDOWN: 1270 case -ESHUTDOWN:
1272 /* this urb is terminated, clean up */ 1271 /* this urb is terminated, clean up */
1273 dbg("%s - urb shutting down with status: %d", 1272 dev_dbg(dev, "%s - urb shutting down with status: %d\n",
1274 __func__, status); 1273 __func__, status);
1275 priv->write_urb_in_use = 0; 1274 priv->write_urb_in_use = 0;
1276 return; 1275 return;
1277 case -EPIPE: /* no break needed; clear halt and resubmit */ 1276 case -EPIPE: /* no break needed; clear halt and resubmit */
@@ -1279,21 +1278,19 @@ static void cypress_write_int_callback(struct urb *urb)
1279 break; 1278 break;
1280 usb_clear_halt(port->serial->dev, 0x02); 1279 usb_clear_halt(port->serial->dev, 0x02);
1281 /* error in the urb, so we have to resubmit it */ 1280 /* error in the urb, so we have to resubmit it */
1282 dbg("%s - nonzero write bulk status received: %d", 1281 dev_dbg(dev, "%s - nonzero write bulk status received: %d\n",
1283 __func__, status); 1282 __func__, status);
1284 port->interrupt_out_urb->transfer_buffer_length = 1; 1283 port->interrupt_out_urb->transfer_buffer_length = 1;
1285 result = usb_submit_urb(port->interrupt_out_urb, GFP_ATOMIC); 1284 result = usb_submit_urb(port->interrupt_out_urb, GFP_ATOMIC);
1286 if (!result) 1285 if (!result)
1287 return; 1286 return;
1288 dev_err(&urb->dev->dev, 1287 dev_err(dev, "%s - failed resubmitting write urb, error %d\n",
1289 "%s - failed resubmitting write urb, error %d\n", 1288 __func__, result);
1290 __func__, result);
1291 cypress_set_dead(port); 1289 cypress_set_dead(port);
1292 break; 1290 break;
1293 default: 1291 default:
1294 dev_err(&urb->dev->dev, 1292 dev_err(dev, "%s - unexpected nonzero write status received: %d\n",
1295 "%s - unexpected nonzero write status received: %d\n", 1293 __func__, status);
1296 __func__, status);
1297 cypress_set_dead(port); 1294 cypress_set_dead(port);
1298 break; 1295 break;
1299 } 1296 }
@@ -1310,8 +1307,6 @@ MODULE_DESCRIPTION(DRIVER_DESC);
1310MODULE_VERSION(DRIVER_VERSION); 1307MODULE_VERSION(DRIVER_VERSION);
1311MODULE_LICENSE("GPL"); 1308MODULE_LICENSE("GPL");
1312 1309
1313module_param(debug, bool, S_IRUGO | S_IWUSR);
1314MODULE_PARM_DESC(debug, "Debug enabled or not");
1315module_param(stats, bool, S_IRUGO | S_IWUSR); 1310module_param(stats, bool, S_IRUGO | S_IWUSR);
1316MODULE_PARM_DESC(stats, "Enable statistics or not"); 1311MODULE_PARM_DESC(stats, "Enable statistics or not");
1317module_param(interval, int, S_IRUGO | S_IWUSR); 1312module_param(interval, int, S_IRUGO | S_IWUSR);