aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/serial')
-rw-r--r--drivers/usb/serial/Kconfig21
-rw-r--r--drivers/usb/serial/Makefile2
-rw-r--r--drivers/usb/serial/aircable.c5
-rw-r--r--drivers/usb/serial/ark3116.c7
-rw-r--r--drivers/usb/serial/belkin_sa.c8
-rw-r--r--drivers/usb/serial/ch341.c49
-rw-r--r--drivers/usb/serial/console.c23
-rw-r--r--drivers/usb/serial/cp210x.c141
-rw-r--r--drivers/usb/serial/cyberjack.c77
-rw-r--r--drivers/usb/serial/cypress_m8.c157
-rw-r--r--drivers/usb/serial/digi_acceleport.c50
-rw-r--r--drivers/usb/serial/empeg.c5
-rw-r--r--drivers/usb/serial/ezusb.c59
-rw-r--r--drivers/usb/serial/f81232.c8
-rw-r--r--drivers/usb/serial/ftdi_sio.c138
-rw-r--r--drivers/usb/serial/ftdi_sio_ids.h5
-rw-r--r--drivers/usb/serial/funsoft.c5
-rw-r--r--drivers/usb/serial/garmin_gps.c129
-rw-r--r--drivers/usb/serial/generic.c11
-rw-r--r--drivers/usb/serial/io_edgeport.c616
-rw-r--r--drivers/usb/serial/io_ti.c408
-rw-r--r--drivers/usb/serial/ipaq.c4
-rw-r--r--drivers/usb/serial/ipw.c66
-rw-r--r--drivers/usb/serial/ir-usb.c16
-rw-r--r--drivers/usb/serial/iuu_phoenix.c134
-rw-r--r--drivers/usb/serial/keyspan.c338
-rw-r--r--drivers/usb/serial/keyspan.h17
-rw-r--r--drivers/usb/serial/keyspan_pda.c73
-rw-r--r--drivers/usb/serial/kl5kusb105.c41
-rw-r--r--drivers/usb/serial/kobil_sct.c98
-rw-r--r--drivers/usb/serial/mct_u232.c104
-rw-r--r--drivers/usb/serial/metro-usb.c7
-rw-r--r--drivers/usb/serial/mos7720.c231
-rw-r--r--drivers/usb/serial/mos7840.c478
-rw-r--r--drivers/usb/serial/navman.c8
-rw-r--r--drivers/usb/serial/omninet.c43
-rw-r--r--drivers/usb/serial/opticon.c30
-rw-r--r--drivers/usb/serial/option.c23
-rw-r--r--drivers/usb/serial/oti6858.c77
-rw-r--r--drivers/usb/serial/pl2303.c8
-rw-r--r--drivers/usb/serial/qcaux.c10
-rw-r--r--drivers/usb/serial/qcserial.c5
-rw-r--r--drivers/usb/serial/quatech2.c7
-rw-r--r--drivers/usb/serial/safe_serial.c12
-rw-r--r--drivers/usb/serial/sierra.c11
-rw-r--r--drivers/usb/serial/spcp8x5.c5
-rw-r--r--drivers/usb/serial/ssu100.c37
-rw-r--r--drivers/usb/serial/symbolserial.c8
-rw-r--r--drivers/usb/serial/ti_usb_3410_5052.c150
-rw-r--r--drivers/usb/serial/usb-serial.c176
-rw-r--r--drivers/usb/serial/usb_wwan.c56
-rw-r--r--drivers/usb/serial/visor.c13
-rw-r--r--drivers/usb/serial/whiteheat.c135
-rw-r--r--drivers/usb/serial/zte_ev.c307
54 files changed, 2086 insertions, 2566 deletions
diff --git a/drivers/usb/serial/Kconfig b/drivers/usb/serial/Kconfig
index 325d2910f9f9..76f462241738 100644
--- a/drivers/usb/serial/Kconfig
+++ b/drivers/usb/serial/Kconfig
@@ -42,11 +42,6 @@ config USB_SERIAL_CONSOLE
42 42
43 If unsure, say N. 43 If unsure, say N.
44 44
45config USB_EZUSB
46 bool "Functions for loading firmware on EZUSB chips"
47 help
48 Say Y here if you need EZUSB device support.
49
50config USB_SERIAL_GENERIC 45config USB_SERIAL_GENERIC
51 bool "USB Generic Serial Driver" 46 bool "USB Generic Serial Driver"
52 help 47 help
@@ -94,7 +89,7 @@ config USB_SERIAL_CH341
94 89
95config USB_SERIAL_WHITEHEAT 90config USB_SERIAL_WHITEHEAT
96 tristate "USB ConnectTech WhiteHEAT Serial Driver" 91 tristate "USB ConnectTech WhiteHEAT Serial Driver"
97 select USB_EZUSB 92 select USB_EZUSB_FX2
98 help 93 help
99 Say Y here if you want to use a ConnectTech WhiteHEAT 4 port 94 Say Y here if you want to use a ConnectTech WhiteHEAT 4 port
100 USB to serial converter device. 95 USB to serial converter device.
@@ -281,7 +276,7 @@ config USB_SERIAL_IUU
281 276
282config USB_SERIAL_KEYSPAN_PDA 277config USB_SERIAL_KEYSPAN_PDA
283 tristate "USB Keyspan PDA Single Port Serial Driver" 278 tristate "USB Keyspan PDA Single Port Serial Driver"
284 select USB_EZUSB 279 select USB_EZUSB_FX2
285 help 280 help
286 Say Y here if you want to use a Keyspan PDA single port USB to 281 Say Y here if you want to use a Keyspan PDA single port USB to
287 serial converter device. This driver makes use of firmware 282 serial converter device. This driver makes use of firmware
@@ -292,7 +287,7 @@ config USB_SERIAL_KEYSPAN_PDA
292 287
293config USB_SERIAL_KEYSPAN 288config USB_SERIAL_KEYSPAN
294 tristate "USB Keyspan USA-xxx Serial Driver" 289 tristate "USB Keyspan USA-xxx Serial Driver"
295 select USB_EZUSB 290 select USB_EZUSB_FX2
296 ---help--- 291 ---help---
297 Say Y here if you want to use Keyspan USB to serial converter 292 Say Y here if you want to use Keyspan USB to serial converter
298 devices. This driver makes use of Keyspan's official firmware 293 devices. This driver makes use of Keyspan's official firmware
@@ -596,7 +591,7 @@ config USB_SERIAL_CYBERJACK
596 591
597config USB_SERIAL_XIRCOM 592config USB_SERIAL_XIRCOM
598 tristate "USB Xircom / Entregra Single Port Serial Driver" 593 tristate "USB Xircom / Entregra Single Port Serial Driver"
599 select USB_EZUSB 594 select USB_EZUSB_FX2
600 help 595 help
601 Say Y here if you want to use a Xircom or Entregra single port USB to 596 Say Y here if you want to use a Xircom or Entregra single port USB to
602 serial converter device. This driver makes use of firmware 597 serial converter device. This driver makes use of firmware
@@ -660,6 +655,14 @@ config USB_SERIAL_ZIO
660 To compile this driver as a module, choose M here: the 655 To compile this driver as a module, choose M here: the
661 module will be called zio. 656 module will be called zio.
662 657
658config USB_SERIAL_ZTE
659 tristate "ZTE USB serial driver"
660 help
661 Say Y here if you want to use a ZTE USB to serial device.
662
663 To compile this driver as a module, choose M here: the
664 module will be called zte.
665
663config USB_SERIAL_SSU100 666config USB_SERIAL_SSU100
664 tristate "USB Quatech SSU-100 Single Port Serial Driver" 667 tristate "USB Quatech SSU-100 Single Port Serial Driver"
665 help 668 help
diff --git a/drivers/usb/serial/Makefile b/drivers/usb/serial/Makefile
index 1dc483a8bfc7..3b3e7308d476 100644
--- a/drivers/usb/serial/Makefile
+++ b/drivers/usb/serial/Makefile
@@ -9,7 +9,6 @@ obj-$(CONFIG_USB_SERIAL) += usbserial.o
9usbserial-y := usb-serial.o generic.o bus.o 9usbserial-y := usb-serial.o generic.o bus.o
10 10
11usbserial-$(CONFIG_USB_SERIAL_CONSOLE) += console.o 11usbserial-$(CONFIG_USB_SERIAL_CONSOLE) += console.o
12usbserial-$(CONFIG_USB_EZUSB) += ezusb.o
13 12
14obj-$(CONFIG_USB_SERIAL_AIRCABLE) += aircable.o 13obj-$(CONFIG_USB_SERIAL_AIRCABLE) += aircable.o
15obj-$(CONFIG_USB_SERIAL_ARK3116) += ark3116.o 14obj-$(CONFIG_USB_SERIAL_ARK3116) += ark3116.o
@@ -63,3 +62,4 @@ obj-$(CONFIG_USB_SERIAL_WHITEHEAT) += whiteheat.o
63obj-$(CONFIG_USB_SERIAL_XIRCOM) += keyspan_pda.o 62obj-$(CONFIG_USB_SERIAL_XIRCOM) += keyspan_pda.o
64obj-$(CONFIG_USB_SERIAL_VIVOPAY_SERIAL) += vivopay-serial.o 63obj-$(CONFIG_USB_SERIAL_VIVOPAY_SERIAL) += vivopay-serial.o
65obj-$(CONFIG_USB_SERIAL_ZIO) += zio.o 64obj-$(CONFIG_USB_SERIAL_ZIO) += zio.o
65obj-$(CONFIG_USB_SERIAL_ZTE) += zte_ev.o
diff --git a/drivers/usb/serial/aircable.c b/drivers/usb/serial/aircable.c
index d634e6635632..54e1bb6372e7 100644
--- a/drivers/usb/serial/aircable.c
+++ b/drivers/usb/serial/aircable.c
@@ -52,8 +52,6 @@
52#include <linux/usb.h> 52#include <linux/usb.h>
53#include <linux/usb/serial.h> 53#include <linux/usb/serial.h>
54 54
55static bool debug;
56
57/* Vendor and Product ID */ 55/* Vendor and Product ID */
58#define AIRCABLE_VID 0x16CA 56#define AIRCABLE_VID 0x16CA
59#define AIRCABLE_USB_PID 0x1502 57#define AIRCABLE_USB_PID 0x1502
@@ -196,6 +194,3 @@ MODULE_AUTHOR(DRIVER_AUTHOR);
196MODULE_DESCRIPTION(DRIVER_DESC); 194MODULE_DESCRIPTION(DRIVER_DESC);
197MODULE_VERSION(DRIVER_VERSION); 195MODULE_VERSION(DRIVER_VERSION);
198MODULE_LICENSE("GPL"); 196MODULE_LICENSE("GPL");
199
200module_param(debug, bool, S_IRUGO | S_IWUSR);
201MODULE_PARM_DESC(debug, "Debug enabled or not");
diff --git a/drivers/usb/serial/ark3116.c b/drivers/usb/serial/ark3116.c
index 3b98fb733362..cf2522c397d3 100644
--- a/drivers/usb/serial/ark3116.c
+++ b/drivers/usb/serial/ark3116.c
@@ -37,7 +37,6 @@
37#include <linux/mutex.h> 37#include <linux/mutex.h>
38#include <linux/spinlock.h> 38#include <linux/spinlock.h>
39 39
40static bool debug;
41/* 40/*
42 * Version information 41 * Version information
43 */ 42 */
@@ -650,8 +649,7 @@ static void ark3116_read_int_callback(struct urb *urb)
650 /* 649 /*
651 * Not sure what this data meant... 650 * Not sure what this data meant...
652 */ 651 */
653 usb_serial_debug_data(debug, &port->dev, 652 usb_serial_debug_data(&port->dev, __func__,
654 __func__,
655 urb->actual_length, 653 urb->actual_length,
656 urb->transfer_buffer); 654 urb->transfer_buffer);
657 break; 655 break;
@@ -750,9 +748,6 @@ MODULE_LICENSE("GPL");
750MODULE_AUTHOR(DRIVER_AUTHOR); 748MODULE_AUTHOR(DRIVER_AUTHOR);
751MODULE_DESCRIPTION(DRIVER_DESC); 749MODULE_DESCRIPTION(DRIVER_DESC);
752 750
753module_param(debug, bool, S_IRUGO | S_IWUSR);
754MODULE_PARM_DESC(debug, "Enable debug");
755
756/* 751/*
757 * The following describes what I learned from studying the old 752 * The following describes what I learned from studying the old
758 * ark3116.c driver, disassembling the windows driver, and some lucky 753 * ark3116.c driver, disassembling the windows driver, and some lucky
diff --git a/drivers/usb/serial/belkin_sa.c b/drivers/usb/serial/belkin_sa.c
index a46df73ee96e..99449424193f 100644
--- a/drivers/usb/serial/belkin_sa.c
+++ b/drivers/usb/serial/belkin_sa.c
@@ -37,8 +37,6 @@
37#include <linux/usb/serial.h> 37#include <linux/usb/serial.h>
38#include "belkin_sa.h" 38#include "belkin_sa.h"
39 39
40static bool debug;
41
42/* 40/*
43 * Version Information 41 * Version Information
44 */ 42 */
@@ -206,8 +204,7 @@ static void belkin_sa_read_int_callback(struct urb *urb)
206 goto exit; 204 goto exit;
207 } 205 }
208 206
209 usb_serial_debug_data(debug, &port->dev, __func__, 207 usb_serial_debug_data(&port->dev, __func__, urb->actual_length, data);
210 urb->actual_length, data);
211 208
212 /* Handle known interrupt data */ 209 /* Handle known interrupt data */
213 /* ignore data[0] and data[1] */ 210 /* ignore data[0] and data[1] */
@@ -515,6 +512,3 @@ MODULE_AUTHOR(DRIVER_AUTHOR);
515MODULE_DESCRIPTION(DRIVER_DESC); 512MODULE_DESCRIPTION(DRIVER_DESC);
516MODULE_VERSION(DRIVER_VERSION); 513MODULE_VERSION(DRIVER_VERSION);
517MODULE_LICENSE("GPL"); 514MODULE_LICENSE("GPL");
518
519module_param(debug, bool, S_IRUGO | S_IWUSR);
520MODULE_PARM_DESC(debug, "Debug enabled or not");
diff --git a/drivers/usb/serial/ch341.c b/drivers/usb/serial/ch341.c
index cabd1b15ddce..e9c7046ae355 100644
--- a/drivers/usb/serial/ch341.c
+++ b/drivers/usb/serial/ch341.c
@@ -70,8 +70,6 @@
70#define CH341_NBREAK_BITS_REG2 0x40 70#define CH341_NBREAK_BITS_REG2 0x40
71 71
72 72
73static bool debug;
74
75static const struct usb_device_id id_table[] = { 73static const struct usb_device_id id_table[] = {
76 { USB_DEVICE(0x4348, 0x5523) }, 74 { USB_DEVICE(0x4348, 0x5523) },
77 { USB_DEVICE(0x1a86, 0x7523) }, 75 { USB_DEVICE(0x1a86, 0x7523) },
@@ -93,8 +91,9 @@ static int ch341_control_out(struct usb_device *dev, u8 request,
93 u16 value, u16 index) 91 u16 value, u16 index)
94{ 92{
95 int r; 93 int r;
96 dbg("ch341_control_out(%02x,%02x,%04x,%04x)", USB_DIR_OUT|0x40, 94
97 (int)request, (int)value, (int)index); 95 dev_dbg(&dev->dev, "ch341_control_out(%02x,%02x,%04x,%04x)\n",
96 USB_DIR_OUT|0x40, (int)request, (int)value, (int)index);
98 97
99 r = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), request, 98 r = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), request,
100 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, 99 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT,
@@ -108,8 +107,10 @@ static int ch341_control_in(struct usb_device *dev,
108 char *buf, unsigned bufsize) 107 char *buf, unsigned bufsize)
109{ 108{
110 int r; 109 int r;
111 dbg("ch341_control_in(%02x,%02x,%04x,%04x,%p,%u)", USB_DIR_IN|0x40, 110
112 (int)request, (int)value, (int)index, buf, (int)bufsize); 111 dev_dbg(&dev->dev, "ch341_control_in(%02x,%02x,%04x,%04x,%p,%u)\n",
112 USB_DIR_IN|0x40, (int)request, (int)value, (int)index, buf,
113 (int)bufsize);
113 114
114 r = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), request, 115 r = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), request,
115 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, 116 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,
@@ -320,7 +321,7 @@ static int ch341_open(struct tty_struct *tty, struct usb_serial_port *port)
320 if (r) 321 if (r)
321 goto out; 322 goto out;
322 323
323 dbg("%s - submitting interrupt urb", __func__); 324 dev_dbg(&port->dev, "%s - submitting interrupt urb", __func__);
324 r = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); 325 r = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
325 if (r) { 326 if (r) {
326 dev_err(&port->dev, "%s - failed submitting interrupt urb," 327 dev_err(&port->dev, "%s - failed submitting interrupt urb,"
@@ -390,19 +391,19 @@ static void ch341_break_ctl(struct tty_struct *tty, int break_state)
390 __func__, r); 391 __func__, r);
391 goto out; 392 goto out;
392 } 393 }
393 dbg("%s - initial ch341 break register contents - reg1: %x, reg2: %x", 394 dev_dbg(&port->dev, "%s - initial ch341 break register contents - reg1: %x, reg2: %x\n",
394 __func__, break_reg[0], break_reg[1]); 395 __func__, break_reg[0], break_reg[1]);
395 if (break_state != 0) { 396 if (break_state != 0) {
396 dbg("%s - Enter break state requested", __func__); 397 dev_dbg(&port->dev, "%s - Enter break state requested\n", __func__);
397 break_reg[0] &= ~CH341_NBREAK_BITS_REG1; 398 break_reg[0] &= ~CH341_NBREAK_BITS_REG1;
398 break_reg[1] &= ~CH341_NBREAK_BITS_REG2; 399 break_reg[1] &= ~CH341_NBREAK_BITS_REG2;
399 } else { 400 } else {
400 dbg("%s - Leave break state requested", __func__); 401 dev_dbg(&port->dev, "%s - Leave break state requested\n", __func__);
401 break_reg[0] |= CH341_NBREAK_BITS_REG1; 402 break_reg[0] |= CH341_NBREAK_BITS_REG1;
402 break_reg[1] |= CH341_NBREAK_BITS_REG2; 403 break_reg[1] |= CH341_NBREAK_BITS_REG2;
403 } 404 }
404 dbg("%s - New ch341 break register contents - reg1: %x, reg2: %x", 405 dev_dbg(&port->dev, "%s - New ch341 break register contents - reg1: %x, reg2: %x\n",
405 __func__, break_reg[0], break_reg[1]); 406 __func__, break_reg[0], break_reg[1]);
406 reg_contents = get_unaligned_le16(break_reg); 407 reg_contents = get_unaligned_le16(break_reg);
407 r = ch341_control_out(port->serial->dev, CH341_REQ_WRITE_REG, 408 r = ch341_control_out(port->serial->dev, CH341_REQ_WRITE_REG,
408 ch341_break_reg, reg_contents); 409 ch341_break_reg, reg_contents);
@@ -451,16 +452,16 @@ static void ch341_read_int_callback(struct urb *urb)
451 case -ENOENT: 452 case -ENOENT:
452 case -ESHUTDOWN: 453 case -ESHUTDOWN:
453 /* this urb is terminated, clean up */ 454 /* this urb is terminated, clean up */
454 dbg("%s - urb shutting down with status: %d", __func__, 455 dev_dbg(&urb->dev->dev, "%s - urb shutting down with status: %d\n",
455 urb->status); 456 __func__, urb->status);
456 return; 457 return;
457 default: 458 default:
458 dbg("%s - nonzero urb status received: %d", __func__, 459 dev_dbg(&urb->dev->dev, "%s - nonzero urb status received: %d\n",
459 urb->status); 460 __func__, urb->status);
460 goto exit; 461 goto exit;
461 } 462 }
462 463
463 usb_serial_debug_data(debug, &port->dev, __func__, 464 usb_serial_debug_data(&port->dev, __func__,
464 urb->actual_length, urb->transfer_buffer); 465 urb->actual_length, urb->transfer_buffer);
465 466
466 if (actual_length >= 4) { 467 if (actual_length >= 4) {
@@ -536,15 +537,16 @@ static int ch341_ioctl(struct tty_struct *tty,
536 unsigned int cmd, unsigned long arg) 537 unsigned int cmd, unsigned long arg)
537{ 538{
538 struct usb_serial_port *port = tty->driver_data; 539 struct usb_serial_port *port = tty->driver_data;
539 dbg("%s (%d) cmd = 0x%04x", __func__, port->number, cmd); 540
541 dev_dbg(&port->dev, "%s (%d) cmd = 0x%04x\n", __func__, port->number, cmd);
540 542
541 switch (cmd) { 543 switch (cmd) {
542 case TIOCMIWAIT: 544 case TIOCMIWAIT:
543 dbg("%s (%d) TIOCMIWAIT", __func__, port->number); 545 dev_dbg(&port->dev, "%s (%d) TIOCMIWAIT\n", __func__, port->number);
544 return wait_modem_info(port, arg); 546 return wait_modem_info(port, arg);
545 547
546 default: 548 default:
547 dbg("%s not supported = 0x%04x", __func__, cmd); 549 dev_dbg(&port->dev, "%s not supported = 0x%04x\n", __func__, cmd);
548 break; 550 break;
549 } 551 }
550 552
@@ -572,7 +574,7 @@ static int ch341_tiocmget(struct tty_struct *tty)
572 | ((status & CH341_BIT_RI) ? TIOCM_RI : 0) 574 | ((status & CH341_BIT_RI) ? TIOCM_RI : 0)
573 | ((status & CH341_BIT_DCD) ? TIOCM_CD : 0); 575 | ((status & CH341_BIT_DCD) ? TIOCM_CD : 0);
574 576
575 dbg("%s - result = %x", __func__, result); 577 dev_dbg(&port->dev, "%s - result = %x\n", __func__, result);
576 578
577 return result; 579 return result;
578} 580}
@@ -617,6 +619,3 @@ static struct usb_serial_driver * const serial_drivers[] = {
617module_usb_serial_driver(serial_drivers, id_table); 619module_usb_serial_driver(serial_drivers, id_table);
618 620
619MODULE_LICENSE("GPL"); 621MODULE_LICENSE("GPL");
620
621module_param(debug, bool, S_IRUGO | S_IWUSR);
622MODULE_PARM_DESC(debug, "Debug enabled or not");
diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
index 9a564286bfd7..5f3bcd31e204 100644
--- a/drivers/usb/serial/console.c
+++ b/drivers/usb/serial/console.c
@@ -11,6 +11,8 @@
11 * 11 *
12 */ 12 */
13 13
14#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
15
14#include <linux/kernel.h> 16#include <linux/kernel.h>
15#include <linux/init.h> 17#include <linux/init.h>
16#include <linux/slab.h> 18#include <linux/slab.h>
@@ -20,8 +22,6 @@
20#include <linux/usb.h> 22#include <linux/usb.h>
21#include <linux/usb/serial.h> 23#include <linux/usb/serial.h>
22 24
23static int debug;
24
25struct usbcons_info { 25struct usbcons_info {
26 int magic; 26 int magic;
27 int break_flag; 27 int break_flag;
@@ -68,8 +68,6 @@ static int usb_console_setup(struct console *co, char *options)
68 struct tty_struct *tty = NULL; 68 struct tty_struct *tty = NULL;
69 struct ktermios dummy; 69 struct ktermios dummy;
70 70
71 dbg("%s", __func__);
72
73 if (options) { 71 if (options) {
74 baud = simple_strtoul(options, NULL, 10); 72 baud = simple_strtoul(options, NULL, 10);
75 s = options; 73 s = options;
@@ -113,8 +111,7 @@ static int usb_console_setup(struct console *co, char *options)
113 serial = usb_serial_get_by_index(co->index); 111 serial = usb_serial_get_by_index(co->index);
114 if (serial == NULL) { 112 if (serial == NULL) {
115 /* no device is connected yet, sorry :( */ 113 /* no device is connected yet, sorry :( */
116 printk(KERN_ERR "No USB device connected to ttyUSB%i\n", 114 pr_err("No USB device connected to ttyUSB%i\n", co->index);
117 co->index);
118 return -ENODEV; 115 return -ENODEV;
119 } 116 }
120 117
@@ -213,10 +210,10 @@ static void usb_console_write(struct console *co,
213 if (count == 0) 210 if (count == 0)
214 return; 211 return;
215 212
216 dbg("%s - port %d, %d byte(s)", __func__, port->number, count); 213 pr_debug("%s - port %d, %d byte(s)\n", __func__, port->number, count);
217 214
218 if (!port->port.console) { 215 if (!port->port.console) {
219 dbg("%s - port not opened", __func__); 216 pr_debug("%s - port not opened\n", __func__);
220 return; 217 return;
221 } 218 }
222 219
@@ -237,7 +234,7 @@ static void usb_console_write(struct console *co,
237 retval = serial->type->write(NULL, port, buf, i); 234 retval = serial->type->write(NULL, port, buf, i);
238 else 235 else
239 retval = usb_serial_generic_write(NULL, port, buf, i); 236 retval = usb_serial_generic_write(NULL, port, buf, i);
240 dbg("%s - return value : %d", __func__, retval); 237 pr_debug("%s - return value : %d\n", __func__, retval);
241 if (lf) { 238 if (lf) {
242 /* append CR after LF */ 239 /* append CR after LF */
243 unsigned char cr = 13; 240 unsigned char cr = 13;
@@ -247,7 +244,7 @@ static void usb_console_write(struct console *co,
247 else 244 else
248 retval = usb_serial_generic_write(NULL, 245 retval = usb_serial_generic_write(NULL,
249 port, &cr, 1); 246 port, &cr, 1);
250 dbg("%s - return value : %d", __func__, retval); 247 pr_debug("%s - return value : %d\n", __func__, retval);
251 } 248 }
252 buf += i; 249 buf += i;
253 count -= i; 250 count -= i;
@@ -284,10 +281,8 @@ void usb_serial_console_disconnect(struct usb_serial *serial)
284 } 281 }
285} 282}
286 283
287void usb_serial_console_init(int serial_debug, int minor) 284void usb_serial_console_init(int minor)
288{ 285{
289 debug = serial_debug;
290
291 if (minor == 0) { 286 if (minor == 0) {
292 /* 287 /*
293 * Call register_console() if this is the first device plugged 288 * Call register_console() if this is the first device plugged
@@ -302,7 +297,7 @@ void usb_serial_console_init(int serial_debug, int minor)
302 * register_console). console_write() is called immediately 297 * register_console). console_write() is called immediately
303 * from register_console iff CON_PRINTBUFFER is set in flags. 298 * from register_console iff CON_PRINTBUFFER is set in flags.
304 */ 299 */
305 dbg("registering the USB serial console."); 300 pr_debug("registering the USB serial console.\n");
306 register_console(&usbcons); 301 register_console(&usbcons);
307 } 302 }
308} 303}
diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
index ba5e07e188a0..28af5acc3360 100644
--- a/drivers/usb/serial/cp210x.c
+++ b/drivers/usb/serial/cp210x.c
@@ -52,8 +52,6 @@ static int cp210x_startup(struct usb_serial *);
52static void cp210x_release(struct usb_serial *); 52static void cp210x_release(struct usb_serial *);
53static void cp210x_dtr_rts(struct usb_serial_port *p, int on); 53static void cp210x_dtr_rts(struct usb_serial_port *p, int on);
54 54
55static bool debug;
56
57static const struct usb_device_id id_table[] = { 55static const struct usb_device_id id_table[] = {
58 { USB_DEVICE(0x045B, 0x0053) }, /* Renesas RX610 RX-Stick */ 56 { USB_DEVICE(0x045B, 0x0053) }, /* Renesas RX610 RX-Stick */
59 { USB_DEVICE(0x0471, 0x066A) }, /* AKTAKOM ACE-1001 cable */ 57 { USB_DEVICE(0x0471, 0x066A) }, /* AKTAKOM ACE-1001 cable */
@@ -304,9 +302,8 @@ static int cp210x_get_config(struct usb_serial_port *port, u8 request,
304 kfree(buf); 302 kfree(buf);
305 303
306 if (result != size) { 304 if (result != size) {
307 dbg("%s - Unable to send config request, " 305 dev_dbg(&port->dev, "%s - Unable to send config request, request=0x%x size=%d result=%d\n",
308 "request=0x%x size=%d result=%d", 306 __func__, request, size, result);
309 __func__, request, size, result);
310 if (result > 0) 307 if (result > 0)
311 result = -EPROTO; 308 result = -EPROTO;
312 309
@@ -361,9 +358,8 @@ static int cp210x_set_config(struct usb_serial_port *port, u8 request,
361 kfree(buf); 358 kfree(buf);
362 359
363 if ((size > 2 && result != size) || result < 0) { 360 if ((size > 2 && result != size) || result < 0) {
364 dbg("%s - Unable to send request, " 361 dev_dbg(&port->dev, "%s - Unable to send request, request=0x%x size=%d result=%d\n",
365 "request=0x%x size=%d result=%d", 362 __func__, request, size, result);
366 __func__, request, size, result);
367 if (result > 0) 363 if (result > 0)
368 result = -EPROTO; 364 result = -EPROTO;
369 365
@@ -487,13 +483,14 @@ static void cp210x_get_termios(struct tty_struct *tty,
487static void cp210x_get_termios_port(struct usb_serial_port *port, 483static void cp210x_get_termios_port(struct usb_serial_port *port,
488 unsigned int *cflagp, unsigned int *baudp) 484 unsigned int *cflagp, unsigned int *baudp)
489{ 485{
486 struct device *dev = &port->dev;
490 unsigned int cflag, modem_ctl[4]; 487 unsigned int cflag, modem_ctl[4];
491 unsigned int baud; 488 unsigned int baud;
492 unsigned int bits; 489 unsigned int bits;
493 490
494 cp210x_get_config(port, CP210X_GET_BAUDRATE, &baud, 4); 491 cp210x_get_config(port, CP210X_GET_BAUDRATE, &baud, 4);
495 492
496 dbg("%s - baud rate = %d", __func__, baud); 493 dev_dbg(dev, "%s - baud rate = %d\n", __func__, baud);
497 *baudp = baud; 494 *baudp = baud;
498 495
499 cflag = *cflagp; 496 cflag = *cflagp;
@@ -502,31 +499,30 @@ static void cp210x_get_termios_port(struct usb_serial_port *port,
502 cflag &= ~CSIZE; 499 cflag &= ~CSIZE;
503 switch (bits & BITS_DATA_MASK) { 500 switch (bits & BITS_DATA_MASK) {
504 case BITS_DATA_5: 501 case BITS_DATA_5:
505 dbg("%s - data bits = 5", __func__); 502 dev_dbg(dev, "%s - data bits = 5\n", __func__);
506 cflag |= CS5; 503 cflag |= CS5;
507 break; 504 break;
508 case BITS_DATA_6: 505 case BITS_DATA_6:
509 dbg("%s - data bits = 6", __func__); 506 dev_dbg(dev, "%s - data bits = 6\n", __func__);
510 cflag |= CS6; 507 cflag |= CS6;
511 break; 508 break;
512 case BITS_DATA_7: 509 case BITS_DATA_7:
513 dbg("%s - data bits = 7", __func__); 510 dev_dbg(dev, "%s - data bits = 7\n", __func__);
514 cflag |= CS7; 511 cflag |= CS7;
515 break; 512 break;
516 case BITS_DATA_8: 513 case BITS_DATA_8:
517 dbg("%s - data bits = 8", __func__); 514 dev_dbg(dev, "%s - data bits = 8\n", __func__);
518 cflag |= CS8; 515 cflag |= CS8;
519 break; 516 break;
520 case BITS_DATA_9: 517 case BITS_DATA_9:
521 dbg("%s - data bits = 9 (not supported, using 8 data bits)", 518 dev_dbg(dev, "%s - data bits = 9 (not supported, using 8 data bits)\n", __func__);
522 __func__);
523 cflag |= CS8; 519 cflag |= CS8;
524 bits &= ~BITS_DATA_MASK; 520 bits &= ~BITS_DATA_MASK;
525 bits |= BITS_DATA_8; 521 bits |= BITS_DATA_8;
526 cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2); 522 cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2);
527 break; 523 break;
528 default: 524 default:
529 dbg("%s - Unknown number of data bits, using 8", __func__); 525 dev_dbg(dev, "%s - Unknown number of data bits, using 8\n", __func__);
530 cflag |= CS8; 526 cflag |= CS8;
531 bits &= ~BITS_DATA_MASK; 527 bits &= ~BITS_DATA_MASK;
532 bits |= BITS_DATA_8; 528 bits |= BITS_DATA_8;
@@ -536,29 +532,29 @@ static void cp210x_get_termios_port(struct usb_serial_port *port,
536 532
537 switch (bits & BITS_PARITY_MASK) { 533 switch (bits & BITS_PARITY_MASK) {
538 case BITS_PARITY_NONE: 534 case BITS_PARITY_NONE:
539 dbg("%s - parity = NONE", __func__); 535 dev_dbg(dev, "%s - parity = NONE\n", __func__);
540 cflag &= ~PARENB; 536 cflag &= ~PARENB;
541 break; 537 break;
542 case BITS_PARITY_ODD: 538 case BITS_PARITY_ODD:
543 dbg("%s - parity = ODD", __func__); 539 dev_dbg(dev, "%s - parity = ODD\n", __func__);
544 cflag |= (PARENB|PARODD); 540 cflag |= (PARENB|PARODD);
545 break; 541 break;
546 case BITS_PARITY_EVEN: 542 case BITS_PARITY_EVEN:
547 dbg("%s - parity = EVEN", __func__); 543 dev_dbg(dev, "%s - parity = EVEN\n", __func__);
548 cflag &= ~PARODD; 544 cflag &= ~PARODD;
549 cflag |= PARENB; 545 cflag |= PARENB;
550 break; 546 break;
551 case BITS_PARITY_MARK: 547 case BITS_PARITY_MARK:
552 dbg("%s - parity = MARK", __func__); 548 dev_dbg(dev, "%s - parity = MARK\n", __func__);
553 cflag |= (PARENB|PARODD|CMSPAR); 549 cflag |= (PARENB|PARODD|CMSPAR);
554 break; 550 break;
555 case BITS_PARITY_SPACE: 551 case BITS_PARITY_SPACE:
556 dbg("%s - parity = SPACE", __func__); 552 dev_dbg(dev, "%s - parity = SPACE\n", __func__);
557 cflag &= ~PARODD; 553 cflag &= ~PARODD;
558 cflag |= (PARENB|CMSPAR); 554 cflag |= (PARENB|CMSPAR);
559 break; 555 break;
560 default: 556 default:
561 dbg("%s - Unknown parity mode, disabling parity", __func__); 557 dev_dbg(dev, "%s - Unknown parity mode, disabling parity\n", __func__);
562 cflag &= ~PARENB; 558 cflag &= ~PARENB;
563 bits &= ~BITS_PARITY_MASK; 559 bits &= ~BITS_PARITY_MASK;
564 cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2); 560 cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2);
@@ -568,21 +564,19 @@ static void cp210x_get_termios_port(struct usb_serial_port *port,
568 cflag &= ~CSTOPB; 564 cflag &= ~CSTOPB;
569 switch (bits & BITS_STOP_MASK) { 565 switch (bits & BITS_STOP_MASK) {
570 case BITS_STOP_1: 566 case BITS_STOP_1:
571 dbg("%s - stop bits = 1", __func__); 567 dev_dbg(dev, "%s - stop bits = 1\n", __func__);
572 break; 568 break;
573 case BITS_STOP_1_5: 569 case BITS_STOP_1_5:
574 dbg("%s - stop bits = 1.5 (not supported, using 1 stop bit)", 570 dev_dbg(dev, "%s - stop bits = 1.5 (not supported, using 1 stop bit)\n", __func__);
575 __func__);
576 bits &= ~BITS_STOP_MASK; 571 bits &= ~BITS_STOP_MASK;
577 cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2); 572 cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2);
578 break; 573 break;
579 case BITS_STOP_2: 574 case BITS_STOP_2:
580 dbg("%s - stop bits = 2", __func__); 575 dev_dbg(dev, "%s - stop bits = 2\n", __func__);
581 cflag |= CSTOPB; 576 cflag |= CSTOPB;
582 break; 577 break;
583 default: 578 default:
584 dbg("%s - Unknown number of stop bits, using 1 stop bit", 579 dev_dbg(dev, "%s - Unknown number of stop bits, using 1 stop bit\n", __func__);
585 __func__);
586 bits &= ~BITS_STOP_MASK; 580 bits &= ~BITS_STOP_MASK;
587 cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2); 581 cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2);
588 break; 582 break;
@@ -590,10 +584,10 @@ static void cp210x_get_termios_port(struct usb_serial_port *port,
590 584
591 cp210x_get_config(port, CP210X_GET_FLOW, modem_ctl, 16); 585 cp210x_get_config(port, CP210X_GET_FLOW, modem_ctl, 16);
592 if (modem_ctl[0] & 0x0008) { 586 if (modem_ctl[0] & 0x0008) {
593 dbg("%s - flow control = CRTSCTS", __func__); 587 dev_dbg(dev, "%s - flow control = CRTSCTS\n", __func__);
594 cflag |= CRTSCTS; 588 cflag |= CRTSCTS;
595 } else { 589 } else {
596 dbg("%s - flow control = NONE", __func__); 590 dev_dbg(dev, "%s - flow control = NONE\n", __func__);
597 cflag &= ~CRTSCTS; 591 cflag &= ~CRTSCTS;
598 } 592 }
599 593
@@ -640,7 +634,7 @@ static void cp210x_change_speed(struct tty_struct *tty,
640 */ 634 */
641 baud = cp210x_quantise_baudrate(baud); 635 baud = cp210x_quantise_baudrate(baud);
642 636
643 dbg("%s - setting baud rate to %u", __func__, baud); 637 dev_dbg(&port->dev, "%s - setting baud rate to %u\n", __func__, baud);
644 if (cp210x_set_config(port, CP210X_SET_BAUDRATE, &baud, 638 if (cp210x_set_config(port, CP210X_SET_BAUDRATE, &baud,
645 sizeof(baud))) { 639 sizeof(baud))) {
646 dev_warn(&port->dev, "failed to set baud rate to %u\n", baud); 640 dev_warn(&port->dev, "failed to set baud rate to %u\n", baud);
@@ -656,11 +650,12 @@ static void cp210x_change_speed(struct tty_struct *tty,
656static void cp210x_set_termios(struct tty_struct *tty, 650static void cp210x_set_termios(struct tty_struct *tty,
657 struct usb_serial_port *port, struct ktermios *old_termios) 651 struct usb_serial_port *port, struct ktermios *old_termios)
658{ 652{
653 struct device *dev = &port->dev;
659 unsigned int cflag, old_cflag; 654 unsigned int cflag, old_cflag;
660 unsigned int bits; 655 unsigned int bits;
661 unsigned int modem_ctl[4]; 656 unsigned int modem_ctl[4];
662 657
663 dbg("%s - port %d", __func__, port->number); 658 dev_dbg(dev, "%s - port %d\n", __func__, port->number);
664 659
665 if (!tty) 660 if (!tty)
666 return; 661 return;
@@ -678,34 +673,31 @@ static void cp210x_set_termios(struct tty_struct *tty,
678 switch (cflag & CSIZE) { 673 switch (cflag & CSIZE) {
679 case CS5: 674 case CS5:
680 bits |= BITS_DATA_5; 675 bits |= BITS_DATA_5;
681 dbg("%s - data bits = 5", __func__); 676 dev_dbg(dev, "%s - data bits = 5\n", __func__);
682 break; 677 break;
683 case CS6: 678 case CS6:
684 bits |= BITS_DATA_6; 679 bits |= BITS_DATA_6;
685 dbg("%s - data bits = 6", __func__); 680 dev_dbg(dev, "%s - data bits = 6\n", __func__);
686 break; 681 break;
687 case CS7: 682 case CS7:
688 bits |= BITS_DATA_7; 683 bits |= BITS_DATA_7;
689 dbg("%s - data bits = 7", __func__); 684 dev_dbg(dev, "%s - data bits = 7\n", __func__);
690 break; 685 break;
691 case CS8: 686 case CS8:
692 bits |= BITS_DATA_8; 687 bits |= BITS_DATA_8;
693 dbg("%s - data bits = 8", __func__); 688 dev_dbg(dev, "%s - data bits = 8\n", __func__);
694 break; 689 break;
695 /*case CS9: 690 /*case CS9:
696 bits |= BITS_DATA_9; 691 bits |= BITS_DATA_9;
697 dbg("%s - data bits = 9", __func__); 692 dev_dbg(dev, "%s - data bits = 9\n", __func__);
698 break;*/ 693 break;*/
699 default: 694 default:
700 dbg("cp210x driver does not " 695 dev_dbg(dev, "cp210x driver does not support the number of bits requested, using 8 bit mode\n");
701 "support the number of bits requested,"
702 " using 8 bit mode");
703 bits |= BITS_DATA_8; 696 bits |= BITS_DATA_8;
704 break; 697 break;
705 } 698 }
706 if (cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2)) 699 if (cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2))
707 dbg("Number of data bits requested " 700 dev_dbg(dev, "Number of data bits requested not supported by device\n");
708 "not supported by device");
709 } 701 }
710 702
711 if ((cflag & (PARENB|PARODD|CMSPAR)) != 703 if ((cflag & (PARENB|PARODD|CMSPAR)) !=
@@ -714,25 +706,25 @@ static void cp210x_set_termios(struct tty_struct *tty,
714 bits &= ~BITS_PARITY_MASK; 706 bits &= ~BITS_PARITY_MASK;
715 if (cflag & PARENB) { 707 if (cflag & PARENB) {
716 if (cflag & CMSPAR) { 708 if (cflag & CMSPAR) {
717 if (cflag & PARODD) { 709 if (cflag & PARODD) {
718 bits |= BITS_PARITY_MARK; 710 bits |= BITS_PARITY_MARK;
719 dbg("%s - parity = MARK", __func__); 711 dev_dbg(dev, "%s - parity = MARK\n", __func__);
720 } else { 712 } else {
721 bits |= BITS_PARITY_SPACE; 713 bits |= BITS_PARITY_SPACE;
722 dbg("%s - parity = SPACE", __func__); 714 dev_dbg(dev, "%s - parity = SPACE\n", __func__);
723 } 715 }
724 } else { 716 } else {
725 if (cflag & PARODD) { 717 if (cflag & PARODD) {
726 bits |= BITS_PARITY_ODD; 718 bits |= BITS_PARITY_ODD;
727 dbg("%s - parity = ODD", __func__); 719 dev_dbg(dev, "%s - parity = ODD\n", __func__);
728 } else { 720 } else {
729 bits |= BITS_PARITY_EVEN; 721 bits |= BITS_PARITY_EVEN;
730 dbg("%s - parity = EVEN", __func__); 722 dev_dbg(dev, "%s - parity = EVEN\n", __func__);
731 } 723 }
732 } 724 }
733 } 725 }
734 if (cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2)) 726 if (cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2))
735 dbg("Parity mode not supported by device"); 727 dev_dbg(dev, "Parity mode not supported by device\n");
736 } 728 }
737 729
738 if ((cflag & CSTOPB) != (old_cflag & CSTOPB)) { 730 if ((cflag & CSTOPB) != (old_cflag & CSTOPB)) {
@@ -740,37 +732,36 @@ static void cp210x_set_termios(struct tty_struct *tty,
740 bits &= ~BITS_STOP_MASK; 732 bits &= ~BITS_STOP_MASK;
741 if (cflag & CSTOPB) { 733 if (cflag & CSTOPB) {
742 bits |= BITS_STOP_2; 734 bits |= BITS_STOP_2;
743 dbg("%s - stop bits = 2", __func__); 735 dev_dbg(dev, "%s - stop bits = 2\n", __func__);
744 } else { 736 } else {
745 bits |= BITS_STOP_1; 737 bits |= BITS_STOP_1;
746 dbg("%s - stop bits = 1", __func__); 738 dev_dbg(dev, "%s - stop bits = 1\n", __func__);
747 } 739 }
748 if (cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2)) 740 if (cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2))
749 dbg("Number of stop bits requested " 741 dev_dbg(dev, "Number of stop bits requested not supported by device\n");
750 "not supported by device");
751 } 742 }
752 743
753 if ((cflag & CRTSCTS) != (old_cflag & CRTSCTS)) { 744 if ((cflag & CRTSCTS) != (old_cflag & CRTSCTS)) {
754 cp210x_get_config(port, CP210X_GET_FLOW, modem_ctl, 16); 745 cp210x_get_config(port, CP210X_GET_FLOW, modem_ctl, 16);
755 dbg("%s - read modem controls = 0x%.4x 0x%.4x 0x%.4x 0x%.4x", 746 dev_dbg(dev, "%s - read modem controls = 0x%.4x 0x%.4x 0x%.4x 0x%.4x\n",
756 __func__, modem_ctl[0], modem_ctl[1], 747 __func__, modem_ctl[0], modem_ctl[1],
757 modem_ctl[2], modem_ctl[3]); 748 modem_ctl[2], modem_ctl[3]);
758 749
759 if (cflag & CRTSCTS) { 750 if (cflag & CRTSCTS) {
760 modem_ctl[0] &= ~0x7B; 751 modem_ctl[0] &= ~0x7B;
761 modem_ctl[0] |= 0x09; 752 modem_ctl[0] |= 0x09;
762 modem_ctl[1] = 0x80; 753 modem_ctl[1] = 0x80;
763 dbg("%s - flow control = CRTSCTS", __func__); 754 dev_dbg(dev, "%s - flow control = CRTSCTS\n", __func__);
764 } else { 755 } else {
765 modem_ctl[0] &= ~0x7B; 756 modem_ctl[0] &= ~0x7B;
766 modem_ctl[0] |= 0x01; 757 modem_ctl[0] |= 0x01;
767 modem_ctl[1] |= 0x40; 758 modem_ctl[1] |= 0x40;
768 dbg("%s - flow control = NONE", __func__); 759 dev_dbg(dev, "%s - flow control = NONE\n", __func__);
769 } 760 }
770 761
771 dbg("%s - write modem controls = 0x%.4x 0x%.4x 0x%.4x 0x%.4x", 762 dev_dbg(dev, "%s - write modem controls = 0x%.4x 0x%.4x 0x%.4x 0x%.4x\n",
772 __func__, modem_ctl[0], modem_ctl[1], 763 __func__, modem_ctl[0], modem_ctl[1],
773 modem_ctl[2], modem_ctl[3]); 764 modem_ctl[2], modem_ctl[3]);
774 cp210x_set_config(port, CP210X_SET_FLOW, modem_ctl, 16); 765 cp210x_set_config(port, CP210X_SET_FLOW, modem_ctl, 16);
775 } 766 }
776 767
@@ -805,7 +796,7 @@ static int cp210x_tiocmset_port(struct usb_serial_port *port,
805 control |= CONTROL_WRITE_DTR; 796 control |= CONTROL_WRITE_DTR;
806 } 797 }
807 798
808 dbg("%s - control = 0x%.4x", __func__, control); 799 dev_dbg(&port->dev, "%s - control = 0x%.4x\n", __func__, control);
809 800
810 return cp210x_set_config(port, CP210X_SET_MHS, &control, 2); 801 return cp210x_set_config(port, CP210X_SET_MHS, &control, 2);
811} 802}
@@ -833,7 +824,7 @@ static int cp210x_tiocmget (struct tty_struct *tty)
833 |((control & CONTROL_RING)? TIOCM_RI : 0) 824 |((control & CONTROL_RING)? TIOCM_RI : 0)
834 |((control & CONTROL_DCD) ? TIOCM_CD : 0); 825 |((control & CONTROL_DCD) ? TIOCM_CD : 0);
835 826
836 dbg("%s - control = 0x%.2x", __func__, control); 827 dev_dbg(&port->dev, "%s - control = 0x%.2x\n", __func__, control);
837 828
838 return result; 829 return result;
839} 830}
@@ -847,8 +838,8 @@ static void cp210x_break_ctl (struct tty_struct *tty, int break_state)
847 state = BREAK_OFF; 838 state = BREAK_OFF;
848 else 839 else
849 state = BREAK_ON; 840 state = BREAK_ON;
850 dbg("%s - turning break %s", __func__, 841 dev_dbg(&port->dev, "%s - turning break %s\n", __func__,
851 state == BREAK_OFF ? "off" : "on"); 842 state == BREAK_OFF ? "off" : "on");
852 cp210x_set_config(port, CP210X_SET_BREAK, &state, 2); 843 cp210x_set_config(port, CP210X_SET_BREAK, &state, 2);
853} 844}
854 845
@@ -865,7 +856,6 @@ static int cp210x_startup(struct usb_serial *serial)
865 if (!port_priv) 856 if (!port_priv)
866 return -ENOMEM; 857 return -ENOMEM;
867 858
868 memset(port_priv, 0x00, sizeof(*port_priv));
869 port_priv->bInterfaceNumber = 859 port_priv->bInterfaceNumber =
870 serial->interface->cur_altsetting->desc.bInterfaceNumber; 860 serial->interface->cur_altsetting->desc.bInterfaceNumber;
871 861
@@ -892,6 +882,3 @@ module_usb_serial_driver(serial_drivers, id_table);
892MODULE_DESCRIPTION(DRIVER_DESC); 882MODULE_DESCRIPTION(DRIVER_DESC);
893MODULE_VERSION(DRIVER_VERSION); 883MODULE_VERSION(DRIVER_VERSION);
894MODULE_LICENSE("GPL"); 884MODULE_LICENSE("GPL");
895
896module_param(debug, bool, S_IRUGO | S_IWUSR);
897MODULE_PARM_DESC(debug, "Enable verbose debugging messages");
diff --git a/drivers/usb/serial/cyberjack.c b/drivers/usb/serial/cyberjack.c
index 3aa0b530f68e..2a7aecc72237 100644
--- a/drivers/usb/serial/cyberjack.c
+++ b/drivers/usb/serial/cyberjack.c
@@ -43,8 +43,6 @@
43 43
44#define CYBERJACK_LOCAL_BUF_SIZE 32 44#define CYBERJACK_LOCAL_BUF_SIZE 32
45 45
46static bool debug;
47
48/* 46/*
49 * Version Information 47 * Version Information
50 */ 48 */
@@ -136,7 +134,8 @@ static int cyberjack_startup(struct usb_serial *serial)
136 if (result) 134 if (result)
137 dev_err(&serial->dev->dev, 135 dev_err(&serial->dev->dev,
138 "usb_submit_urb(read int) failed\n"); 136 "usb_submit_urb(read int) failed\n");
139 dbg("%s - usb_submit_urb(int urb)", __func__); 137 dev_dbg(&serial->dev->dev, "%s - usb_submit_urb(int urb)\n",
138 __func__);
140 } 139 }
141 140
142 return 0; 141 return 0;
@@ -167,7 +166,7 @@ static int cyberjack_open(struct tty_struct *tty,
167 unsigned long flags; 166 unsigned long flags;
168 int result = 0; 167 int result = 0;
169 168
170 dbg("%s - usb_clear_halt", __func__); 169 dev_dbg(&port->dev, "%s - usb_clear_halt\n", __func__);
171 usb_clear_halt(port->serial->dev, port->write_urb->pipe); 170 usb_clear_halt(port->serial->dev, port->write_urb->pipe);
172 171
173 priv = usb_get_serial_port_data(port); 172 priv = usb_get_serial_port_data(port);
@@ -192,18 +191,19 @@ static void cyberjack_close(struct usb_serial_port *port)
192static int cyberjack_write(struct tty_struct *tty, 191static int cyberjack_write(struct tty_struct *tty,
193 struct usb_serial_port *port, const unsigned char *buf, int count) 192 struct usb_serial_port *port, const unsigned char *buf, int count)
194{ 193{
194 struct device *dev = &port->dev;
195 struct cyberjack_private *priv = usb_get_serial_port_data(port); 195 struct cyberjack_private *priv = usb_get_serial_port_data(port);
196 unsigned long flags; 196 unsigned long flags;
197 int result; 197 int result;
198 int wrexpected; 198 int wrexpected;
199 199
200 if (count == 0) { 200 if (count == 0) {
201 dbg("%s - write request of 0 bytes", __func__); 201 dev_dbg(dev, "%s - write request of 0 bytes\n", __func__);
202 return 0; 202 return 0;
203 } 203 }
204 204
205 if (!test_and_clear_bit(0, &port->write_urbs_free)) { 205 if (!test_and_clear_bit(0, &port->write_urbs_free)) {
206 dbg("%s - already writing", __func__); 206 dev_dbg(dev, "%s - already writing\n", __func__);
207 return 0; 207 return 0;
208 } 208 }
209 209
@@ -220,13 +220,12 @@ static int cyberjack_write(struct tty_struct *tty,
220 /* Copy data */ 220 /* Copy data */
221 memcpy(priv->wrbuf + priv->wrfilled, buf, count); 221 memcpy(priv->wrbuf + priv->wrfilled, buf, count);
222 222
223 usb_serial_debug_data(debug, &port->dev, __func__, count, 223 usb_serial_debug_data(dev, __func__, count, priv->wrbuf + priv->wrfilled);
224 priv->wrbuf + priv->wrfilled);
225 priv->wrfilled += count; 224 priv->wrfilled += count;
226 225
227 if (priv->wrfilled >= 3) { 226 if (priv->wrfilled >= 3) {
228 wrexpected = ((int)priv->wrbuf[2]<<8)+priv->wrbuf[1]+3; 227 wrexpected = ((int)priv->wrbuf[2]<<8)+priv->wrbuf[1]+3;
229 dbg("%s - expected data: %d", __func__, wrexpected); 228 dev_dbg(dev, "%s - expected data: %d\n", __func__, wrexpected);
230 } else 229 } else
231 wrexpected = sizeof(priv->wrbuf); 230 wrexpected = sizeof(priv->wrbuf);
232 231
@@ -234,7 +233,7 @@ static int cyberjack_write(struct tty_struct *tty,
234 /* We have enough data to begin transmission */ 233 /* We have enough data to begin transmission */
235 int length; 234 int length;
236 235
237 dbg("%s - transmitting data (frame 1)", __func__); 236 dev_dbg(dev, "%s - transmitting data (frame 1)\n", __func__);
238 length = (wrexpected > port->bulk_out_size) ? 237 length = (wrexpected > port->bulk_out_size) ?
239 port->bulk_out_size : wrexpected; 238 port->bulk_out_size : wrexpected;
240 239
@@ -258,11 +257,11 @@ static int cyberjack_write(struct tty_struct *tty,
258 return 0; 257 return 0;
259 } 258 }
260 259
261 dbg("%s - priv->wrsent=%d", __func__, priv->wrsent); 260 dev_dbg(dev, "%s - priv->wrsent=%d\n", __func__, priv->wrsent);
262 dbg("%s - priv->wrfilled=%d", __func__, priv->wrfilled); 261 dev_dbg(dev, "%s - priv->wrfilled=%d\n", __func__, priv->wrfilled);
263 262
264 if (priv->wrsent >= priv->wrfilled) { 263 if (priv->wrsent >= priv->wrfilled) {
265 dbg("%s - buffer cleaned", __func__); 264 dev_dbg(dev, "%s - buffer cleaned\n", __func__);
266 memset(priv->wrbuf, 0, sizeof(priv->wrbuf)); 265 memset(priv->wrbuf, 0, sizeof(priv->wrbuf));
267 priv->wrfilled = 0; 266 priv->wrfilled = 0;
268 priv->wrsent = 0; 267 priv->wrsent = 0;
@@ -284,6 +283,7 @@ static void cyberjack_read_int_callback(struct urb *urb)
284{ 283{
285 struct usb_serial_port *port = urb->context; 284 struct usb_serial_port *port = urb->context;
286 struct cyberjack_private *priv = usb_get_serial_port_data(port); 285 struct cyberjack_private *priv = usb_get_serial_port_data(port);
286 struct device *dev = &port->dev;
287 unsigned char *data = urb->transfer_buffer; 287 unsigned char *data = urb->transfer_buffer;
288 int status = urb->status; 288 int status = urb->status;
289 int result; 289 int result;
@@ -292,8 +292,7 @@ static void cyberjack_read_int_callback(struct urb *urb)
292 if (status) 292 if (status)
293 return; 293 return;
294 294
295 usb_serial_debug_data(debug, &port->dev, __func__, 295 usb_serial_debug_data(dev, __func__, urb->actual_length, data);
296 urb->actual_length, data);
297 296
298 /* React only to interrupts signaling a bulk_in transfer */ 297 /* React only to interrupts signaling a bulk_in transfer */
299 if (urb->actual_length == 4 && data[0] == 0x01) { 298 if (urb->actual_length == 4 && data[0] == 0x01) {
@@ -307,7 +306,7 @@ static void cyberjack_read_int_callback(struct urb *urb)
307 old_rdtodo = priv->rdtodo; 306 old_rdtodo = priv->rdtodo;
308 307
309 if (old_rdtodo + size < old_rdtodo) { 308 if (old_rdtodo + size < old_rdtodo) {
310 dbg("To many bulk_in urbs to do."); 309 dev_dbg(dev, "To many bulk_in urbs to do.\n");
311 spin_unlock(&priv->lock); 310 spin_unlock(&priv->lock);
312 goto resubmit; 311 goto resubmit;
313 } 312 }
@@ -315,17 +314,16 @@ static void cyberjack_read_int_callback(struct urb *urb)
315 /* "+=" is probably more fault tollerant than "=" */ 314 /* "+=" is probably more fault tollerant than "=" */
316 priv->rdtodo += size; 315 priv->rdtodo += size;
317 316
318 dbg("%s - rdtodo: %d", __func__, priv->rdtodo); 317 dev_dbg(dev, "%s - rdtodo: %d\n", __func__, priv->rdtodo);
319 318
320 spin_unlock(&priv->lock); 319 spin_unlock(&priv->lock);
321 320
322 if (!old_rdtodo) { 321 if (!old_rdtodo) {
323 result = usb_submit_urb(port->read_urb, GFP_ATOMIC); 322 result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
324 if (result) 323 if (result)
325 dev_err(&port->dev, "%s - failed resubmitting " 324 dev_err(dev, "%s - failed resubmitting read urb, error %d\n",
326 "read urb, error %d\n",
327 __func__, result); 325 __func__, result);
328 dbg("%s - usb_submit_urb(read urb)", __func__); 326 dev_dbg(dev, "%s - usb_submit_urb(read urb)\n", __func__);
329 } 327 }
330 } 328 }
331 329
@@ -333,30 +331,30 @@ resubmit:
333 result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); 331 result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC);
334 if (result) 332 if (result)
335 dev_err(&port->dev, "usb_submit_urb(read int) failed\n"); 333 dev_err(&port->dev, "usb_submit_urb(read int) failed\n");
336 dbg("%s - usb_submit_urb(int urb)", __func__); 334 dev_dbg(dev, "%s - usb_submit_urb(int urb)\n", __func__);
337} 335}
338 336
339static void cyberjack_read_bulk_callback(struct urb *urb) 337static void cyberjack_read_bulk_callback(struct urb *urb)
340{ 338{
341 struct usb_serial_port *port = urb->context; 339 struct usb_serial_port *port = urb->context;
342 struct cyberjack_private *priv = usb_get_serial_port_data(port); 340 struct cyberjack_private *priv = usb_get_serial_port_data(port);
341 struct device *dev = &port->dev;
343 struct tty_struct *tty; 342 struct tty_struct *tty;
344 unsigned char *data = urb->transfer_buffer; 343 unsigned char *data = urb->transfer_buffer;
345 short todo; 344 short todo;
346 int result; 345 int result;
347 int status = urb->status; 346 int status = urb->status;
348 347
349 usb_serial_debug_data(debug, &port->dev, __func__, 348 usb_serial_debug_data(dev, __func__, urb->actual_length, data);
350 urb->actual_length, data);
351 if (status) { 349 if (status) {
352 dbg("%s - nonzero read bulk status received: %d", 350 dev_dbg(dev, "%s - nonzero read bulk status received: %d\n",
353 __func__, status); 351 __func__, status);
354 return; 352 return;
355 } 353 }
356 354
357 tty = tty_port_tty_get(&port->port); 355 tty = tty_port_tty_get(&port->port);
358 if (!tty) { 356 if (!tty) {
359 dbg("%s - ignoring since device not open", __func__); 357 dev_dbg(dev, "%s - ignoring since device not open\n", __func__);
360 return; 358 return;
361 } 359 }
362 if (urb->actual_length) { 360 if (urb->actual_length) {
@@ -376,15 +374,15 @@ static void cyberjack_read_bulk_callback(struct urb *urb)
376 374
377 spin_unlock(&priv->lock); 375 spin_unlock(&priv->lock);
378 376
379 dbg("%s - rdtodo: %d", __func__, todo); 377 dev_dbg(dev, "%s - rdtodo: %d\n", __func__, todo);
380 378
381 /* Continue to read if we have still urbs to do. */ 379 /* Continue to read if we have still urbs to do. */
382 if (todo /* || (urb->actual_length==port->bulk_in_endpointAddress)*/) { 380 if (todo /* || (urb->actual_length==port->bulk_in_endpointAddress)*/) {
383 result = usb_submit_urb(port->read_urb, GFP_ATOMIC); 381 result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
384 if (result) 382 if (result)
385 dev_err(&port->dev, "%s - failed resubmitting read " 383 dev_err(dev, "%s - failed resubmitting read urb, error %d\n",
386 "urb, error %d\n", __func__, result); 384 __func__, result);
387 dbg("%s - usb_submit_urb(read urb)", __func__); 385 dev_dbg(dev, "%s - usb_submit_urb(read urb)\n", __func__);
388 } 386 }
389} 387}
390 388
@@ -392,12 +390,13 @@ static void cyberjack_write_bulk_callback(struct urb *urb)
392{ 390{
393 struct usb_serial_port *port = urb->context; 391 struct usb_serial_port *port = urb->context;
394 struct cyberjack_private *priv = usb_get_serial_port_data(port); 392 struct cyberjack_private *priv = usb_get_serial_port_data(port);
393 struct device *dev = &port->dev;
395 int status = urb->status; 394 int status = urb->status;
396 395
397 set_bit(0, &port->write_urbs_free); 396 set_bit(0, &port->write_urbs_free);
398 if (status) { 397 if (status) {
399 dbg("%s - nonzero write bulk status received: %d", 398 dev_dbg(dev, "%s - nonzero write bulk status received: %d\n",
400 __func__, status); 399 __func__, status);
401 return; 400 return;
402 } 401 }
403 402
@@ -407,7 +406,7 @@ static void cyberjack_write_bulk_callback(struct urb *urb)
407 if (priv->wrfilled) { 406 if (priv->wrfilled) {
408 int length, blksize, result; 407 int length, blksize, result;
409 408
410 dbg("%s - transmitting data (frame n)", __func__); 409 dev_dbg(dev, "%s - transmitting data (frame n)\n", __func__);
411 410
412 length = ((priv->wrfilled - priv->wrsent) > port->bulk_out_size) ? 411 length = ((priv->wrfilled - priv->wrsent) > port->bulk_out_size) ?
413 port->bulk_out_size : (priv->wrfilled - priv->wrsent); 412 port->bulk_out_size : (priv->wrfilled - priv->wrsent);
@@ -422,8 +421,7 @@ static void cyberjack_write_bulk_callback(struct urb *urb)
422 /* send the data out the bulk port */ 421 /* send the data out the bulk port */
423 result = usb_submit_urb(port->write_urb, GFP_ATOMIC); 422 result = usb_submit_urb(port->write_urb, GFP_ATOMIC);
424 if (result) { 423 if (result) {
425 dev_err(&port->dev, 424 dev_err(dev, "%s - failed submitting write urb, error %d\n",
426 "%s - failed submitting write urb, error %d\n",
427 __func__, result); 425 __func__, result);
428 /* Throw away data. No better idea what to do with it. */ 426 /* Throw away data. No better idea what to do with it. */
429 priv->wrfilled = 0; 427 priv->wrfilled = 0;
@@ -431,14 +429,14 @@ static void cyberjack_write_bulk_callback(struct urb *urb)
431 goto exit; 429 goto exit;
432 } 430 }
433 431
434 dbg("%s - priv->wrsent=%d", __func__, priv->wrsent); 432 dev_dbg(dev, "%s - priv->wrsent=%d\n", __func__, priv->wrsent);
435 dbg("%s - priv->wrfilled=%d", __func__, priv->wrfilled); 433 dev_dbg(dev, "%s - priv->wrfilled=%d\n", __func__, priv->wrfilled);
436 434
437 blksize = ((int)priv->wrbuf[2]<<8)+priv->wrbuf[1]+3; 435 blksize = ((int)priv->wrbuf[2]<<8)+priv->wrbuf[1]+3;
438 436
439 if (priv->wrsent >= priv->wrfilled || 437 if (priv->wrsent >= priv->wrfilled ||
440 priv->wrsent >= blksize) { 438 priv->wrsent >= blksize) {
441 dbg("%s - buffer cleaned", __func__); 439 dev_dbg(dev, "%s - buffer cleaned\n", __func__);
442 memset(priv->wrbuf, 0, sizeof(priv->wrbuf)); 440 memset(priv->wrbuf, 0, sizeof(priv->wrbuf));
443 priv->wrfilled = 0; 441 priv->wrfilled = 0;
444 priv->wrsent = 0; 442 priv->wrsent = 0;
@@ -456,6 +454,3 @@ MODULE_AUTHOR(DRIVER_AUTHOR);
456MODULE_DESCRIPTION(DRIVER_DESC); 454MODULE_DESCRIPTION(DRIVER_DESC);
457MODULE_VERSION(DRIVER_VERSION); 455MODULE_VERSION(DRIVER_VERSION);
458MODULE_LICENSE("GPL"); 456MODULE_LICENSE("GPL");
459
460module_param(debug, bool, S_IRUGO | S_IWUSR);
461MODULE_PARM_DESC(debug, "Debug enabled or not");
diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c
index be34f153e566..1befce21e173 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);
diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c
index afd9d2ec577b..c86f68c6b078 100644
--- a/drivers/usb/serial/digi_acceleport.c
+++ b/drivers/usb/serial/digi_acceleport.c
@@ -249,10 +249,6 @@ static int digi_read_inb_callback(struct urb *urb);
249static int digi_read_oob_callback(struct urb *urb); 249static int digi_read_oob_callback(struct urb *urb);
250 250
251 251
252/* Statics */
253
254static bool debug;
255
256static const struct usb_device_id id_table_combined[] = { 252static const struct usb_device_id id_table_combined[] = {
257 { USB_DEVICE(DIGI_VENDOR_ID, DIGI_2_ID) }, 253 { USB_DEVICE(DIGI_VENDOR_ID, DIGI_2_ID) },
258 { USB_DEVICE(DIGI_VENDOR_ID, DIGI_4_ID) }, 254 { USB_DEVICE(DIGI_VENDOR_ID, DIGI_4_ID) },
@@ -404,14 +400,15 @@ static void digi_wakeup_write(struct usb_serial_port *port)
404static int digi_write_oob_command(struct usb_serial_port *port, 400static int digi_write_oob_command(struct usb_serial_port *port,
405 unsigned char *buf, int count, int interruptible) 401 unsigned char *buf, int count, int interruptible)
406{ 402{
407
408 int ret = 0; 403 int ret = 0;
409 int len; 404 int len;
410 struct usb_serial_port *oob_port = (struct usb_serial_port *)((struct digi_serial *)(usb_get_serial_data(port->serial)))->ds_oob_port; 405 struct usb_serial_port *oob_port = (struct usb_serial_port *)((struct digi_serial *)(usb_get_serial_data(port->serial)))->ds_oob_port;
411 struct digi_port *oob_priv = usb_get_serial_port_data(oob_port); 406 struct digi_port *oob_priv = usb_get_serial_port_data(oob_port);
412 unsigned long flags = 0; 407 unsigned long flags = 0;
413 408
414 dbg("digi_write_oob_command: TOP: port=%d, count=%d", oob_priv->dp_port_num, count); 409 dev_dbg(&port->dev,
410 "digi_write_oob_command: TOP: port=%d, count=%d\n",
411 oob_priv->dp_port_num, count);
415 412
416 spin_lock_irqsave(&oob_priv->dp_port_lock, flags); 413 spin_lock_irqsave(&oob_priv->dp_port_lock, flags);
417 while (count > 0) { 414 while (count > 0) {
@@ -467,7 +464,7 @@ static int digi_write_inb_command(struct usb_serial_port *port,
467 unsigned char *data = port->write_urb->transfer_buffer; 464 unsigned char *data = port->write_urb->transfer_buffer;
468 unsigned long flags = 0; 465 unsigned long flags = 0;
469 466
470 dbg("digi_write_inb_command: TOP: port=%d, count=%d", 467 dev_dbg(&port->dev, "digi_write_inb_command: TOP: port=%d, count=%d\n",
471 priv->dp_port_num, count); 468 priv->dp_port_num, count);
472 469
473 if (timeout) 470 if (timeout)
@@ -549,7 +546,8 @@ static int digi_set_modem_signals(struct usb_serial_port *port,
549 unsigned long flags = 0; 546 unsigned long flags = 0;
550 547
551 548
552 dbg("digi_set_modem_signals: TOP: port=%d, modem_signals=0x%x", 549 dev_dbg(&port->dev,
550 "digi_set_modem_signals: TOP: port=%d, modem_signals=0x%x\n",
553 port_priv->dp_port_num, modem_signals); 551 port_priv->dp_port_num, modem_signals);
554 552
555 spin_lock_irqsave(&oob_priv->dp_port_lock, flags); 553 spin_lock_irqsave(&oob_priv->dp_port_lock, flags);
@@ -687,6 +685,7 @@ static void digi_set_termios(struct tty_struct *tty,
687 struct usb_serial_port *port, struct ktermios *old_termios) 685 struct usb_serial_port *port, struct ktermios *old_termios)
688{ 686{
689 struct digi_port *priv = usb_get_serial_port_data(port); 687 struct digi_port *priv = usb_get_serial_port_data(port);
688 struct device *dev = &port->dev;
690 unsigned int iflag = tty->termios.c_iflag; 689 unsigned int iflag = tty->termios.c_iflag;
691 unsigned int cflag = tty->termios.c_cflag; 690 unsigned int cflag = tty->termios.c_cflag;
692 unsigned int old_iflag = old_termios->c_iflag; 691 unsigned int old_iflag = old_termios->c_iflag;
@@ -697,7 +696,9 @@ static void digi_set_termios(struct tty_struct *tty,
697 int i = 0; 696 int i = 0;
698 speed_t baud; 697 speed_t baud;
699 698
700 dbg("digi_set_termios: TOP: port=%d, iflag=0x%x, old_iflag=0x%x, cflag=0x%x, old_cflag=0x%x", priv->dp_port_num, iflag, old_iflag, cflag, old_cflag); 699 dev_dbg(dev,
700 "digi_set_termios: TOP: port=%d, iflag=0x%x, old_iflag=0x%x, cflag=0x%x, old_cflag=0x%x\n",
701 priv->dp_port_num, iflag, old_iflag, cflag, old_cflag);
701 702
702 /* set baud rate */ 703 /* set baud rate */
703 baud = tty_get_baud_rate(tty); 704 baud = tty_get_baud_rate(tty);
@@ -773,7 +774,8 @@ static void digi_set_termios(struct tty_struct *tty,
773 case CS7: arg = DIGI_WORD_SIZE_7; break; 774 case CS7: arg = DIGI_WORD_SIZE_7; break;
774 case CS8: arg = DIGI_WORD_SIZE_8; break; 775 case CS8: arg = DIGI_WORD_SIZE_8; break;
775 default: 776 default:
776 dbg("digi_set_termios: can't handle word size %d", 777 dev_dbg(dev,
778 "digi_set_termios: can't handle word size %d\n",
777 (cflag&CSIZE)); 779 (cflag&CSIZE));
778 break; 780 break;
779 } 781 }
@@ -866,7 +868,7 @@ static void digi_set_termios(struct tty_struct *tty,
866 } 868 }
867 ret = digi_write_oob_command(port, buf, i, 1); 869 ret = digi_write_oob_command(port, buf, i, 1);
868 if (ret != 0) 870 if (ret != 0)
869 dbg("digi_set_termios: write oob failed, ret=%d", ret); 871 dev_dbg(dev, "digi_set_termios: write oob failed, ret=%d\n", ret);
870 tty_encode_baud_rate(tty, baud, baud); 872 tty_encode_baud_rate(tty, baud, baud);
871} 873}
872 874
@@ -922,7 +924,8 @@ static int digi_write(struct tty_struct *tty, struct usb_serial_port *port,
922 unsigned char *data = port->write_urb->transfer_buffer; 924 unsigned char *data = port->write_urb->transfer_buffer;
923 unsigned long flags = 0; 925 unsigned long flags = 0;
924 926
925 dbg("digi_write: TOP: port=%d, count=%d, in_interrupt=%ld", 927 dev_dbg(&port->dev,
928 "digi_write: TOP: port=%d, count=%d, in_interrupt=%ld\n",
926 priv->dp_port_num, count, in_interrupt()); 929 priv->dp_port_num, count, in_interrupt());
927 930
928 /* copy user data (which can sleep) before getting spin lock */ 931 /* copy user data (which can sleep) before getting spin lock */
@@ -981,7 +984,7 @@ static int digi_write(struct tty_struct *tty, struct usb_serial_port *port,
981 dev_err_console(port, 984 dev_err_console(port,
982 "%s: usb_submit_urb failed, ret=%d, port=%d\n", 985 "%s: usb_submit_urb failed, ret=%d, port=%d\n",
983 __func__, ret, priv->dp_port_num); 986 __func__, ret, priv->dp_port_num);
984 dbg("digi_write: returning %d", ret); 987 dev_dbg(&port->dev, "digi_write: returning %d\n", ret);
985 return ret; 988 return ret;
986 989
987} 990}
@@ -1012,7 +1015,7 @@ static void digi_write_bulk_callback(struct urb *urb)
1012 1015
1013 /* handle oob callback */ 1016 /* handle oob callback */
1014 if (priv->dp_port_num == serial_priv->ds_oob_port_num) { 1017 if (priv->dp_port_num == serial_priv->ds_oob_port_num) {
1015 dbg("digi_write_bulk_callback: oob callback"); 1018 dev_dbg(&port->dev, "digi_write_bulk_callback: oob callback\n");
1016 spin_lock(&priv->dp_port_lock); 1019 spin_lock(&priv->dp_port_lock);
1017 priv->dp_write_urb_in_use = 0; 1020 priv->dp_write_urb_in_use = 0;
1018 wake_up_interruptible(&port->write_wait); 1021 wake_up_interruptible(&port->write_wait);
@@ -1066,7 +1069,7 @@ static int digi_write_room(struct tty_struct *tty)
1066 room = port->bulk_out_size - 2 - priv->dp_out_buf_len; 1069 room = port->bulk_out_size - 2 - priv->dp_out_buf_len;
1067 1070
1068 spin_unlock_irqrestore(&priv->dp_port_lock, flags); 1071 spin_unlock_irqrestore(&priv->dp_port_lock, flags);
1069 dbg("digi_write_room: port=%d, room=%d", priv->dp_port_num, room); 1072 dev_dbg(&port->dev, "digi_write_room: port=%d, room=%d\n", priv->dp_port_num, room);
1070 return room; 1073 return room;
1071 1074
1072} 1075}
@@ -1077,12 +1080,12 @@ static int digi_chars_in_buffer(struct tty_struct *tty)
1077 struct digi_port *priv = usb_get_serial_port_data(port); 1080 struct digi_port *priv = usb_get_serial_port_data(port);
1078 1081
1079 if (priv->dp_write_urb_in_use) { 1082 if (priv->dp_write_urb_in_use) {
1080 dbg("digi_chars_in_buffer: port=%d, chars=%d", 1083 dev_dbg(&port->dev, "digi_chars_in_buffer: port=%d, chars=%d\n",
1081 priv->dp_port_num, port->bulk_out_size - 2); 1084 priv->dp_port_num, port->bulk_out_size - 2);
1082 /* return(port->bulk_out_size - 2); */ 1085 /* return(port->bulk_out_size - 2); */
1083 return 256; 1086 return 256;
1084 } else { 1087 } else {
1085 dbg("digi_chars_in_buffer: port=%d, chars=%d", 1088 dev_dbg(&port->dev, "digi_chars_in_buffer: port=%d, chars=%d\n",
1086 priv->dp_port_num, priv->dp_out_buf_len); 1089 priv->dp_port_num, priv->dp_out_buf_len);
1087 return priv->dp_out_buf_len; 1090 return priv->dp_out_buf_len;
1088 } 1091 }
@@ -1120,7 +1123,7 @@ static int digi_open(struct tty_struct *tty, struct usb_serial_port *port)
1120 1123
1121 ret = digi_write_oob_command(port, buf, 8, 1); 1124 ret = digi_write_oob_command(port, buf, 8, 1);
1122 if (ret != 0) 1125 if (ret != 0)
1123 dbg("digi_open: write oob failed, ret=%d", ret); 1126 dev_dbg(&port->dev, "digi_open: write oob failed, ret=%d\n", ret);
1124 1127
1125 /* set termios settings */ 1128 /* set termios settings */
1126 if (tty) { 1129 if (tty) {
@@ -1180,7 +1183,7 @@ static void digi_close(struct usb_serial_port *port)
1180 1183
1181 ret = digi_write_oob_command(port, buf, 20, 0); 1184 ret = digi_write_oob_command(port, buf, 20, 0);
1182 if (ret != 0) 1185 if (ret != 0)
1183 dbg("digi_close: write oob failed, ret=%d", ret); 1186 dev_dbg(&port->dev, "digi_close: write oob failed, ret=%d\n", ret);
1184 1187
1185 /* wait for final commands on oob port to complete */ 1188 /* wait for final commands on oob port to complete */
1186 prepare_to_wait(&priv->dp_flush_wait, &wait, 1189 prepare_to_wait(&priv->dp_flush_wait, &wait,
@@ -1448,9 +1451,9 @@ static int digi_read_inb_callback(struct urb *urb)
1448 tty_kref_put(tty); 1451 tty_kref_put(tty);
1449 1452
1450 if (opcode == DIGI_CMD_RECEIVE_DISABLE) 1453 if (opcode == DIGI_CMD_RECEIVE_DISABLE)
1451 dbg("%s: got RECEIVE_DISABLE", __func__); 1454 dev_dbg(&port->dev, "%s: got RECEIVE_DISABLE\n", __func__);
1452 else if (opcode != DIGI_CMD_RECEIVE_DATA) 1455 else if (opcode != DIGI_CMD_RECEIVE_DATA)
1453 dbg("%s: unknown opcode: %d", __func__, opcode); 1456 dev_dbg(&port->dev, "%s: unknown opcode: %d\n", __func__, opcode);
1454 1457
1455 return throttled ? 1 : 0; 1458 return throttled ? 1 : 0;
1456 1459
@@ -1484,7 +1487,7 @@ static int digi_read_oob_callback(struct urb *urb)
1484 status = ((unsigned char *)urb->transfer_buffer)[i++]; 1487 status = ((unsigned char *)urb->transfer_buffer)[i++];
1485 val = ((unsigned char *)urb->transfer_buffer)[i++]; 1488 val = ((unsigned char *)urb->transfer_buffer)[i++];
1486 1489
1487 dbg("digi_read_oob_callback: opcode=%d, line=%d, status=%d, val=%d", 1490 dev_dbg(&port->dev, "digi_read_oob_callback: opcode=%d, line=%d, status=%d, val=%d\n",
1488 opcode, line, status, val); 1491 opcode, line, status, val);
1489 1492
1490 if (status != 0 || line >= serial->type->num_ports) 1493 if (status != 0 || line >= serial->type->num_ports)
@@ -1552,6 +1555,3 @@ module_usb_serial_driver(serial_drivers, id_table_combined);
1552MODULE_AUTHOR(DRIVER_AUTHOR); 1555MODULE_AUTHOR(DRIVER_AUTHOR);
1553MODULE_DESCRIPTION(DRIVER_DESC); 1556MODULE_DESCRIPTION(DRIVER_DESC);
1554MODULE_LICENSE("GPL"); 1557MODULE_LICENSE("GPL");
1555
1556module_param(debug, bool, S_IRUGO | S_IWUSR);
1557MODULE_PARM_DESC(debug, "Debug enabled or not");
diff --git a/drivers/usb/serial/empeg.c b/drivers/usb/serial/empeg.c
index 34e86383090a..43ede4a1e12c 100644
--- a/drivers/usb/serial/empeg.c
+++ b/drivers/usb/serial/empeg.c
@@ -28,8 +28,6 @@
28#include <linux/usb.h> 28#include <linux/usb.h>
29#include <linux/usb/serial.h> 29#include <linux/usb/serial.h>
30 30
31static bool debug;
32
33/* 31/*
34 * Version Information 32 * Version Information
35 */ 33 */
@@ -134,6 +132,3 @@ module_usb_serial_driver(serial_drivers, id_table);
134MODULE_AUTHOR(DRIVER_AUTHOR); 132MODULE_AUTHOR(DRIVER_AUTHOR);
135MODULE_DESCRIPTION(DRIVER_DESC); 133MODULE_DESCRIPTION(DRIVER_DESC);
136MODULE_LICENSE("GPL"); 134MODULE_LICENSE("GPL");
137
138module_param(debug, bool, S_IRUGO | S_IWUSR);
139MODULE_PARM_DESC(debug, "Debug enabled or not");
diff --git a/drivers/usb/serial/ezusb.c b/drivers/usb/serial/ezusb.c
deleted file mode 100644
index 800e8eb60003..000000000000
--- a/drivers/usb/serial/ezusb.c
+++ /dev/null
@@ -1,59 +0,0 @@
1/*
2 * EZ-USB specific functions used by some of the USB to Serial drivers.
3 *
4 * Copyright (C) 1999 - 2002 Greg Kroah-Hartman (greg@kroah.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License version
8 * 2 as published by the Free Software Foundation.
9 */
10
11#include <linux/kernel.h>
12#include <linux/errno.h>
13#include <linux/init.h>
14#include <linux/slab.h>
15#include <linux/tty.h>
16#include <linux/module.h>
17#include <linux/usb.h>
18#include <linux/usb/serial.h>
19
20/* EZ-USB Control and Status Register. Bit 0 controls 8051 reset */
21#define CPUCS_REG 0x7F92
22
23int ezusb_writememory(struct usb_serial *serial, int address,
24 unsigned char *data, int length, __u8 request)
25{
26 int result;
27 unsigned char *transfer_buffer;
28
29 if (!serial->dev) {
30 printk(KERN_ERR "ezusb: %s - no physical device present, "
31 "failing.\n", __func__);
32 return -ENODEV;
33 }
34
35 transfer_buffer = kmemdup(data, length, GFP_KERNEL);
36 if (!transfer_buffer) {
37 dev_err(&serial->dev->dev, "%s - kmalloc(%d) failed.\n",
38 __func__, length);
39 return -ENOMEM;
40 }
41 result = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
42 request, 0x40, address, 0, transfer_buffer, length, 3000);
43 kfree(transfer_buffer);
44 return result;
45}
46EXPORT_SYMBOL_GPL(ezusb_writememory);
47
48int ezusb_set_reset(struct usb_serial *serial, unsigned char reset_bit)
49{
50 int response;
51
52 response = ezusb_writememory(serial, CPUCS_REG, &reset_bit, 1, 0xa0);
53 if (response < 0)
54 dev_err(&serial->dev->dev, "%s- %d failed\n",
55 __func__, reset_bit);
56 return response;
57}
58EXPORT_SYMBOL_GPL(ezusb_set_reset);
59
diff --git a/drivers/usb/serial/f81232.c b/drivers/usb/serial/f81232.c
index 79451ee12ca0..244477107e2f 100644
--- a/drivers/usb/serial/f81232.c
+++ b/drivers/usb/serial/f81232.c
@@ -25,8 +25,6 @@
25#include <linux/usb.h> 25#include <linux/usb.h>
26#include <linux/usb/serial.h> 26#include <linux/usb/serial.h>
27 27
28static bool debug;
29
30static const struct usb_device_id id_table[] = { 28static const struct usb_device_id id_table[] = {
31 { USB_DEVICE(0x1934, 0x0706) }, 29 { USB_DEVICE(0x1934, 0x0706) },
32 { } /* Terminating entry */ 30 { } /* Terminating entry */
@@ -85,7 +83,7 @@ static void f81232_read_int_callback(struct urb *urb)
85 goto exit; 83 goto exit;
86 } 84 }
87 85
88 usb_serial_debug_data(debug, &port->dev, __func__, 86 usb_serial_debug_data(&port->dev, __func__,
89 urb->actual_length, urb->transfer_buffer); 87 urb->actual_length, urb->transfer_buffer);
90 88
91 f81232_update_line_status(port, data, actual_length); 89 f81232_update_line_status(port, data, actual_length);
@@ -389,7 +387,3 @@ module_usb_serial_driver(serial_drivers, id_table);
389MODULE_DESCRIPTION("Fintek F81232 USB to serial adaptor driver"); 387MODULE_DESCRIPTION("Fintek F81232 USB to serial adaptor driver");
390MODULE_AUTHOR("Greg Kroah-Hartman <gregkh@linuxfoundation.org"); 388MODULE_AUTHOR("Greg Kroah-Hartman <gregkh@linuxfoundation.org");
391MODULE_LICENSE("GPL v2"); 389MODULE_LICENSE("GPL v2");
392
393module_param(debug, bool, S_IRUGO | S_IWUSR);
394MODULE_PARM_DESC(debug, "Debug enabled or not");
395
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 0c8d1c226273..be845873e23d 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -48,14 +48,9 @@
48#include "ftdi_sio.h" 48#include "ftdi_sio.h"
49#include "ftdi_sio_ids.h" 49#include "ftdi_sio_ids.h"
50 50
51/*
52 * Version Information
53 */
54#define DRIVER_VERSION "v1.6.0"
55#define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com>, Bill Ryder <bryder@sgi.com>, Kuba Ober <kuba@mareimbrium.org>, Andreas Mohr, Johan Hovold <jhovold@gmail.com>" 51#define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com>, Bill Ryder <bryder@sgi.com>, Kuba Ober <kuba@mareimbrium.org>, Andreas Mohr, Johan Hovold <jhovold@gmail.com>"
56#define DRIVER_DESC "USB FTDI Serial Converters Driver" 52#define DRIVER_DESC "USB FTDI Serial Converters Driver"
57 53
58static bool debug;
59static __u16 vendor = FTDI_VID; 54static __u16 vendor = FTDI_VID;
60static __u16 product; 55static __u16 product;
61 56
@@ -584,6 +579,8 @@ static struct usb_device_id id_table_combined [] = {
584 { USB_DEVICE(FTDI_VID, FTDI_IBS_PEDO_PID) }, 579 { USB_DEVICE(FTDI_VID, FTDI_IBS_PEDO_PID) },
585 { USB_DEVICE(FTDI_VID, FTDI_IBS_PROD_PID) }, 580 { USB_DEVICE(FTDI_VID, FTDI_IBS_PROD_PID) },
586 { USB_DEVICE(FTDI_VID, FTDI_TAVIR_STK500_PID) }, 581 { USB_DEVICE(FTDI_VID, FTDI_TAVIR_STK500_PID) },
582 { USB_DEVICE(FTDI_VID, FTDI_TIAO_UMPA_PID),
583 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
587 /* 584 /*
588 * ELV devices: 585 * ELV devices:
589 */ 586 */
@@ -1063,11 +1060,12 @@ static int update_mctrl(struct usb_serial_port *port, unsigned int set,
1063 unsigned int clear) 1060 unsigned int clear)
1064{ 1061{
1065 struct ftdi_private *priv = usb_get_serial_port_data(port); 1062 struct ftdi_private *priv = usb_get_serial_port_data(port);
1063 struct device *dev = &port->dev;
1066 unsigned urb_value; 1064 unsigned urb_value;
1067 int rv; 1065 int rv;
1068 1066
1069 if (((set | clear) & (TIOCM_DTR | TIOCM_RTS)) == 0) { 1067 if (((set | clear) & (TIOCM_DTR | TIOCM_RTS)) == 0) {
1070 dbg("%s - DTR|RTS not being set|cleared", __func__); 1068 dev_dbg(dev, "%s - DTR|RTS not being set|cleared\n", __func__);
1071 return 0; /* no change */ 1069 return 0; /* no change */
1072 } 1070 }
1073 1071
@@ -1088,18 +1086,14 @@ static int update_mctrl(struct usb_serial_port *port, unsigned int set,
1088 urb_value, priv->interface, 1086 urb_value, priv->interface,
1089 NULL, 0, WDR_TIMEOUT); 1087 NULL, 0, WDR_TIMEOUT);
1090 if (rv < 0) { 1088 if (rv < 0) {
1091 dbg("%s Error from MODEM_CTRL urb: DTR %s, RTS %s", 1089 dev_dbg(dev, "%s Error from MODEM_CTRL urb: DTR %s, RTS %s\n",
1092 __func__, 1090 __func__,
1093 (set & TIOCM_DTR) ? "HIGH" : 1091 (set & TIOCM_DTR) ? "HIGH" : (clear & TIOCM_DTR) ? "LOW" : "unchanged",
1094 (clear & TIOCM_DTR) ? "LOW" : "unchanged", 1092 (set & TIOCM_RTS) ? "HIGH" : (clear & TIOCM_RTS) ? "LOW" : "unchanged");
1095 (set & TIOCM_RTS) ? "HIGH" :
1096 (clear & TIOCM_RTS) ? "LOW" : "unchanged");
1097 } else { 1093 } else {
1098 dbg("%s - DTR %s, RTS %s", __func__, 1094 dev_dbg(dev, "%s - DTR %s, RTS %s\n", __func__,
1099 (set & TIOCM_DTR) ? "HIGH" : 1095 (set & TIOCM_DTR) ? "HIGH" : (clear & TIOCM_DTR) ? "LOW" : "unchanged",
1100 (clear & TIOCM_DTR) ? "LOW" : "unchanged", 1096 (set & TIOCM_RTS) ? "HIGH" : (clear & TIOCM_RTS) ? "LOW" : "unchanged");
1101 (set & TIOCM_RTS) ? "HIGH" :
1102 (clear & TIOCM_RTS) ? "LOW" : "unchanged");
1103 /* FIXME: locking on last_dtr_rts */ 1097 /* FIXME: locking on last_dtr_rts */
1104 priv->last_dtr_rts = (priv->last_dtr_rts & ~clear) | set; 1098 priv->last_dtr_rts = (priv->last_dtr_rts & ~clear) | set;
1105 } 1099 }
@@ -1111,6 +1105,7 @@ static __u32 get_ftdi_divisor(struct tty_struct *tty,
1111 struct usb_serial_port *port) 1105 struct usb_serial_port *port)
1112{ 1106{
1113 struct ftdi_private *priv = usb_get_serial_port_data(port); 1107 struct ftdi_private *priv = usb_get_serial_port_data(port);
1108 struct device *dev = &port->dev;
1114 __u32 div_value = 0; 1109 __u32 div_value = 0;
1115 int div_okay = 1; 1110 int div_okay = 1;
1116 int baud; 1111 int baud;
@@ -1146,7 +1141,7 @@ static __u32 get_ftdi_divisor(struct tty_struct *tty,
1146 alt_speed hack */ 1141 alt_speed hack */
1147 1142
1148 baud = tty_get_baud_rate(tty); 1143 baud = tty_get_baud_rate(tty);
1149 dbg("%s - tty_get_baud_rate reports speed %d", __func__, baud); 1144 dev_dbg(dev, "%s - tty_get_baud_rate reports speed %d\n", __func__, baud);
1150 1145
1151 /* 2. Observe async-compatible custom_divisor hack, update baudrate 1146 /* 2. Observe async-compatible custom_divisor hack, update baudrate
1152 if needed */ 1147 if needed */
@@ -1155,8 +1150,8 @@ static __u32 get_ftdi_divisor(struct tty_struct *tty,
1155 ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST) && 1150 ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST) &&
1156 (priv->custom_divisor)) { 1151 (priv->custom_divisor)) {
1157 baud = priv->baud_base / priv->custom_divisor; 1152 baud = priv->baud_base / priv->custom_divisor;
1158 dbg("%s - custom divisor %d sets baud rate to %d", 1153 dev_dbg(dev, "%s - custom divisor %d sets baud rate to %d\n",
1159 __func__, priv->custom_divisor, baud); 1154 __func__, priv->custom_divisor, baud);
1160 } 1155 }
1161 1156
1162 /* 3. Convert baudrate to device-specific divisor */ 1157 /* 3. Convert baudrate to device-specific divisor */
@@ -1178,8 +1173,8 @@ static __u32 get_ftdi_divisor(struct tty_struct *tty,
1178 case 115200: div_value = ftdi_sio_b115200; break; 1173 case 115200: div_value = ftdi_sio_b115200; break;
1179 } /* baud */ 1174 } /* baud */
1180 if (div_value == 0) { 1175 if (div_value == 0) {
1181 dbg("%s - Baudrate (%d) requested is not supported", 1176 dev_dbg(dev, "%s - Baudrate (%d) requested is not supported\n",
1182 __func__, baud); 1177 __func__, baud);
1183 div_value = ftdi_sio_b9600; 1178 div_value = ftdi_sio_b9600;
1184 baud = 9600; 1179 baud = 9600;
1185 div_okay = 0; 1180 div_okay = 0;
@@ -1189,7 +1184,7 @@ static __u32 get_ftdi_divisor(struct tty_struct *tty,
1189 if (baud <= 3000000) { 1184 if (baud <= 3000000) {
1190 div_value = ftdi_232am_baud_to_divisor(baud); 1185 div_value = ftdi_232am_baud_to_divisor(baud);
1191 } else { 1186 } else {
1192 dbg("%s - Baud rate too high!", __func__); 1187 dev_dbg(dev, "%s - Baud rate too high!\n", __func__);
1193 baud = 9600; 1188 baud = 9600;
1194 div_value = ftdi_232am_baud_to_divisor(9600); 1189 div_value = ftdi_232am_baud_to_divisor(9600);
1195 div_okay = 0; 1190 div_okay = 0;
@@ -1212,7 +1207,7 @@ static __u32 get_ftdi_divisor(struct tty_struct *tty,
1212 } 1207 }
1213 div_value = ftdi_232bm_baud_to_divisor(baud); 1208 div_value = ftdi_232bm_baud_to_divisor(baud);
1214 } else { 1209 } else {
1215 dbg("%s - Baud rate too high!", __func__); 1210 dev_dbg(dev, "%s - Baud rate too high!\n", __func__);
1216 div_value = ftdi_232bm_baud_to_divisor(9600); 1211 div_value = ftdi_232bm_baud_to_divisor(9600);
1217 div_okay = 0; 1212 div_okay = 0;
1218 baud = 9600; 1213 baud = 9600;
@@ -1226,7 +1221,7 @@ static __u32 get_ftdi_divisor(struct tty_struct *tty,
1226 } else if (baud < 1200) { 1221 } else if (baud < 1200) {
1227 div_value = ftdi_232bm_baud_to_divisor(baud); 1222 div_value = ftdi_232bm_baud_to_divisor(baud);
1228 } else { 1223 } else {
1229 dbg("%s - Baud rate too high!", __func__); 1224 dev_dbg(dev, "%s - Baud rate too high!\n", __func__);
1230 div_value = ftdi_232bm_baud_to_divisor(9600); 1225 div_value = ftdi_232bm_baud_to_divisor(9600);
1231 div_okay = 0; 1226 div_okay = 0;
1232 baud = 9600; 1227 baud = 9600;
@@ -1235,7 +1230,7 @@ static __u32 get_ftdi_divisor(struct tty_struct *tty,
1235 } /* priv->chip_type */ 1230 } /* priv->chip_type */
1236 1231
1237 if (div_okay) { 1232 if (div_okay) {
1238 dbg("%s - Baud rate set to %d (divisor 0x%lX) on chip %s", 1233 dev_dbg(dev, "%s - Baud rate set to %d (divisor 0x%lX) on chip %s\n",
1239 __func__, baud, (unsigned long)div_value, 1234 __func__, baud, (unsigned long)div_value,
1240 ftdi_chip_name[priv->chip_type]); 1235 ftdi_chip_name[priv->chip_type]);
1241 } 1236 }
@@ -1281,7 +1276,7 @@ static int write_latency_timer(struct usb_serial_port *port)
1281 if (priv->flags & ASYNC_LOW_LATENCY) 1276 if (priv->flags & ASYNC_LOW_LATENCY)
1282 l = 1; 1277 l = 1;
1283 1278
1284 dbg("%s: setting latency timer = %i", __func__, l); 1279 dev_dbg(&port->dev, "%s: setting latency timer = %i\n", __func__, l);
1285 1280
1286 rv = usb_control_msg(udev, 1281 rv = usb_control_msg(udev,
1287 usb_sndctrlpipe(udev, 0), 1282 usb_sndctrlpipe(udev, 0),
@@ -1436,8 +1431,8 @@ static void ftdi_determine_type(struct usb_serial_port *port)
1436 1431
1437 version = le16_to_cpu(udev->descriptor.bcdDevice); 1432 version = le16_to_cpu(udev->descriptor.bcdDevice);
1438 interfaces = udev->actconfig->desc.bNumInterfaces; 1433 interfaces = udev->actconfig->desc.bNumInterfaces;
1439 dbg("%s: bcdDevice = 0x%x, bNumInterfaces = %u", __func__, 1434 dev_dbg(&port->dev, "%s: bcdDevice = 0x%x, bNumInterfaces = %u\n", __func__,
1440 version, interfaces); 1435 version, interfaces);
1441 if (interfaces > 1) { 1436 if (interfaces > 1) {
1442 int inter; 1437 int inter;
1443 1438
@@ -1467,8 +1462,9 @@ static void ftdi_determine_type(struct usb_serial_port *port)
1467 /* BM-type devices have a bug where bcdDevice gets set 1462 /* BM-type devices have a bug where bcdDevice gets set
1468 * to 0x200 when iSerialNumber is 0. */ 1463 * to 0x200 when iSerialNumber is 0. */
1469 if (version < 0x500) { 1464 if (version < 0x500) {
1470 dbg("%s: something fishy - bcdDevice too low for multi-interface device", 1465 dev_dbg(&port->dev,
1471 __func__); 1466 "%s: something fishy - bcdDevice too low for multi-interface device\n",
1467 __func__);
1472 } 1468 }
1473 } else if (version < 0x200) { 1469 } else if (version < 0x200) {
1474 /* Old device. Assume it's the original SIO. */ 1470 /* Old device. Assume it's the original SIO. */
@@ -1582,7 +1578,7 @@ static ssize_t store_event_char(struct device *dev,
1582 int v = simple_strtoul(valbuf, NULL, 10); 1578 int v = simple_strtoul(valbuf, NULL, 10);
1583 int rv; 1579 int rv;
1584 1580
1585 dbg("%s: setting event char = %i", __func__, v); 1581 dev_dbg(&port->dev, "%s: setting event char = %i\n", __func__, v);
1586 1582
1587 rv = usb_control_msg(udev, 1583 rv = usb_control_msg(udev,
1588 usb_sndctrlpipe(udev, 0), 1584 usb_sndctrlpipe(udev, 0),
@@ -1591,7 +1587,7 @@ static ssize_t store_event_char(struct device *dev,
1591 v, priv->interface, 1587 v, priv->interface,
1592 NULL, 0, WDR_TIMEOUT); 1588 NULL, 0, WDR_TIMEOUT);
1593 if (rv < 0) { 1589 if (rv < 0) {
1594 dbg("Unable to write event character: %i", rv); 1590 dev_dbg(&port->dev, "Unable to write event character: %i\n", rv);
1595 return -EIO; 1591 return -EIO;
1596 } 1592 }
1597 1593
@@ -1610,7 +1606,7 @@ static int create_sysfs_attrs(struct usb_serial_port *port)
1610 /* XXX I've no idea if the original SIO supports the event_char 1606 /* XXX I've no idea if the original SIO supports the event_char
1611 * sysfs parameter, so I'm playing it safe. */ 1607 * sysfs parameter, so I'm playing it safe. */
1612 if (priv->chip_type != SIO) { 1608 if (priv->chip_type != SIO) {
1613 dbg("sysfs attributes for %s", ftdi_chip_name[priv->chip_type]); 1609 dev_dbg(&port->dev, "sysfs attributes for %s\n", ftdi_chip_name[priv->chip_type]);
1614 retval = device_create_file(&port->dev, &dev_attr_event_char); 1610 retval = device_create_file(&port->dev, &dev_attr_event_char);
1615 if ((!retval) && 1611 if ((!retval) &&
1616 (priv->chip_type == FT232BM || 1612 (priv->chip_type == FT232BM ||
@@ -1750,8 +1746,8 @@ static int ftdi_NDI_device_setup(struct usb_serial *serial)
1750 if (latency > 99) 1746 if (latency > 99)
1751 latency = 99; 1747 latency = 99;
1752 1748
1753 dbg("%s setting NDI device latency to %d", __func__, latency); 1749 dev_dbg(&udev->dev, "%s setting NDI device latency to %d\n", __func__, latency);
1754 dev_info(&udev->dev, "NDI device with a latency value of %d", latency); 1750 dev_info(&udev->dev, "NDI device with a latency value of %d\n", latency);
1755 1751
1756 /* FIXME: errors are not returned */ 1752 /* FIXME: errors are not returned */
1757 usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 1753 usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
@@ -1969,7 +1965,7 @@ static int ftdi_process_packet(struct tty_struct *tty,
1969 char *ch; 1965 char *ch;
1970 1966
1971 if (len < 2) { 1967 if (len < 2) {
1972 dbg("malformed packet"); 1968 dev_dbg(&port->dev, "malformed packet\n");
1973 return 0; 1969 return 0;
1974 } 1970 }
1975 1971
@@ -2084,12 +2080,12 @@ static void ftdi_break_ctl(struct tty_struct *tty, int break_state)
2084 FTDI_SIO_SET_DATA_REQUEST_TYPE, 2080 FTDI_SIO_SET_DATA_REQUEST_TYPE,
2085 urb_value , priv->interface, 2081 urb_value , priv->interface,
2086 NULL, 0, WDR_TIMEOUT) < 0) { 2082 NULL, 0, WDR_TIMEOUT) < 0) {
2087 dev_err(&port->dev, "%s FAILED to enable/disable break state " 2083 dev_err(&port->dev, "%s FAILED to enable/disable break state (state was %d)\n",
2088 "(state was %d)\n", __func__, break_state); 2084 __func__, break_state);
2089 } 2085 }
2090 2086
2091 dbg("%s break state is %d - urb is %d", __func__, 2087 dev_dbg(&port->dev, "%s break state is %d - urb is %d\n", __func__,
2092 break_state, urb_value); 2088 break_state, urb_value);
2093 2089
2094} 2090}
2095 2091
@@ -2101,6 +2097,7 @@ static void ftdi_set_termios(struct tty_struct *tty,
2101 struct usb_serial_port *port, struct ktermios *old_termios) 2097 struct usb_serial_port *port, struct ktermios *old_termios)
2102{ 2098{
2103 struct usb_device *dev = port->serial->dev; 2099 struct usb_device *dev = port->serial->dev;
2100 struct device *ddev = &port->dev;
2104 struct ftdi_private *priv = usb_get_serial_port_data(port); 2101 struct ftdi_private *priv = usb_get_serial_port_data(port);
2105 struct ktermios *termios = &tty->termios; 2102 struct ktermios *termios = &tty->termios;
2106 unsigned int cflag = termios->c_cflag; 2103 unsigned int cflag = termios->c_cflag;
@@ -2114,20 +2111,20 @@ static void ftdi_set_termios(struct tty_struct *tty,
2114 /* Force baud rate if this device requires it, unless it is set to 2111 /* Force baud rate if this device requires it, unless it is set to
2115 B0. */ 2112 B0. */
2116 if (priv->force_baud && ((termios->c_cflag & CBAUD) != B0)) { 2113 if (priv->force_baud && ((termios->c_cflag & CBAUD) != B0)) {
2117 dbg("%s: forcing baud rate for this device", __func__); 2114 dev_dbg(ddev, "%s: forcing baud rate for this device\n", __func__);
2118 tty_encode_baud_rate(tty, priv->force_baud, 2115 tty_encode_baud_rate(tty, priv->force_baud,
2119 priv->force_baud); 2116 priv->force_baud);
2120 } 2117 }
2121 2118
2122 /* Force RTS-CTS if this device requires it. */ 2119 /* Force RTS-CTS if this device requires it. */
2123 if (priv->force_rtscts) { 2120 if (priv->force_rtscts) {
2124 dbg("%s: forcing rtscts for this device", __func__); 2121 dev_dbg(ddev, "%s: forcing rtscts for this device\n", __func__);
2125 termios->c_cflag |= CRTSCTS; 2122 termios->c_cflag |= CRTSCTS;
2126 } 2123 }
2127 2124
2128 cflag = termios->c_cflag; 2125 cflag = termios->c_cflag;
2129 2126
2130 if (old_termios == 0) 2127 if (!old_termios)
2131 goto no_skip; 2128 goto no_skip;
2132 2129
2133 if (old_termios->c_cflag == termios->c_cflag 2130 if (old_termios->c_cflag == termios->c_cflag
@@ -2163,10 +2160,16 @@ no_skip:
2163 } 2160 }
2164 if (cflag & CSIZE) { 2161 if (cflag & CSIZE) {
2165 switch (cflag & CSIZE) { 2162 switch (cflag & CSIZE) {
2166 case CS7: urb_value |= 7; dbg("Setting CS7"); break; 2163 case CS7:
2167 case CS8: urb_value |= 8; dbg("Setting CS8"); break; 2164 urb_value |= 7;
2165 dev_dbg(ddev, "Setting CS7\n");
2166 break;
2167 case CS8:
2168 urb_value |= 8;
2169 dev_dbg(ddev, "Setting CS8\n");
2170 break;
2168 default: 2171 default:
2169 dev_err(&port->dev, "CSIZE was set but not CS7-CS8\n"); 2172 dev_err(ddev, "CSIZE was set but not CS7-CS8\n");
2170 } 2173 }
2171 } 2174 }
2172 2175
@@ -2179,8 +2182,8 @@ no_skip:
2179 FTDI_SIO_SET_DATA_REQUEST_TYPE, 2182 FTDI_SIO_SET_DATA_REQUEST_TYPE,
2180 urb_value , priv->interface, 2183 urb_value , priv->interface,
2181 NULL, 0, WDR_SHORT_TIMEOUT) < 0) { 2184 NULL, 0, WDR_SHORT_TIMEOUT) < 0) {
2182 dev_err(&port->dev, "%s FAILED to set " 2185 dev_err(ddev, "%s FAILED to set databits/stopbits/parity\n",
2183 "databits/stopbits/parity\n", __func__); 2186 __func__);
2184 } 2187 }
2185 2188
2186 /* Now do the baudrate */ 2189 /* Now do the baudrate */
@@ -2192,8 +2195,7 @@ no_data_parity_stop_changes:
2192 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, 2195 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE,
2193 0, priv->interface, 2196 0, priv->interface,
2194 NULL, 0, WDR_TIMEOUT) < 0) { 2197 NULL, 0, WDR_TIMEOUT) < 0) {
2195 dev_err(&port->dev, 2198 dev_err(ddev, "%s error from disable flowcontrol urb\n",
2196 "%s error from disable flowcontrol urb\n",
2197 __func__); 2199 __func__);
2198 } 2200 }
2199 /* Drop RTS and DTR */ 2201 /* Drop RTS and DTR */
@@ -2202,8 +2204,7 @@ no_data_parity_stop_changes:
2202 /* set the baudrate determined before */ 2204 /* set the baudrate determined before */
2203 mutex_lock(&priv->cfg_lock); 2205 mutex_lock(&priv->cfg_lock);
2204 if (change_speed(tty, port)) 2206 if (change_speed(tty, port))
2205 dev_err(&port->dev, "%s urb failed to set baudrate\n", 2207 dev_err(ddev, "%s urb failed to set baudrate\n", __func__);
2206 __func__);
2207 mutex_unlock(&priv->cfg_lock); 2208 mutex_unlock(&priv->cfg_lock);
2208 /* Ensure RTS and DTR are raised when baudrate changed from 0 */ 2209 /* Ensure RTS and DTR are raised when baudrate changed from 0 */
2209 if (!old_termios || (old_termios->c_cflag & CBAUD) == B0) 2210 if (!old_termios || (old_termios->c_cflag & CBAUD) == B0)
@@ -2214,17 +2215,15 @@ no_data_parity_stop_changes:
2214 /* Note device also supports DTR/CD (ugh) and Xon/Xoff in hardware */ 2215 /* Note device also supports DTR/CD (ugh) and Xon/Xoff in hardware */
2215no_c_cflag_changes: 2216no_c_cflag_changes:
2216 if (cflag & CRTSCTS) { 2217 if (cflag & CRTSCTS) {
2217 dbg("%s Setting to CRTSCTS flow control", __func__); 2218 dev_dbg(ddev, "%s Setting to CRTSCTS flow control\n", __func__);
2218 if (usb_control_msg(dev, 2219 if (usb_control_msg(dev,
2219 usb_sndctrlpipe(dev, 0), 2220 usb_sndctrlpipe(dev, 0),
2220 FTDI_SIO_SET_FLOW_CTRL_REQUEST, 2221 FTDI_SIO_SET_FLOW_CTRL_REQUEST,
2221 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, 2222 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE,
2222 0 , (FTDI_SIO_RTS_CTS_HS | priv->interface), 2223 0 , (FTDI_SIO_RTS_CTS_HS | priv->interface),
2223 NULL, 0, WDR_TIMEOUT) < 0) { 2224 NULL, 0, WDR_TIMEOUT) < 0) {
2224 dev_err(&port->dev, 2225 dev_err(ddev, "urb failed to set to rts/cts flow control\n");
2225 "urb failed to set to rts/cts flow control\n");
2226 } 2226 }
2227
2228 } else { 2227 } else {
2229 /* 2228 /*
2230 * Xon/Xoff code 2229 * Xon/Xoff code
@@ -2234,8 +2233,8 @@ no_c_cflag_changes:
2234 * code is executed. 2233 * code is executed.
2235 */ 2234 */
2236 if (iflag & IXOFF) { 2235 if (iflag & IXOFF) {
2237 dbg("%s request to enable xonxoff iflag=%04x", 2236 dev_dbg(ddev, "%s request to enable xonxoff iflag=%04x\n",
2238 __func__, iflag); 2237 __func__, iflag);
2239 /* Try to enable the XON/XOFF on the ftdi_sio 2238 /* Try to enable the XON/XOFF on the ftdi_sio
2240 * Set the vstart and vstop -- could have been done up 2239 * Set the vstart and vstop -- could have been done up
2241 * above where a lot of other dereferencing is done but 2240 * above where a lot of other dereferencing is done but
@@ -2260,18 +2259,16 @@ no_c_cflag_changes:
2260 /* else clause to only run if cflag ! CRTSCTS and iflag 2259 /* else clause to only run if cflag ! CRTSCTS and iflag
2261 * ! XOFF. CHECKME Assuming XON/XOFF handled by tty 2260 * ! XOFF. CHECKME Assuming XON/XOFF handled by tty
2262 * stack - not by device */ 2261 * stack - not by device */
2263 dbg("%s Turning off hardware flow control", __func__); 2262 dev_dbg(ddev, "%s Turning off hardware flow control\n", __func__);
2264 if (usb_control_msg(dev, 2263 if (usb_control_msg(dev,
2265 usb_sndctrlpipe(dev, 0), 2264 usb_sndctrlpipe(dev, 0),
2266 FTDI_SIO_SET_FLOW_CTRL_REQUEST, 2265 FTDI_SIO_SET_FLOW_CTRL_REQUEST,
2267 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, 2266 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE,
2268 0, priv->interface, 2267 0, priv->interface,
2269 NULL, 0, WDR_TIMEOUT) < 0) { 2268 NULL, 0, WDR_TIMEOUT) < 0) {
2270 dev_err(&port->dev, 2269 dev_err(ddev, "urb failed to clear flow control\n");
2271 "urb failed to clear flow control\n");
2272 } 2270 }
2273 } 2271 }
2274
2275 } 2272 }
2276} 2273}
2277 2274
@@ -2365,7 +2362,7 @@ static int ftdi_ioctl(struct tty_struct *tty,
2365 struct async_icount cnow; 2362 struct async_icount cnow;
2366 struct async_icount cprev; 2363 struct async_icount cprev;
2367 2364
2368 dbg("%s cmd 0x%04x", __func__, cmd); 2365 dev_dbg(&port->dev, "%s cmd 0x%04x\n", __func__, cmd);
2369 2366
2370 /* Based on code from acm.c and others */ 2367 /* Based on code from acm.c and others */
2371 switch (cmd) { 2368 switch (cmd) {
@@ -2413,14 +2410,13 @@ static int ftdi_ioctl(struct tty_struct *tty,
2413 /* This is not necessarily an error - turns out the higher layers 2410 /* This is not necessarily an error - turns out the higher layers
2414 * will do some ioctls themselves (see comment above) 2411 * will do some ioctls themselves (see comment above)
2415 */ 2412 */
2416 dbg("%s arg not supported - it was 0x%04x - check /usr/include/asm/ioctls.h", __func__, cmd); 2413 dev_dbg(&port->dev, "%s arg not supported - it was 0x%04x - check /usr/include/asm/ioctls.h\n",
2414 __func__, cmd);
2417 return -ENOIOCTLCMD; 2415 return -ENOIOCTLCMD;
2418} 2416}
2419 2417
2420static int __init ftdi_init(void) 2418static int __init ftdi_init(void)
2421{ 2419{
2422 int retval;
2423
2424 if (vendor > 0 && product > 0) { 2420 if (vendor > 0 && product > 0) {
2425 /* Add user specified VID/PID to reserved element of table. */ 2421 /* Add user specified VID/PID to reserved element of table. */
2426 int i; 2422 int i;
@@ -2430,11 +2426,7 @@ static int __init ftdi_init(void)
2430 id_table_combined[i].idVendor = vendor; 2426 id_table_combined[i].idVendor = vendor;
2431 id_table_combined[i].idProduct = product; 2427 id_table_combined[i].idProduct = product;
2432 } 2428 }
2433 retval = usb_serial_register_drivers(serial_drivers, KBUILD_MODNAME, id_table_combined); 2429 return usb_serial_register_drivers(serial_drivers, KBUILD_MODNAME, id_table_combined);
2434 if (retval == 0)
2435 printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":"
2436 DRIVER_DESC "\n");
2437 return retval;
2438} 2430}
2439 2431
2440static void __exit ftdi_exit(void) 2432static void __exit ftdi_exit(void)
@@ -2450,8 +2442,6 @@ MODULE_AUTHOR(DRIVER_AUTHOR);
2450MODULE_DESCRIPTION(DRIVER_DESC); 2442MODULE_DESCRIPTION(DRIVER_DESC);
2451MODULE_LICENSE("GPL"); 2443MODULE_LICENSE("GPL");
2452 2444
2453module_param(debug, bool, S_IRUGO | S_IWUSR);
2454MODULE_PARM_DESC(debug, "Debug enabled or not");
2455module_param(vendor, ushort, 0); 2445module_param(vendor, ushort, 0);
2456MODULE_PARM_DESC(vendor, "User specified vendor ID (default=" 2446MODULE_PARM_DESC(vendor, "User specified vendor ID (default="
2457 __MODULE_STRING(FTDI_VID)")"); 2447 __MODULE_STRING(FTDI_VID)")");
diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h
index 41fe5826100c..57c12ef6625e 100644
--- a/drivers/usb/serial/ftdi_sio_ids.h
+++ b/drivers/usb/serial/ftdi_sio_ids.h
@@ -517,6 +517,11 @@
517 */ 517 */
518#define FTDI_TAVIR_STK500_PID 0xFA33 /* STK500 AVR programmer */ 518#define FTDI_TAVIR_STK500_PID 0xFA33 /* STK500 AVR programmer */
519 519
520/*
521 * TIAO product ids (FTDI_VID)
522 * http://www.tiaowiki.com/w/Main_Page
523 */
524#define FTDI_TIAO_UMPA_PID 0x8a98 /* TIAO/DIYGADGET USB Multi-Protocol Adapter */
520 525
521 526
522/********************************/ 527/********************************/
diff --git a/drivers/usb/serial/funsoft.c b/drivers/usb/serial/funsoft.c
index 235707961ca3..9362f8fd2385 100644
--- a/drivers/usb/serial/funsoft.c
+++ b/drivers/usb/serial/funsoft.c
@@ -16,8 +16,6 @@
16#include <linux/usb/serial.h> 16#include <linux/usb/serial.h>
17#include <linux/uaccess.h> 17#include <linux/uaccess.h>
18 18
19static bool debug;
20
21static const struct usb_device_id id_table[] = { 19static const struct usb_device_id id_table[] = {
22 { USB_DEVICE(0x1404, 0xcddc) }, 20 { USB_DEVICE(0x1404, 0xcddc) },
23 { }, 21 { },
@@ -40,6 +38,3 @@ static struct usb_serial_driver * const serial_drivers[] = {
40module_usb_serial_driver(serial_drivers, id_table); 38module_usb_serial_driver(serial_drivers, id_table);
41 39
42MODULE_LICENSE("GPL"); 40MODULE_LICENSE("GPL");
43
44module_param(debug, bool, S_IRUGO | S_IWUSR);
45MODULE_PARM_DESC(debug, "Debug enabled or not");
diff --git a/drivers/usb/serial/garmin_gps.c b/drivers/usb/serial/garmin_gps.c
index 346c15a51066..3ee92648c02d 100644
--- a/drivers/usb/serial/garmin_gps.c
+++ b/drivers/usb/serial/garmin_gps.c
@@ -41,9 +41,6 @@
41/* the mode to be set when the port ist opened */ 41/* the mode to be set when the port ist opened */
42static int initial_mode = 1; 42static int initial_mode = 1;
43 43
44/* debug flag */
45static bool debug;
46
47#define GARMIN_VENDOR_ID 0x091E 44#define GARMIN_VENDOR_ID 0x091E
48 45
49/* 46/*
@@ -258,10 +255,7 @@ static void send_to_tty(struct usb_serial_port *port,
258 struct tty_struct *tty = tty_port_tty_get(&port->port); 255 struct tty_struct *tty = tty_port_tty_get(&port->port);
259 256
260 if (tty && actual_length) { 257 if (tty && actual_length) {
261 258 usb_serial_debug_data(&port->dev, __func__, actual_length, data);
262 usb_serial_debug_data(debug, &port->dev,
263 __func__, actual_length, data);
264
265 tty_insert_flip_string(tty, data, actual_length); 259 tty_insert_flip_string(tty, data, actual_length);
266 tty_flip_buffer_push(tty); 260 tty_flip_buffer_push(tty);
267 } 261 }
@@ -303,8 +297,9 @@ static int pkt_add(struct garmin_data *garmin_data_p,
303 state = garmin_data_p->state; 297 state = garmin_data_p->state;
304 spin_unlock_irqrestore(&garmin_data_p->lock, flags); 298 spin_unlock_irqrestore(&garmin_data_p->lock, flags);
305 299
306 dbg("%s - added: pkt: %d - %d bytes", 300 dev_dbg(&garmin_data_p->port->dev,
307 __func__, pkt->seq, data_length); 301 "%s - added: pkt: %d - %d bytes\n", __func__,
302 pkt->seq, data_length);
308 303
309 /* in serial mode, if someone is waiting for data from 304 /* in serial mode, if someone is waiting for data from
310 the device, convert and send the next packet to tty. */ 305 the device, convert and send the next packet to tty. */
@@ -359,7 +354,8 @@ static int gsp_send_ack(struct garmin_data *garmin_data_p, __u8 pkt_id)
359 __u8 *ptr = pkt; 354 __u8 *ptr = pkt;
360 unsigned l = 0; 355 unsigned l = 0;
361 356
362 dbg("%s - pkt-id: 0x%X.", __func__, 0xFF & pkt_id); 357 dev_dbg(&garmin_data_p->port->dev, "%s - pkt-id: 0x%X.\n", __func__,
358 0xFF & pkt_id);
363 359
364 *ptr++ = DLE; 360 *ptr++ = DLE;
365 *ptr++ = ACK; 361 *ptr++ = ACK;
@@ -399,20 +395,20 @@ static int gsp_send_ack(struct garmin_data *garmin_data_p, __u8 pkt_id)
399 */ 395 */
400static int gsp_rec_packet(struct garmin_data *garmin_data_p, int count) 396static int gsp_rec_packet(struct garmin_data *garmin_data_p, int count)
401{ 397{
398 struct device *dev = &garmin_data_p->port->dev;
402 unsigned long flags; 399 unsigned long flags;
403 const __u8 *recpkt = garmin_data_p->inbuffer+GSP_INITIAL_OFFSET; 400 const __u8 *recpkt = garmin_data_p->inbuffer+GSP_INITIAL_OFFSET;
404 __le32 *usbdata = (__le32 *) garmin_data_p->inbuffer; 401 __le32 *usbdata = (__le32 *) garmin_data_p->inbuffer;
405
406 int cksum = 0; 402 int cksum = 0;
407 int n = 0; 403 int n = 0;
408 int pktid = recpkt[0]; 404 int pktid = recpkt[0];
409 int size = recpkt[1]; 405 int size = recpkt[1];
410 406
411 usb_serial_debug_data(debug, &garmin_data_p->port->dev, 407 usb_serial_debug_data(&garmin_data_p->port->dev, __func__,
412 __func__, count-GSP_INITIAL_OFFSET, recpkt); 408 count-GSP_INITIAL_OFFSET, recpkt);
413 409
414 if (size != (count-GSP_INITIAL_OFFSET-3)) { 410 if (size != (count-GSP_INITIAL_OFFSET-3)) {
415 dbg("%s - invalid size, expected %d bytes, got %d", 411 dev_dbg(dev, "%s - invalid size, expected %d bytes, got %d\n",
416 __func__, size, (count-GSP_INITIAL_OFFSET-3)); 412 __func__, size, (count-GSP_INITIAL_OFFSET-3));
417 return -EINVPKT; 413 return -EINVPKT;
418 } 414 }
@@ -422,8 +418,8 @@ static int gsp_rec_packet(struct garmin_data *garmin_data_p, int count)
422 418
423 /* sanity check, remove after test ... */ 419 /* sanity check, remove after test ... */
424 if ((__u8 *)&(usbdata[3]) != recpkt) { 420 if ((__u8 *)&(usbdata[3]) != recpkt) {
425 dbg("%s - ptr mismatch %p - %p", 421 dev_dbg(dev, "%s - ptr mismatch %p - %p\n", __func__,
426 __func__, &(usbdata[4]), recpkt); 422 &(usbdata[4]), recpkt);
427 return -EINVPKT; 423 return -EINVPKT;
428 } 424 }
429 425
@@ -433,7 +429,7 @@ static int gsp_rec_packet(struct garmin_data *garmin_data_p, int count)
433 } 429 }
434 430
435 if ((0xff & (cksum + *recpkt)) != 0) { 431 if ((0xff & (cksum + *recpkt)) != 0) {
436 dbg("%s - invalid checksum, expected %02x, got %02x", 432 dev_dbg(dev, "%s - invalid checksum, expected %02x, got %02x\n",
437 __func__, 0xff & -cksum, 0xff & *recpkt); 433 __func__, 0xff & -cksum, 0xff & *recpkt);
438 return -EINVPKT; 434 return -EINVPKT;
439 } 435 }
@@ -480,6 +476,7 @@ static int gsp_rec_packet(struct garmin_data *garmin_data_p, int count)
480static int gsp_receive(struct garmin_data *garmin_data_p, 476static int gsp_receive(struct garmin_data *garmin_data_p,
481 const unsigned char *buf, int count) 477 const unsigned char *buf, int count)
482{ 478{
479 struct device *dev = &garmin_data_p->port->dev;
483 unsigned long flags; 480 unsigned long flags;
484 int offs = 0; 481 int offs = 0;
485 int ack_or_nak_seen = 0; 482 int ack_or_nak_seen = 0;
@@ -500,7 +497,7 @@ static int gsp_receive(struct garmin_data *garmin_data_p,
500 skip = garmin_data_p->flags & FLAGS_GSP_SKIP; 497 skip = garmin_data_p->flags & FLAGS_GSP_SKIP;
501 spin_unlock_irqrestore(&garmin_data_p->lock, flags); 498 spin_unlock_irqrestore(&garmin_data_p->lock, flags);
502 499
503 /* dbg("%s - dle=%d skip=%d size=%d count=%d", 500 /* dev_dbg(dev, "%s - dle=%d skip=%d size=%d count=%d\n",
504 __func__, dleSeen, skip, size, count); */ 501 __func__, dleSeen, skip, size, count); */
505 502
506 if (size == 0) 503 if (size == 0)
@@ -530,12 +527,12 @@ static int gsp_receive(struct garmin_data *garmin_data_p,
530 527
531 if (data == ACK) { 528 if (data == ACK) {
532 ack_or_nak_seen = ACK; 529 ack_or_nak_seen = ACK;
533 dbg("ACK packet complete."); 530 dev_dbg(dev, "ACK packet complete.\n");
534 } else if (data == NAK) { 531 } else if (data == NAK) {
535 ack_or_nak_seen = NAK; 532 ack_or_nak_seen = NAK;
536 dbg("NAK packet complete."); 533 dev_dbg(dev, "NAK packet complete.\n");
537 } else { 534 } else {
538 dbg("packet complete - id=0x%X.", 535 dev_dbg(dev, "packet complete - id=0x%X.\n",
539 0xFF & data); 536 0xFF & data);
540 gsp_rec_packet(garmin_data_p, size); 537 gsp_rec_packet(garmin_data_p, size);
541 } 538 }
@@ -557,7 +554,7 @@ static int gsp_receive(struct garmin_data *garmin_data_p,
557 } 554 }
558 555
559 if (size >= GPS_IN_BUFSIZ) { 556 if (size >= GPS_IN_BUFSIZ) {
560 dbg("%s - packet too large.", __func__); 557 dev_dbg(dev, "%s - packet too large.\n", __func__);
561 skip = 1; 558 skip = 1;
562 size = GSP_INITIAL_OFFSET; 559 size = GSP_INITIAL_OFFSET;
563 dleSeen = 0; 560 dleSeen = 0;
@@ -602,6 +599,7 @@ static int gsp_receive(struct garmin_data *garmin_data_p,
602static int gsp_send(struct garmin_data *garmin_data_p, 599static int gsp_send(struct garmin_data *garmin_data_p,
603 const unsigned char *buf, int count) 600 const unsigned char *buf, int count)
604{ 601{
602 struct device *dev = &garmin_data_p->port->dev;
605 const unsigned char *src; 603 const unsigned char *src;
606 unsigned char *dst; 604 unsigned char *dst;
607 int pktid = 0; 605 int pktid = 0;
@@ -610,12 +608,12 @@ static int gsp_send(struct garmin_data *garmin_data_p,
610 int i = 0; 608 int i = 0;
611 int k; 609 int k;
612 610
613 dbg("%s - state %d - %d bytes.", __func__, 611 dev_dbg(dev, "%s - state %d - %d bytes.\n", __func__,
614 garmin_data_p->state, count); 612 garmin_data_p->state, count);
615 613
616 k = garmin_data_p->outsize; 614 k = garmin_data_p->outsize;
617 if ((k+count) > GPS_OUT_BUFSIZ) { 615 if ((k+count) > GPS_OUT_BUFSIZ) {
618 dbg("packet too large"); 616 dev_dbg(dev, "packet too large\n");
619 garmin_data_p->outsize = 0; 617 garmin_data_p->outsize = 0;
620 return -4; 618 return -4;
621 } 619 }
@@ -634,28 +632,28 @@ static int gsp_send(struct garmin_data *garmin_data_p,
634 return 0; 632 return 0;
635 } 633 }
636 634
637 dbg("%s - %d bytes in buffer, %d bytes in pkt.", __func__, k, i); 635 dev_dbg(dev, "%s - %d bytes in buffer, %d bytes in pkt.\n", __func__, k, i);
638 636
639 /* garmin_data_p->outbuffer now contains a complete packet */ 637 /* garmin_data_p->outbuffer now contains a complete packet */
640 638
641 usb_serial_debug_data(debug, &garmin_data_p->port->dev, 639 usb_serial_debug_data(&garmin_data_p->port->dev, __func__, k,
642 __func__, k, garmin_data_p->outbuffer); 640 garmin_data_p->outbuffer);
643 641
644 garmin_data_p->outsize = 0; 642 garmin_data_p->outsize = 0;
645 643
646 if (GARMIN_LAYERID_APPL != getLayerId(garmin_data_p->outbuffer)) { 644 if (GARMIN_LAYERID_APPL != getLayerId(garmin_data_p->outbuffer)) {
647 dbg("not an application packet (%d)", 645 dev_dbg(dev, "not an application packet (%d)\n",
648 getLayerId(garmin_data_p->outbuffer)); 646 getLayerId(garmin_data_p->outbuffer));
649 return -1; 647 return -1;
650 } 648 }
651 649
652 if (pktid > 255) { 650 if (pktid > 255) {
653 dbg("packet-id %d too large", pktid); 651 dev_dbg(dev, "packet-id %d too large\n", pktid);
654 return -2; 652 return -2;
655 } 653 }
656 654
657 if (datalen > 255) { 655 if (datalen > 255) {
658 dbg("packet-size %d too large", datalen); 656 dev_dbg(dev, "packet-size %d too large\n", datalen);
659 return -3; 657 return -3;
660 } 658 }
661 659
@@ -722,7 +720,7 @@ static int gsp_next_packet(struct garmin_data *garmin_data_p)
722 struct garmin_packet *pkt = NULL; 720 struct garmin_packet *pkt = NULL;
723 721
724 while ((pkt = pkt_pop(garmin_data_p)) != NULL) { 722 while ((pkt = pkt_pop(garmin_data_p)) != NULL) {
725 dbg("%s - next pkt: %d", __func__, pkt->seq); 723 dev_dbg(&garmin_data_p->port->dev, "%s - next pkt: %d\n", __func__, pkt->seq);
726 result = gsp_send(garmin_data_p, pkt->data, pkt->size); 724 result = gsp_send(garmin_data_p, pkt->data, pkt->size);
727 if (result > 0) { 725 if (result > 0) {
728 kfree(pkt); 726 kfree(pkt);
@@ -768,7 +766,9 @@ static int nat_receive(struct garmin_data *garmin_data_p,
768 if (len >= GPS_IN_BUFSIZ) { 766 if (len >= GPS_IN_BUFSIZ) {
769 /* seems to be an invalid packet, ignore rest 767 /* seems to be an invalid packet, ignore rest
770 of input */ 768 of input */
771 dbg("%s - packet size too large: %d", __func__, len); 769 dev_dbg(&garmin_data_p->port->dev,
770 "%s - packet size too large: %d\n",
771 __func__, len);
772 garmin_data_p->insize = 0; 772 garmin_data_p->insize = 0;
773 count = 0; 773 count = 0;
774 result = -EINVPKT; 774 result = -EINVPKT;
@@ -849,10 +849,10 @@ static int process_resetdev_request(struct usb_serial_port *port)
849 spin_unlock_irqrestore(&garmin_data_p->lock, flags); 849 spin_unlock_irqrestore(&garmin_data_p->lock, flags);
850 850
851 usb_kill_urb(port->interrupt_in_urb); 851 usb_kill_urb(port->interrupt_in_urb);
852 dbg("%s - usb_reset_device", __func__); 852 dev_dbg(&port->dev, "%s - usb_reset_device\n", __func__);
853 status = usb_reset_device(port->serial->dev); 853 status = usb_reset_device(port->serial->dev);
854 if (status) 854 if (status)
855 dbg("%s - usb_reset_device failed: %d", 855 dev_dbg(&port->dev, "%s - usb_reset_device failed: %d\n",
856 __func__, status); 856 __func__, status);
857 return status; 857 return status;
858} 858}
@@ -889,7 +889,7 @@ static int garmin_init_session(struct usb_serial_port *port)
889 if (status == 0) { 889 if (status == 0) {
890 usb_kill_urb(port->interrupt_in_urb); 890 usb_kill_urb(port->interrupt_in_urb);
891 891
892 dbg("%s - adding interrupt input", __func__); 892 dev_dbg(&serial->dev->dev, "%s - adding interrupt input\n", __func__);
893 status = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); 893 status = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
894 if (status) 894 if (status)
895 dev_err(&serial->dev->dev, 895 dev_err(&serial->dev->dev,
@@ -902,7 +902,7 @@ static int garmin_init_session(struct usb_serial_port *port)
902 * gpsbabel/jeeps/gpslibusb.c gusb_reset_toggles() 902 * gpsbabel/jeeps/gpslibusb.c gusb_reset_toggles()
903 */ 903 */
904 if (status == 0) { 904 if (status == 0) {
905 dbg("%s - starting session ...", __func__); 905 dev_dbg(&serial->dev->dev, "%s - starting session ...\n", __func__);
906 garmin_data_p->state = STATE_ACTIVE; 906 garmin_data_p->state = STATE_ACTIVE;
907 907
908 for (i = 0; i < 3; i++) { 908 for (i = 0; i < 3; i++) {
@@ -952,8 +952,8 @@ static void garmin_close(struct usb_serial_port *port)
952 struct usb_serial *serial = port->serial; 952 struct usb_serial *serial = port->serial;
953 struct garmin_data *garmin_data_p = usb_get_serial_port_data(port); 953 struct garmin_data *garmin_data_p = usb_get_serial_port_data(port);
954 954
955 dbg("%s - port %d - mode=%d state=%d flags=0x%X", __func__, 955 dev_dbg(&port->dev, "%s - port %d - mode=%d state=%d flags=0x%X\n",
956 port->number, garmin_data_p->mode, 956 __func__, port->number, garmin_data_p->mode,
957 garmin_data_p->state, garmin_data_p->flags); 957 garmin_data_p->state, garmin_data_p->flags);
958 958
959 if (!serial) 959 if (!serial)
@@ -1032,7 +1032,7 @@ static int garmin_write_bulk(struct usb_serial_port *port,
1032 1032
1033 memcpy(buffer, buf, count); 1033 memcpy(buffer, buf, count);
1034 1034
1035 usb_serial_debug_data(debug, &port->dev, __func__, count, buffer); 1035 usb_serial_debug_data(&port->dev, __func__, count, buffer);
1036 1036
1037 usb_fill_bulk_urb(urb, serial->dev, 1037 usb_fill_bulk_urb(urb, serial->dev,
1038 usb_sndbulkpipe(serial->dev, 1038 usb_sndbulkpipe(serial->dev,
@@ -1073,11 +1073,12 @@ static int garmin_write_bulk(struct usb_serial_port *port,
1073static int garmin_write(struct tty_struct *tty, struct usb_serial_port *port, 1073static int garmin_write(struct tty_struct *tty, struct usb_serial_port *port,
1074 const unsigned char *buf, int count) 1074 const unsigned char *buf, int count)
1075{ 1075{
1076 struct device *dev = &port->dev;
1076 int pktid, pktsiz, len; 1077 int pktid, pktsiz, len;
1077 struct garmin_data *garmin_data_p = usb_get_serial_port_data(port); 1078 struct garmin_data *garmin_data_p = usb_get_serial_port_data(port);
1078 __le32 *privpkt = (__le32 *)garmin_data_p->privpkt; 1079 __le32 *privpkt = (__le32 *)garmin_data_p->privpkt;
1079 1080
1080 usb_serial_debug_data(debug, &port->dev, __func__, count, buf); 1081 usb_serial_debug_data(dev, __func__, count, buf);
1081 1082
1082 if (garmin_data_p->state == STATE_RESET) 1083 if (garmin_data_p->state == STATE_RESET)
1083 return -EIO; 1084 return -EIO;
@@ -1097,27 +1098,18 @@ static int garmin_write(struct tty_struct *tty, struct usb_serial_port *port,
1097 && GARMIN_LAYERID_PRIVATE == 1098 && GARMIN_LAYERID_PRIVATE ==
1098 getLayerId(garmin_data_p->privpkt)) { 1099 getLayerId(garmin_data_p->privpkt)) {
1099 1100
1100 dbg("%s - processing private request %d", 1101 dev_dbg(dev, "%s - processing private request %d\n",
1101 __func__, pktid); 1102 __func__, pktid);
1102 1103
1103 /* drop all unfinished transfers */ 1104 /* drop all unfinished transfers */
1104 garmin_clear(garmin_data_p); 1105 garmin_clear(garmin_data_p);
1105 1106
1106 switch (pktid) { 1107 switch (pktid) {
1107
1108 case PRIV_PKTID_SET_DEBUG:
1109 if (pktsiz != 4)
1110 return -EINVPKT;
1111 debug = __le32_to_cpu(privpkt[3]);
1112 dbg("%s - debug level set to 0x%X",
1113 __func__, debug);
1114 break;
1115
1116 case PRIV_PKTID_SET_MODE: 1108 case PRIV_PKTID_SET_MODE:
1117 if (pktsiz != 4) 1109 if (pktsiz != 4)
1118 return -EINVPKT; 1110 return -EINVPKT;
1119 garmin_data_p->mode = __le32_to_cpu(privpkt[3]); 1111 garmin_data_p->mode = __le32_to_cpu(privpkt[3]);
1120 dbg("%s - mode set to %d", 1112 dev_dbg(dev, "%s - mode set to %d\n",
1121 __func__, garmin_data_p->mode); 1113 __func__, garmin_data_p->mode);
1122 break; 1114 break;
1123 1115
@@ -1133,7 +1125,7 @@ static int garmin_write(struct tty_struct *tty, struct usb_serial_port *port,
1133 if (pktsiz != 4) 1125 if (pktsiz != 4)
1134 return -EINVPKT; 1126 return -EINVPKT;
1135 initial_mode = __le32_to_cpu(privpkt[3]); 1127 initial_mode = __le32_to_cpu(privpkt[3]);
1136 dbg("%s - initial_mode set to %d", 1128 dev_dbg(dev, "%s - initial_mode set to %d\n",
1137 __func__, 1129 __func__,
1138 garmin_data_p->mode); 1130 garmin_data_p->mode);
1139 break; 1131 break;
@@ -1169,7 +1161,7 @@ static void garmin_read_process(struct garmin_data *garmin_data_p,
1169 1161
1170 if (garmin_data_p->flags & FLAGS_DROP_DATA) { 1162 if (garmin_data_p->flags & FLAGS_DROP_DATA) {
1171 /* abort-transfer cmd is actice */ 1163 /* abort-transfer cmd is actice */
1172 dbg("%s - pkt dropped", __func__); 1164 dev_dbg(&garmin_data_p->port->dev, "%s - pkt dropped\n", __func__);
1173 } else if (garmin_data_p->state != STATE_DISCONNECTED && 1165 } else if (garmin_data_p->state != STATE_DISCONNECTED &&
1174 garmin_data_p->state != STATE_RESET) { 1166 garmin_data_p->state != STATE_RESET) {
1175 1167
@@ -1178,7 +1170,7 @@ static void garmin_read_process(struct garmin_data *garmin_data_p,
1178 send it directly to the tty port */ 1170 send it directly to the tty port */
1179 if (garmin_data_p->flags & FLAGS_QUEUING) { 1171 if (garmin_data_p->flags & FLAGS_QUEUING) {
1180 pkt_add(garmin_data_p, data, data_length); 1172 pkt_add(garmin_data_p, data, data_length);
1181 } else if (bulk_data || 1173 } else if (bulk_data ||
1182 getLayerId(data) == GARMIN_LAYERID_APPL) { 1174 getLayerId(data) == GARMIN_LAYERID_APPL) {
1183 1175
1184 spin_lock_irqsave(&garmin_data_p->lock, flags); 1176 spin_lock_irqsave(&garmin_data_p->lock, flags);
@@ -1208,18 +1200,17 @@ static void garmin_read_bulk_callback(struct urb *urb)
1208 int retval; 1200 int retval;
1209 1201
1210 if (!serial) { 1202 if (!serial) {
1211 dbg("%s - bad serial pointer, exiting", __func__); 1203 dev_dbg(&urb->dev->dev, "%s - bad serial pointer, exiting\n", __func__);
1212 return; 1204 return;
1213 } 1205 }
1214 1206
1215 if (status) { 1207 if (status) {
1216 dbg("%s - nonzero read bulk status received: %d", 1208 dev_dbg(&urb->dev->dev, "%s - nonzero read bulk status received: %d\n",
1217 __func__, status); 1209 __func__, status);
1218 return; 1210 return;
1219 } 1211 }
1220 1212
1221 usb_serial_debug_data(debug, &port->dev, 1213 usb_serial_debug_data(&port->dev, __func__, urb->actual_length, data);
1222 __func__, urb->actual_length, data);
1223 1214
1224 garmin_read_process(garmin_data_p, data, urb->actual_length, 1); 1215 garmin_read_process(garmin_data_p, data, urb->actual_length, 1);
1225 1216
@@ -1239,11 +1230,11 @@ static void garmin_read_bulk_callback(struct urb *urb)
1239 retval = usb_submit_urb(port->read_urb, GFP_ATOMIC); 1230 retval = usb_submit_urb(port->read_urb, GFP_ATOMIC);
1240 if (retval) 1231 if (retval)
1241 dev_err(&port->dev, 1232 dev_err(&port->dev,
1242 "%s - failed resubmitting read urb, " 1233 "%s - failed resubmitting read urb, error %d\n",
1243 "error %d\n", __func__, retval); 1234 __func__, retval);
1244 } 1235 }
1245 } else { 1236 } else {
1246 dbg("%s - end of bulk data", __func__); 1237 dev_dbg(&port->dev, "%s - end of bulk data\n", __func__);
1247 spin_lock_irqsave(&garmin_data_p->lock, flags); 1238 spin_lock_irqsave(&garmin_data_p->lock, flags);
1248 garmin_data_p->flags &= ~FLAGS_BULK_IN_ACTIVE; 1239 garmin_data_p->flags &= ~FLAGS_BULK_IN_ACTIVE;
1249 spin_unlock_irqrestore(&garmin_data_p->lock, flags); 1240 spin_unlock_irqrestore(&garmin_data_p->lock, flags);
@@ -1268,23 +1259,23 @@ static void garmin_read_int_callback(struct urb *urb)
1268 case -ENOENT: 1259 case -ENOENT:
1269 case -ESHUTDOWN: 1260 case -ESHUTDOWN:
1270 /* this urb is terminated, clean up */ 1261 /* this urb is terminated, clean up */
1271 dbg("%s - urb shutting down with status: %d", 1262 dev_dbg(&urb->dev->dev, "%s - urb shutting down with status: %d\n",
1272 __func__, status); 1263 __func__, status);
1273 return; 1264 return;
1274 default: 1265 default:
1275 dbg("%s - nonzero urb status received: %d", 1266 dev_dbg(&urb->dev->dev, "%s - nonzero urb status received: %d\n",
1276 __func__, status); 1267 __func__, status);
1277 return; 1268 return;
1278 } 1269 }
1279 1270
1280 usb_serial_debug_data(debug, &port->dev, __func__, 1271 usb_serial_debug_data(&port->dev, __func__, urb->actual_length,
1281 urb->actual_length, urb->transfer_buffer); 1272 urb->transfer_buffer);
1282 1273
1283 if (urb->actual_length == sizeof(GARMIN_BULK_IN_AVAIL_REPLY) && 1274 if (urb->actual_length == sizeof(GARMIN_BULK_IN_AVAIL_REPLY) &&
1284 0 == memcmp(data, GARMIN_BULK_IN_AVAIL_REPLY, 1275 0 == memcmp(data, GARMIN_BULK_IN_AVAIL_REPLY,
1285 sizeof(GARMIN_BULK_IN_AVAIL_REPLY))) { 1276 sizeof(GARMIN_BULK_IN_AVAIL_REPLY))) {
1286 1277
1287 dbg("%s - bulk data available.", __func__); 1278 dev_dbg(&port->dev, "%s - bulk data available.\n", __func__);
1288 1279
1289 if (0 == (garmin_data_p->flags & FLAGS_BULK_IN_ACTIVE)) { 1280 if (0 == (garmin_data_p->flags & FLAGS_BULK_IN_ACTIVE)) {
1290 1281
@@ -1319,7 +1310,7 @@ static void garmin_read_int_callback(struct urb *urb)
1319 garmin_data_p->serial_num = __le32_to_cpup( 1310 garmin_data_p->serial_num = __le32_to_cpup(
1320 (__le32 *)(data+GARMIN_PKTHDR_LENGTH)); 1311 (__le32 *)(data+GARMIN_PKTHDR_LENGTH));
1321 1312
1322 dbg("%s - start-of-session reply seen - serial %u.", 1313 dev_dbg(&port->dev, "%s - start-of-session reply seen - serial %u.\n",
1323 __func__, garmin_data_p->serial_num); 1314 __func__, garmin_data_p->serial_num);
1324 } 1315 }
1325 1316
@@ -1495,7 +1486,5 @@ MODULE_AUTHOR(DRIVER_AUTHOR);
1495MODULE_DESCRIPTION(DRIVER_DESC); 1486MODULE_DESCRIPTION(DRIVER_DESC);
1496MODULE_LICENSE("GPL"); 1487MODULE_LICENSE("GPL");
1497 1488
1498module_param(debug, bool, S_IWUSR | S_IRUGO);
1499MODULE_PARM_DESC(debug, "Debug enabled or not");
1500module_param(initial_mode, int, S_IRUGO); 1489module_param(initial_mode, int, S_IRUGO);
1501MODULE_PARM_DESC(initial_mode, "Initial mode"); 1490MODULE_PARM_DESC(initial_mode, "Initial mode");
diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c
index 9b026bf7afef..296612153ea2 100644
--- a/drivers/usb/serial/generic.c
+++ b/drivers/usb/serial/generic.c
@@ -24,8 +24,6 @@
24#include <linux/kfifo.h> 24#include <linux/kfifo.h>
25#include <linux/serial.h> 25#include <linux/serial.h>
26 26
27static int debug;
28
29#ifdef CONFIG_USB_SERIAL_GENERIC 27#ifdef CONFIG_USB_SERIAL_GENERIC
30 28
31static __u16 vendor = 0x05f9; 29static __u16 vendor = 0x05f9;
@@ -60,11 +58,10 @@ static struct usb_serial_driver * const serial_drivers[] = {
60 58
61#endif 59#endif
62 60
63int usb_serial_generic_register(int _debug) 61int usb_serial_generic_register(void)
64{ 62{
65 int retval = 0; 63 int retval = 0;
66 64
67 debug = _debug;
68#ifdef CONFIG_USB_SERIAL_GENERIC 65#ifdef CONFIG_USB_SERIAL_GENERIC
69 generic_device_ids[0].idVendor = vendor; 66 generic_device_ids[0].idVendor = vendor;
70 generic_device_ids[0].idProduct = product; 67 generic_device_ids[0].idProduct = product;
@@ -171,8 +168,7 @@ retry:
171 urb->transfer_buffer, 168 urb->transfer_buffer,
172 port->bulk_out_size); 169 port->bulk_out_size);
173 urb->transfer_buffer_length = count; 170 urb->transfer_buffer_length = count;
174 usb_serial_debug_data(debug, &port->dev, __func__, count, 171 usb_serial_debug_data(&port->dev, __func__, count, urb->transfer_buffer);
175 urb->transfer_buffer);
176 spin_lock_irqsave(&port->lock, flags); 172 spin_lock_irqsave(&port->lock, flags);
177 port->tx_bytes += count; 173 port->tx_bytes += count;
178 spin_unlock_irqrestore(&port->lock, flags); 174 spin_unlock_irqrestore(&port->lock, flags);
@@ -365,8 +361,7 @@ void usb_serial_generic_read_bulk_callback(struct urb *urb)
365 return; 361 return;
366 } 362 }
367 363
368 usb_serial_debug_data(debug, &port->dev, __func__, 364 usb_serial_debug_data(&port->dev, __func__, urb->actual_length, data);
369 urb->actual_length, data);
370 port->serial->type->process_read_urb(urb); 365 port->serial->type->process_read_urb(urb);
371 366
372 /* Throttle the device if requested by tty */ 367 /* Throttle the device if requested by tty */
diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c
index f435575c4e6e..8e6faaf3580c 100644
--- a/drivers/usb/serial/io_edgeport.c
+++ b/drivers/usb/serial/io_edgeport.c
@@ -190,9 +190,6 @@ static const struct divisor_table_entry divisor_table[] = {
190 { 230400, 1}, 190 { 230400, 1},
191}; 191};
192 192
193/* local variables */
194static bool debug;
195
196/* Number of outstanding Command Write Urbs */ 193/* Number of outstanding Command Write Urbs */
197static atomic_t CmdUrbs = ATOMIC_INIT(0); 194static atomic_t CmdUrbs = ATOMIC_INIT(0);
198 195
@@ -244,7 +241,7 @@ static void handle_new_lsr(struct edgeport_port *edge_port, __u8 lsrData,
244 __u8 lsr, __u8 data); 241 __u8 lsr, __u8 data);
245static int send_iosp_ext_cmd(struct edgeport_port *edge_port, __u8 command, 242static int send_iosp_ext_cmd(struct edgeport_port *edge_port, __u8 command,
246 __u8 param); 243 __u8 param);
247static int calc_baud_rate_divisor(int baud_rate, int *divisor); 244static int calc_baud_rate_divisor(struct device *dev, int baud_rate, int *divisor);
248static int send_cmd_write_baud_rate(struct edgeport_port *edge_port, 245static int send_cmd_write_baud_rate(struct edgeport_port *edge_port,
249 int baudRate); 246 int baudRate);
250static void change_port_settings(struct tty_struct *tty, 247static void change_port_settings(struct tty_struct *tty,
@@ -286,6 +283,7 @@ static void unicode_to_ascii(char *string, int buflen,
286 ************************************************************************/ 283 ************************************************************************/
287static void update_edgeport_E2PROM(struct edgeport_serial *edge_serial) 284static void update_edgeport_E2PROM(struct edgeport_serial *edge_serial)
288{ 285{
286 struct device *dev = &edge_serial->serial->dev->dev;
289 __u32 BootCurVer; 287 __u32 BootCurVer;
290 __u32 BootNewVer; 288 __u32 BootNewVer;
291 __u8 BootMajorVersion; 289 __u8 BootMajorVersion;
@@ -311,7 +309,7 @@ static void update_edgeport_E2PROM(struct edgeport_serial *edge_serial)
311 response = request_ihex_firmware(&fw, fw_name, 309 response = request_ihex_firmware(&fw, fw_name,
312 &edge_serial->serial->dev->dev); 310 &edge_serial->serial->dev->dev);
313 if (response) { 311 if (response) {
314 printk(KERN_ERR "Failed to load image \"%s\" err %d\n", 312 dev_err(dev, "Failed to load image \"%s\" err %d\n",
315 fw_name, response); 313 fw_name, response);
316 return; 314 return;
317 } 315 }
@@ -330,20 +328,20 @@ static void update_edgeport_E2PROM(struct edgeport_serial *edge_serial)
330 (BootMinorVersion << 16) + 328 (BootMinorVersion << 16) +
331 BootBuildNumber; 329 BootBuildNumber;
332 330
333 dbg("Current Boot Image version %d.%d.%d", 331 dev_dbg(dev, "Current Boot Image version %d.%d.%d\n",
334 edge_serial->boot_descriptor.MajorVersion, 332 edge_serial->boot_descriptor.MajorVersion,
335 edge_serial->boot_descriptor.MinorVersion, 333 edge_serial->boot_descriptor.MinorVersion,
336 le16_to_cpu(edge_serial->boot_descriptor.BuildNumber)); 334 le16_to_cpu(edge_serial->boot_descriptor.BuildNumber));
337 335
338 336
339 if (BootNewVer > BootCurVer) { 337 if (BootNewVer > BootCurVer) {
340 dbg("**Update Boot Image from %d.%d.%d to %d.%d.%d", 338 dev_dbg(dev, "**Update Boot Image from %d.%d.%d to %d.%d.%d\n",
341 edge_serial->boot_descriptor.MajorVersion, 339 edge_serial->boot_descriptor.MajorVersion,
342 edge_serial->boot_descriptor.MinorVersion, 340 edge_serial->boot_descriptor.MinorVersion,
343 le16_to_cpu(edge_serial->boot_descriptor.BuildNumber), 341 le16_to_cpu(edge_serial->boot_descriptor.BuildNumber),
344 BootMajorVersion, BootMinorVersion, BootBuildNumber); 342 BootMajorVersion, BootMinorVersion, BootBuildNumber);
345 343
346 dbg("Downloading new Boot Image"); 344 dev_dbg(dev, "Downloading new Boot Image\n");
347 345
348 for (rec = ihex_next_binrec(rec); rec; 346 for (rec = ihex_next_binrec(rec); rec;
349 rec = ihex_next_binrec(rec)) { 347 rec = ihex_next_binrec(rec)) {
@@ -362,7 +360,7 @@ static void update_edgeport_E2PROM(struct edgeport_serial *edge_serial)
362 } 360 }
363 } 361 }
364 } else { 362 } else {
365 dbg("Boot Image -- already up to date"); 363 dev_dbg(dev, "Boot Image -- already up to date\n");
366 } 364 }
367 release_firmware(fw); 365 release_firmware(fw);
368} 366}
@@ -379,7 +377,7 @@ static int get_string_desc(struct usb_device *dev, int Id,
379 struct usb_string_descriptor StringDesc; 377 struct usb_string_descriptor StringDesc;
380 struct usb_string_descriptor *pStringDesc; 378 struct usb_string_descriptor *pStringDesc;
381 379
382 dbg("%s - USB String ID = %d", __func__, Id); 380 dev_dbg(&dev->dev, "%s - USB String ID = %d\n", __func__, Id);
383 381
384 if (!usb_get_descriptor(dev, USB_DT_STRING, Id, &StringDesc, 382 if (!usb_get_descriptor(dev, USB_DT_STRING, Id, &StringDesc,
385 sizeof(StringDesc))) 383 sizeof(StringDesc)))
@@ -400,34 +398,39 @@ static int get_string_desc(struct usb_device *dev, int Id,
400} 398}
401#endif 399#endif
402 400
403static void dump_product_info(struct edgeport_product_info *product_info) 401static void dump_product_info(struct edgeport_serial *edge_serial,
402 struct edgeport_product_info *product_info)
404{ 403{
404 struct device *dev = &edge_serial->serial->dev->dev;
405
405 /* Dump Product Info structure */ 406 /* Dump Product Info structure */
406 dbg("**Product Information:"); 407 dev_dbg(dev, "**Product Information:\n");
407 dbg(" ProductId %x", product_info->ProductId); 408 dev_dbg(dev, " ProductId %x\n", product_info->ProductId);
408 dbg(" NumPorts %d", product_info->NumPorts); 409 dev_dbg(dev, " NumPorts %d\n", product_info->NumPorts);
409 dbg(" ProdInfoVer %d", product_info->ProdInfoVer); 410 dev_dbg(dev, " ProdInfoVer %d\n", product_info->ProdInfoVer);
410 dbg(" IsServer %d", product_info->IsServer); 411 dev_dbg(dev, " IsServer %d\n", product_info->IsServer);
411 dbg(" IsRS232 %d", product_info->IsRS232); 412 dev_dbg(dev, " IsRS232 %d\n", product_info->IsRS232);
412 dbg(" IsRS422 %d", product_info->IsRS422); 413 dev_dbg(dev, " IsRS422 %d\n", product_info->IsRS422);
413 dbg(" IsRS485 %d", product_info->IsRS485); 414 dev_dbg(dev, " IsRS485 %d\n", product_info->IsRS485);
414 dbg(" RomSize %d", product_info->RomSize); 415 dev_dbg(dev, " RomSize %d\n", product_info->RomSize);
415 dbg(" RamSize %d", product_info->RamSize); 416 dev_dbg(dev, " RamSize %d\n", product_info->RamSize);
416 dbg(" CpuRev %x", product_info->CpuRev); 417 dev_dbg(dev, " CpuRev %x\n", product_info->CpuRev);
417 dbg(" BoardRev %x", product_info->BoardRev); 418 dev_dbg(dev, " BoardRev %x\n", product_info->BoardRev);
418 dbg(" BootMajorVersion %d.%d.%d", product_info->BootMajorVersion, 419 dev_dbg(dev, " BootMajorVersion %d.%d.%d\n",
419 product_info->BootMinorVersion, 420 product_info->BootMajorVersion,
420 le16_to_cpu(product_info->BootBuildNumber)); 421 product_info->BootMinorVersion,
421 dbg(" FirmwareMajorVersion %d.%d.%d", 422 le16_to_cpu(product_info->BootBuildNumber));
422 product_info->FirmwareMajorVersion, 423 dev_dbg(dev, " FirmwareMajorVersion %d.%d.%d\n",
423 product_info->FirmwareMinorVersion, 424 product_info->FirmwareMajorVersion,
424 le16_to_cpu(product_info->FirmwareBuildNumber)); 425 product_info->FirmwareMinorVersion,
425 dbg(" ManufactureDescDate %d/%d/%d", 426 le16_to_cpu(product_info->FirmwareBuildNumber));
426 product_info->ManufactureDescDate[0], 427 dev_dbg(dev, " ManufactureDescDate %d/%d/%d\n",
427 product_info->ManufactureDescDate[1], 428 product_info->ManufactureDescDate[0],
428 product_info->ManufactureDescDate[2]+1900); 429 product_info->ManufactureDescDate[1],
429 dbg(" iDownloadFile 0x%x", product_info->iDownloadFile); 430 product_info->ManufactureDescDate[2]+1900);
430 dbg(" EpicVer %d", product_info->EpicVer); 431 dev_dbg(dev, " iDownloadFile 0x%x\n",
432 product_info->iDownloadFile);
433 dev_dbg(dev, " EpicVer %d\n", product_info->EpicVer);
431} 434}
432 435
433static void get_product_info(struct edgeport_serial *edge_serial) 436static void get_product_info(struct edgeport_serial *edge_serial)
@@ -462,7 +465,7 @@ static void get_product_info(struct edgeport_serial *edge_serial)
462 product_info->iDownloadFile = EDGE_DOWNLOAD_FILE_80251; 465 product_info->iDownloadFile = EDGE_DOWNLOAD_FILE_80251;
463 else 466 else
464 product_info->iDownloadFile = EDGE_DOWNLOAD_FILE_I930; 467 product_info->iDownloadFile = EDGE_DOWNLOAD_FILE_I930;
465 468
466 /* Determine Product type and set appropriate flags */ 469 /* Determine Product type and set appropriate flags */
467 switch (DEVICE_ID_FROM_USB_PRODUCT_ID(product_info->ProductId)) { 470 switch (DEVICE_ID_FROM_USB_PRODUCT_ID(product_info->ProductId)) {
468 case ION_DEVICE_ID_EDGEPORT_COMPATIBLE: 471 case ION_DEVICE_ID_EDGEPORT_COMPATIBLE:
@@ -490,7 +493,7 @@ static void get_product_info(struct edgeport_serial *edge_serial)
490 break; 493 break;
491 } 494 }
492 495
493 dump_product_info(product_info); 496 dump_product_info(edge_serial, product_info);
494} 497}
495 498
496static int get_epic_descriptor(struct edgeport_serial *ep) 499static int get_epic_descriptor(struct edgeport_serial *ep)
@@ -500,6 +503,7 @@ static int get_epic_descriptor(struct edgeport_serial *ep)
500 struct edgeport_product_info *product_info = &ep->product_info; 503 struct edgeport_product_info *product_info = &ep->product_info;
501 struct edge_compatibility_descriptor *epic = &ep->epic_descriptor; 504 struct edge_compatibility_descriptor *epic = &ep->epic_descriptor;
502 struct edge_compatibility_bits *bits; 505 struct edge_compatibility_bits *bits;
506 struct device *dev = &serial->dev->dev;
503 507
504 ep->is_epic = 0; 508 ep->is_epic = 0;
505 result = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), 509 result = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0),
@@ -509,8 +513,6 @@ static int get_epic_descriptor(struct edgeport_serial *ep)
509 sizeof(struct edge_compatibility_descriptor), 513 sizeof(struct edge_compatibility_descriptor),
510 300); 514 300);
511 515
512 dbg("%s result = %d", __func__, result);
513
514 if (result > 0) { 516 if (result > 0) {
515 ep->is_epic = 1; 517 ep->is_epic = 1;
516 memset(product_info, 0, sizeof(struct edgeport_product_info)); 518 memset(product_info, 0, sizeof(struct edgeport_product_info));
@@ -524,23 +526,23 @@ static int get_epic_descriptor(struct edgeport_serial *ep)
524 product_info->EpicVer = epic->EpicVer; 526 product_info->EpicVer = epic->EpicVer;
525 product_info->Epic = epic->Supports; 527 product_info->Epic = epic->Supports;
526 product_info->ProductId = ION_DEVICE_ID_EDGEPORT_COMPATIBLE; 528 product_info->ProductId = ION_DEVICE_ID_EDGEPORT_COMPATIBLE;
527 dump_product_info(product_info); 529 dump_product_info(ep, product_info);
528 530
529 bits = &ep->epic_descriptor.Supports; 531 bits = &ep->epic_descriptor.Supports;
530 dbg("**EPIC descriptor:"); 532 dev_dbg(dev, "**EPIC descriptor:\n");
531 dbg(" VendEnableSuspend: %s", bits->VendEnableSuspend ? "TRUE": "FALSE"); 533 dev_dbg(dev, " VendEnableSuspend: %s\n", bits->VendEnableSuspend ? "TRUE": "FALSE");
532 dbg(" IOSPOpen : %s", bits->IOSPOpen ? "TRUE": "FALSE"); 534 dev_dbg(dev, " IOSPOpen : %s\n", bits->IOSPOpen ? "TRUE": "FALSE");
533 dbg(" IOSPClose : %s", bits->IOSPClose ? "TRUE": "FALSE"); 535 dev_dbg(dev, " IOSPClose : %s\n", bits->IOSPClose ? "TRUE": "FALSE");
534 dbg(" IOSPChase : %s", bits->IOSPChase ? "TRUE": "FALSE"); 536 dev_dbg(dev, " IOSPChase : %s\n", bits->IOSPChase ? "TRUE": "FALSE");
535 dbg(" IOSPSetRxFlow : %s", bits->IOSPSetRxFlow ? "TRUE": "FALSE"); 537 dev_dbg(dev, " IOSPSetRxFlow : %s\n", bits->IOSPSetRxFlow ? "TRUE": "FALSE");
536 dbg(" IOSPSetTxFlow : %s", bits->IOSPSetTxFlow ? "TRUE": "FALSE"); 538 dev_dbg(dev, " IOSPSetTxFlow : %s\n", bits->IOSPSetTxFlow ? "TRUE": "FALSE");
537 dbg(" IOSPSetXChar : %s", bits->IOSPSetXChar ? "TRUE": "FALSE"); 539 dev_dbg(dev, " IOSPSetXChar : %s\n", bits->IOSPSetXChar ? "TRUE": "FALSE");
538 dbg(" IOSPRxCheck : %s", bits->IOSPRxCheck ? "TRUE": "FALSE"); 540 dev_dbg(dev, " IOSPRxCheck : %s\n", bits->IOSPRxCheck ? "TRUE": "FALSE");
539 dbg(" IOSPSetClrBreak : %s", bits->IOSPSetClrBreak ? "TRUE": "FALSE"); 541 dev_dbg(dev, " IOSPSetClrBreak : %s\n", bits->IOSPSetClrBreak ? "TRUE": "FALSE");
540 dbg(" IOSPWriteMCR : %s", bits->IOSPWriteMCR ? "TRUE": "FALSE"); 542 dev_dbg(dev, " IOSPWriteMCR : %s\n", bits->IOSPWriteMCR ? "TRUE": "FALSE");
541 dbg(" IOSPWriteLCR : %s", bits->IOSPWriteLCR ? "TRUE": "FALSE"); 543 dev_dbg(dev, " IOSPWriteLCR : %s\n", bits->IOSPWriteLCR ? "TRUE": "FALSE");
542 dbg(" IOSPSetBaudRate : %s", bits->IOSPSetBaudRate ? "TRUE": "FALSE"); 544 dev_dbg(dev, " IOSPSetBaudRate : %s\n", bits->IOSPSetBaudRate ? "TRUE": "FALSE");
543 dbg(" TrueEdgeport : %s", bits->TrueEdgeport ? "TRUE": "FALSE"); 545 dev_dbg(dev, " TrueEdgeport : %s\n", bits->TrueEdgeport ? "TRUE": "FALSE");
544 } 546 }
545 547
546 return result; 548 return result;
@@ -561,7 +563,8 @@ static int get_epic_descriptor(struct edgeport_serial *ep)
561 *****************************************************************************/ 563 *****************************************************************************/
562static void edge_interrupt_callback(struct urb *urb) 564static void edge_interrupt_callback(struct urb *urb)
563{ 565{
564 struct edgeport_serial *edge_serial = urb->context; 566 struct edgeport_serial *edge_serial = urb->context;
567 struct device *dev;
565 struct edgeport_port *edge_port; 568 struct edgeport_port *edge_port;
566 struct usb_serial_port *port; 569 struct usb_serial_port *port;
567 struct tty_struct *tty; 570 struct tty_struct *tty;
@@ -574,8 +577,6 @@ static void edge_interrupt_callback(struct urb *urb)
574 int result; 577 int result;
575 int status = urb->status; 578 int status = urb->status;
576 579
577 dbg("%s", __func__);
578
579 switch (status) { 580 switch (status) {
580 case 0: 581 case 0:
581 /* success */ 582 /* success */
@@ -584,36 +585,42 @@ static void edge_interrupt_callback(struct urb *urb)
584 case -ENOENT: 585 case -ENOENT:
585 case -ESHUTDOWN: 586 case -ESHUTDOWN:
586 /* this urb is terminated, clean up */ 587 /* this urb is terminated, clean up */
587 dbg("%s - urb shutting down with status: %d", 588 dev_dbg(&urb->dev->dev, "%s - urb shutting down with status: %d\n", __func__, status);
588 __func__, status);
589 return; 589 return;
590 default: 590 default:
591 dbg("%s - nonzero urb status received: %d", __func__, status); 591 dev_dbg(&urb->dev->dev, "%s - nonzero urb status received: %d\n", __func__, status);
592 goto exit; 592 goto exit;
593 } 593 }
594 594
595 dev = &edge_serial->serial->dev->dev;
596
595 /* process this interrupt-read even if there are no ports open */ 597 /* process this interrupt-read even if there are no ports open */
596 if (length) { 598 if (length) {
597 usb_serial_debug_data(debug, &edge_serial->serial->dev->dev, 599 usb_serial_debug_data(dev, __func__, length, data);
598 __func__, length, data);
599 600
600 if (length > 1) { 601 if (length > 1) {
601 bytes_avail = data[0] | (data[1] << 8); 602 bytes_avail = data[0] | (data[1] << 8);
602 if (bytes_avail) { 603 if (bytes_avail) {
603 spin_lock(&edge_serial->es_lock); 604 spin_lock(&edge_serial->es_lock);
604 edge_serial->rxBytesAvail += bytes_avail; 605 edge_serial->rxBytesAvail += bytes_avail;
605 dbg("%s - bytes_avail=%d, rxBytesAvail=%d, read_in_progress=%d", __func__, bytes_avail, edge_serial->rxBytesAvail, edge_serial->read_in_progress); 606 dev_dbg(dev,
607 "%s - bytes_avail=%d, rxBytesAvail=%d, read_in_progress=%d\n",
608 __func__, bytes_avail,
609 edge_serial->rxBytesAvail,
610 edge_serial->read_in_progress);
606 611
607 if (edge_serial->rxBytesAvail > 0 && 612 if (edge_serial->rxBytesAvail > 0 &&
608 !edge_serial->read_in_progress) { 613 !edge_serial->read_in_progress) {
609 dbg("%s - posting a read", __func__); 614 dev_dbg(dev, "%s - posting a read\n", __func__);
610 edge_serial->read_in_progress = true; 615 edge_serial->read_in_progress = true;
611 616
612 /* we have pending bytes on the 617 /* we have pending bytes on the
613 bulk in pipe, send a request */ 618 bulk in pipe, send a request */
614 result = usb_submit_urb(edge_serial->read_urb, GFP_ATOMIC); 619 result = usb_submit_urb(edge_serial->read_urb, GFP_ATOMIC);
615 if (result) { 620 if (result) {
616 dev_err(&edge_serial->serial->dev->dev, "%s - usb_submit_urb(read bulk) failed with result = %d\n", __func__, result); 621 dev_err(dev,
622 "%s - usb_submit_urb(read bulk) failed with result = %d\n",
623 __func__, result);
617 edge_serial->read_in_progress = false; 624 edge_serial->read_in_progress = false;
618 } 625 }
619 } 626 }
@@ -633,9 +640,9 @@ static void edge_interrupt_callback(struct urb *urb)
633 spin_lock(&edge_port->ep_lock); 640 spin_lock(&edge_port->ep_lock);
634 edge_port->txCredits += txCredits; 641 edge_port->txCredits += txCredits;
635 spin_unlock(&edge_port->ep_lock); 642 spin_unlock(&edge_port->ep_lock);
636 dbg("%s - txcredits for port%d = %d", 643 dev_dbg(dev, "%s - txcredits for port%d = %d\n",
637 __func__, portNumber, 644 __func__, portNumber,
638 edge_port->txCredits); 645 edge_port->txCredits);
639 646
640 /* tell the tty driver that something 647 /* tell the tty driver that something
641 has changed */ 648 has changed */
@@ -673,49 +680,48 @@ exit:
673static void edge_bulk_in_callback(struct urb *urb) 680static void edge_bulk_in_callback(struct urb *urb)
674{ 681{
675 struct edgeport_serial *edge_serial = urb->context; 682 struct edgeport_serial *edge_serial = urb->context;
683 struct device *dev;
676 unsigned char *data = urb->transfer_buffer; 684 unsigned char *data = urb->transfer_buffer;
677 int retval; 685 int retval;
678 __u16 raw_data_length; 686 __u16 raw_data_length;
679 int status = urb->status; 687 int status = urb->status;
680 688
681 dbg("%s", __func__);
682
683 if (status) { 689 if (status) {
684 dbg("%s - nonzero read bulk status received: %d", 690 dev_dbg(&urb->dev->dev, "%s - nonzero read bulk status received: %d\n",
685 __func__, status); 691 __func__, status);
686 edge_serial->read_in_progress = false; 692 edge_serial->read_in_progress = false;
687 return; 693 return;
688 } 694 }
689 695
690 if (urb->actual_length == 0) { 696 if (urb->actual_length == 0) {
691 dbg("%s - read bulk callback with no data", __func__); 697 dev_dbg(&urb->dev->dev, "%s - read bulk callback with no data\n", __func__);
692 edge_serial->read_in_progress = false; 698 edge_serial->read_in_progress = false;
693 return; 699 return;
694 } 700 }
695 701
702 dev = &edge_serial->serial->dev->dev;
696 raw_data_length = urb->actual_length; 703 raw_data_length = urb->actual_length;
697 704
698 usb_serial_debug_data(debug, &edge_serial->serial->dev->dev, 705 usb_serial_debug_data(dev, __func__, raw_data_length, data);
699 __func__, raw_data_length, data);
700 706
701 spin_lock(&edge_serial->es_lock); 707 spin_lock(&edge_serial->es_lock);
702 708
703 /* decrement our rxBytes available by the number that we just got */ 709 /* decrement our rxBytes available by the number that we just got */
704 edge_serial->rxBytesAvail -= raw_data_length; 710 edge_serial->rxBytesAvail -= raw_data_length;
705 711
706 dbg("%s - Received = %d, rxBytesAvail %d", __func__, 712 dev_dbg(dev, "%s - Received = %d, rxBytesAvail %d\n", __func__,
707 raw_data_length, edge_serial->rxBytesAvail); 713 raw_data_length, edge_serial->rxBytesAvail);
708 714
709 process_rcvd_data(edge_serial, data, urb->actual_length); 715 process_rcvd_data(edge_serial, data, urb->actual_length);
710 716
711 /* check to see if there's any more data for us to read */ 717 /* check to see if there's any more data for us to read */
712 if (edge_serial->rxBytesAvail > 0) { 718 if (edge_serial->rxBytesAvail > 0) {
713 dbg("%s - posting a read", __func__); 719 dev_dbg(dev, "%s - posting a read\n", __func__);
714 retval = usb_submit_urb(edge_serial->read_urb, GFP_ATOMIC); 720 retval = usb_submit_urb(edge_serial->read_urb, GFP_ATOMIC);
715 if (retval) { 721 if (retval) {
716 dev_err(&urb->dev->dev, 722 dev_err(dev,
717 "%s - usb_submit_urb(read bulk) failed, " 723 "%s - usb_submit_urb(read bulk) failed, retval = %d\n",
718 "retval = %d\n", __func__, retval); 724 __func__, retval);
719 edge_serial->read_in_progress = false; 725 edge_serial->read_in_progress = false;
720 } 726 }
721 } else { 727 } else {
@@ -737,11 +743,10 @@ static void edge_bulk_out_data_callback(struct urb *urb)
737 struct tty_struct *tty; 743 struct tty_struct *tty;
738 int status = urb->status; 744 int status = urb->status;
739 745
740 dbg("%s", __func__);
741
742 if (status) { 746 if (status) {
743 dbg("%s - nonzero write bulk status received: %d", 747 dev_dbg(&urb->dev->dev,
744 __func__, status); 748 "%s - nonzero write bulk status received: %d\n",
749 __func__, status);
745 } 750 }
746 751
747 tty = tty_port_tty_get(&edge_port->port->port); 752 tty = tty_port_tty_get(&edge_port->port->port);
@@ -773,11 +778,9 @@ static void edge_bulk_out_cmd_callback(struct urb *urb)
773 struct tty_struct *tty; 778 struct tty_struct *tty;
774 int status = urb->status; 779 int status = urb->status;
775 780
776 dbg("%s", __func__);
777
778 atomic_dec(&CmdUrbs); 781 atomic_dec(&CmdUrbs);
779 dbg("%s - FREE URB %p (outstanding %d)", __func__, 782 dev_dbg(&urb->dev->dev, "%s - FREE URB %p (outstanding %d)\n",
780 urb, atomic_read(&CmdUrbs)); 783 __func__, urb, atomic_read(&CmdUrbs));
781 784
782 785
783 /* clean up the transfer buffer */ 786 /* clean up the transfer buffer */
@@ -787,8 +790,9 @@ static void edge_bulk_out_cmd_callback(struct urb *urb)
787 usb_free_urb(urb); 790 usb_free_urb(urb);
788 791
789 if (status) { 792 if (status) {
790 dbg("%s - nonzero write bulk status received: %d", 793 dev_dbg(&urb->dev->dev,
791 __func__, status); 794 "%s - nonzero write bulk status received: %d\n",
795 __func__, status);
792 return; 796 return;
793 } 797 }
794 798
@@ -819,12 +823,11 @@ static void edge_bulk_out_cmd_callback(struct urb *urb)
819static int edge_open(struct tty_struct *tty, struct usb_serial_port *port) 823static int edge_open(struct tty_struct *tty, struct usb_serial_port *port)
820{ 824{
821 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 825 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
826 struct device *dev = &port->dev;
822 struct usb_serial *serial; 827 struct usb_serial *serial;
823 struct edgeport_serial *edge_serial; 828 struct edgeport_serial *edge_serial;
824 int response; 829 int response;
825 830
826 dbg("%s - port %d", __func__, port->number);
827
828 if (edge_port == NULL) 831 if (edge_port == NULL)
829 return -ENODEV; 832 return -ENODEV;
830 833
@@ -875,9 +878,8 @@ static int edge_open(struct tty_struct *tty, struct usb_serial_port *port)
875 response = usb_submit_urb(edge_serial->interrupt_read_urb, 878 response = usb_submit_urb(edge_serial->interrupt_read_urb,
876 GFP_KERNEL); 879 GFP_KERNEL);
877 if (response) { 880 if (response) {
878 dev_err(&port->dev, 881 dev_err(dev, "%s - Error %d submitting control urb\n",
879 "%s - Error %d submitting control urb\n", 882 __func__, response);
880 __func__, response);
881 } 883 }
882 } 884 }
883 885
@@ -902,8 +904,7 @@ static int edge_open(struct tty_struct *tty, struct usb_serial_port *port)
902 response = send_iosp_ext_cmd(edge_port, IOSP_CMD_OPEN_PORT, 0); 904 response = send_iosp_ext_cmd(edge_port, IOSP_CMD_OPEN_PORT, 0);
903 905
904 if (response < 0) { 906 if (response < 0) {
905 dev_err(&port->dev, "%s - error sending open port command\n", 907 dev_err(dev, "%s - error sending open port command\n", __func__);
906 __func__);
907 edge_port->openPending = false; 908 edge_port->openPending = false;
908 return -ENODEV; 909 return -ENODEV;
909 } 910 }
@@ -914,7 +915,7 @@ static int edge_open(struct tty_struct *tty, struct usb_serial_port *port)
914 915
915 if (!edge_port->open) { 916 if (!edge_port->open) {
916 /* open timed out */ 917 /* open timed out */
917 dbg("%s - open timedout", __func__); 918 dev_dbg(dev, "%s - open timedout\n", __func__);
918 edge_port->openPending = false; 919 edge_port->openPending = false;
919 return -ENODEV; 920 return -ENODEV;
920 } 921 }
@@ -927,7 +928,7 @@ static int edge_open(struct tty_struct *tty, struct usb_serial_port *port)
927 edge_port->txfifo.fifo = kmalloc(edge_port->maxTxCredits, GFP_KERNEL); 928 edge_port->txfifo.fifo = kmalloc(edge_port->maxTxCredits, GFP_KERNEL);
928 929
929 if (!edge_port->txfifo.fifo) { 930 if (!edge_port->txfifo.fifo) {
930 dbg("%s - no memory", __func__); 931 dev_dbg(dev, "%s - no memory\n", __func__);
931 edge_close(port); 932 edge_close(port);
932 return -ENOMEM; 933 return -ENOMEM;
933 } 934 }
@@ -937,15 +938,13 @@ static int edge_open(struct tty_struct *tty, struct usb_serial_port *port)
937 edge_port->write_in_progress = false; 938 edge_port->write_in_progress = false;
938 939
939 if (!edge_port->write_urb) { 940 if (!edge_port->write_urb) {
940 dbg("%s - no memory", __func__); 941 dev_dbg(dev, "%s - no memory\n", __func__);
941 edge_close(port); 942 edge_close(port);
942 return -ENOMEM; 943 return -ENOMEM;
943 } 944 }
944 945
945 dbg("%s(%d) - Initialize TX fifo to %d bytes", 946 dev_dbg(dev, "%s(%d) - Initialize TX fifo to %d bytes\n",
946 __func__, port->number, edge_port->maxTxCredits); 947 __func__, port->number, edge_port->maxTxCredits);
947
948 dbg("%s exited", __func__);
949 948
950 return 0; 949 return 0;
951} 950}
@@ -963,6 +962,7 @@ static int edge_open(struct tty_struct *tty, struct usb_serial_port *port)
963 ************************************************************************/ 962 ************************************************************************/
964static void block_until_chase_response(struct edgeport_port *edge_port) 963static void block_until_chase_response(struct edgeport_port *edge_port)
965{ 964{
965 struct device *dev = &edge_port->port->dev;
966 DEFINE_WAIT(wait); 966 DEFINE_WAIT(wait);
967 __u16 lastCredits; 967 __u16 lastCredits;
968 int timeout = 1*HZ; 968 int timeout = 1*HZ;
@@ -974,11 +974,11 @@ static void block_until_chase_response(struct edgeport_port *edge_port)
974 974
975 /* Did we get our Chase response */ 975 /* Did we get our Chase response */
976 if (!edge_port->chaseResponsePending) { 976 if (!edge_port->chaseResponsePending) {
977 dbg("%s - Got Chase Response", __func__); 977 dev_dbg(dev, "%s - Got Chase Response\n", __func__);
978 978
979 /* did we get all of our credit back? */ 979 /* did we get all of our credit back? */
980 if (edge_port->txCredits == edge_port->maxTxCredits) { 980 if (edge_port->txCredits == edge_port->maxTxCredits) {
981 dbg("%s - Got all credits", __func__); 981 dev_dbg(dev, "%s - Got all credits\n", __func__);
982 return; 982 return;
983 } 983 }
984 } 984 }
@@ -994,12 +994,12 @@ static void block_until_chase_response(struct edgeport_port *edge_port)
994 loop--; 994 loop--;
995 if (loop == 0) { 995 if (loop == 0) {
996 edge_port->chaseResponsePending = false; 996 edge_port->chaseResponsePending = false;
997 dbg("%s - Chase TIMEOUT", __func__); 997 dev_dbg(dev, "%s - Chase TIMEOUT\n", __func__);
998 return; 998 return;
999 } 999 }
1000 } else { 1000 } else {
1001 /* Reset timeout value back to 10 seconds */ 1001 /* Reset timeout value back to 10 seconds */
1002 dbg("%s - Last %d, Current %d", __func__, 1002 dev_dbg(dev, "%s - Last %d, Current %d\n", __func__,
1003 lastCredits, edge_port->txCredits); 1003 lastCredits, edge_port->txCredits);
1004 loop = 10; 1004 loop = 10;
1005 } 1005 }
@@ -1019,6 +1019,7 @@ static void block_until_chase_response(struct edgeport_port *edge_port)
1019 ************************************************************************/ 1019 ************************************************************************/
1020static void block_until_tx_empty(struct edgeport_port *edge_port) 1020static void block_until_tx_empty(struct edgeport_port *edge_port)
1021{ 1021{
1022 struct device *dev = &edge_port->port->dev;
1022 DEFINE_WAIT(wait); 1023 DEFINE_WAIT(wait);
1023 struct TxFifo *fifo = &edge_port->txfifo; 1024 struct TxFifo *fifo = &edge_port->txfifo;
1024 __u32 lastCount; 1025 __u32 lastCount;
@@ -1031,7 +1032,7 @@ static void block_until_tx_empty(struct edgeport_port *edge_port)
1031 1032
1032 /* Is the Edgeport Buffer empty? */ 1033 /* Is the Edgeport Buffer empty? */
1033 if (lastCount == 0) { 1034 if (lastCount == 0) {
1034 dbg("%s - TX Buffer Empty", __func__); 1035 dev_dbg(dev, "%s - TX Buffer Empty\n", __func__);
1035 return; 1036 return;
1036 } 1037 }
1037 1038
@@ -1041,13 +1042,13 @@ static void block_until_tx_empty(struct edgeport_port *edge_port)
1041 schedule_timeout(timeout); 1042 schedule_timeout(timeout);
1042 finish_wait(&edge_port->wait_chase, &wait); 1043 finish_wait(&edge_port->wait_chase, &wait);
1043 1044
1044 dbg("%s wait", __func__); 1045 dev_dbg(dev, "%s wait\n", __func__);
1045 1046
1046 if (lastCount == fifo->count) { 1047 if (lastCount == fifo->count) {
1047 /* No activity.. count down. */ 1048 /* No activity.. count down. */
1048 loop--; 1049 loop--;
1049 if (loop == 0) { 1050 if (loop == 0) {
1050 dbg("%s - TIMEOUT", __func__); 1051 dev_dbg(dev, "%s - TIMEOUT\n", __func__);
1051 return; 1052 return;
1052 } 1053 }
1053 } else { 1054 } else {
@@ -1068,8 +1069,6 @@ static void edge_close(struct usb_serial_port *port)
1068 struct edgeport_port *edge_port; 1069 struct edgeport_port *edge_port;
1069 int status; 1070 int status;
1070 1071
1071 dbg("%s - port %d", __func__, port->number);
1072
1073 edge_serial = usb_get_serial_data(port->serial); 1072 edge_serial = usb_get_serial_data(port->serial);
1074 edge_port = usb_get_serial_port_data(port); 1073 edge_port = usb_get_serial_port_data(port);
1075 if (edge_serial == NULL || edge_port == NULL) 1074 if (edge_serial == NULL || edge_port == NULL)
@@ -1086,7 +1085,7 @@ static void edge_close(struct usb_serial_port *port)
1086 /* flush and chase */ 1085 /* flush and chase */
1087 edge_port->chaseResponsePending = true; 1086 edge_port->chaseResponsePending = true;
1088 1087
1089 dbg("%s - Sending IOSP_CMD_CHASE_PORT", __func__); 1088 dev_dbg(&port->dev, "%s - Sending IOSP_CMD_CHASE_PORT\n", __func__);
1090 status = send_iosp_ext_cmd(edge_port, IOSP_CMD_CHASE_PORT, 0); 1089 status = send_iosp_ext_cmd(edge_port, IOSP_CMD_CHASE_PORT, 0);
1091 if (status == 0) 1090 if (status == 0)
1092 /* block until chase finished */ 1091 /* block until chase finished */
@@ -1099,7 +1098,7 @@ static void edge_close(struct usb_serial_port *port)
1099 ((edge_serial->is_epic) && 1098 ((edge_serial->is_epic) &&
1100 (edge_serial->epic_descriptor.Supports.IOSPClose))) { 1099 (edge_serial->epic_descriptor.Supports.IOSPClose))) {
1101 /* close the port */ 1100 /* close the port */
1102 dbg("%s - Sending IOSP_CMD_CLOSE_PORT", __func__); 1101 dev_dbg(&port->dev, "%s - Sending IOSP_CMD_CLOSE_PORT\n", __func__);
1103 send_iosp_ext_cmd(edge_port, IOSP_CMD_CLOSE_PORT, 0); 1102 send_iosp_ext_cmd(edge_port, IOSP_CMD_CLOSE_PORT, 0);
1104 } 1103 }
1105 1104
@@ -1119,8 +1118,6 @@ static void edge_close(struct usb_serial_port *port)
1119 } 1118 }
1120 kfree(edge_port->txfifo.fifo); 1119 kfree(edge_port->txfifo.fifo);
1121 edge_port->txfifo.fifo = NULL; 1120 edge_port->txfifo.fifo = NULL;
1122
1123 dbg("%s exited", __func__);
1124} 1121}
1125 1122
1126/***************************************************************************** 1123/*****************************************************************************
@@ -1141,8 +1138,6 @@ static int edge_write(struct tty_struct *tty, struct usb_serial_port *port,
1141 int secondhalf; 1138 int secondhalf;
1142 unsigned long flags; 1139 unsigned long flags;
1143 1140
1144 dbg("%s - port %d", __func__, port->number);
1145
1146 if (edge_port == NULL) 1141 if (edge_port == NULL)
1147 return -ENODEV; 1142 return -ENODEV;
1148 1143
@@ -1155,14 +1150,14 @@ static int edge_write(struct tty_struct *tty, struct usb_serial_port *port,
1155 copySize = min((unsigned int)count, 1150 copySize = min((unsigned int)count,
1156 (edge_port->txCredits - fifo->count)); 1151 (edge_port->txCredits - fifo->count));
1157 1152
1158 dbg("%s(%d) of %d byte(s) Fifo room %d -- will copy %d bytes", 1153 dev_dbg(&port->dev, "%s(%d) of %d byte(s) Fifo room %d -- will copy %d bytes\n",
1159 __func__, port->number, count, 1154 __func__, port->number, count,
1160 edge_port->txCredits - fifo->count, copySize); 1155 edge_port->txCredits - fifo->count, copySize);
1161 1156
1162 /* catch writes of 0 bytes which the tty driver likes to give us, 1157 /* catch writes of 0 bytes which the tty driver likes to give us,
1163 and when txCredits is empty */ 1158 and when txCredits is empty */
1164 if (copySize == 0) { 1159 if (copySize == 0) {
1165 dbg("%s - copySize = Zero", __func__); 1160 dev_dbg(&port->dev, "%s - copySize = Zero\n", __func__);
1166 goto finish_write; 1161 goto finish_write;
1167 } 1162 }
1168 1163
@@ -1175,13 +1170,12 @@ static int edge_write(struct tty_struct *tty, struct usb_serial_port *port,
1175 */ 1170 */
1176 bytesleft = fifo->size - fifo->head; 1171 bytesleft = fifo->size - fifo->head;
1177 firsthalf = min(bytesleft, copySize); 1172 firsthalf = min(bytesleft, copySize);
1178 dbg("%s - copy %d bytes of %d into fifo ", __func__, 1173 dev_dbg(&port->dev, "%s - copy %d bytes of %d into fifo \n", __func__,
1179 firsthalf, bytesleft); 1174 firsthalf, bytesleft);
1180 1175
1181 /* now copy our data */ 1176 /* now copy our data */
1182 memcpy(&fifo->fifo[fifo->head], data, firsthalf); 1177 memcpy(&fifo->fifo[fifo->head], data, firsthalf);
1183 usb_serial_debug_data(debug, &port->dev, __func__, 1178 usb_serial_debug_data(&port->dev, __func__, firsthalf, &fifo->fifo[fifo->head]);
1184 firsthalf, &fifo->fifo[fifo->head]);
1185 1179
1186 /* update the index and size */ 1180 /* update the index and size */
1187 fifo->head += firsthalf; 1181 fifo->head += firsthalf;
@@ -1194,10 +1188,9 @@ static int edge_write(struct tty_struct *tty, struct usb_serial_port *port,
1194 secondhalf = copySize-firsthalf; 1188 secondhalf = copySize-firsthalf;
1195 1189
1196 if (secondhalf) { 1190 if (secondhalf) {
1197 dbg("%s - copy rest of data %d", __func__, secondhalf); 1191 dev_dbg(&port->dev, "%s - copy rest of data %d\n", __func__, secondhalf);
1198 memcpy(&fifo->fifo[fifo->head], &data[firsthalf], secondhalf); 1192 memcpy(&fifo->fifo[fifo->head], &data[firsthalf], secondhalf);
1199 usb_serial_debug_data(debug, &port->dev, __func__, 1193 usb_serial_debug_data(&port->dev, __func__, secondhalf, &fifo->fifo[fifo->head]);
1200 secondhalf, &fifo->fifo[fifo->head]);
1201 /* update the index and size */ 1194 /* update the index and size */
1202 fifo->count += secondhalf; 1195 fifo->count += secondhalf;
1203 fifo->head += secondhalf; 1196 fifo->head += secondhalf;
@@ -1212,8 +1205,8 @@ finish_write:
1212 send_more_port_data((struct edgeport_serial *) 1205 send_more_port_data((struct edgeport_serial *)
1213 usb_get_serial_data(port->serial), edge_port); 1206 usb_get_serial_data(port->serial), edge_port);
1214 1207
1215 dbg("%s wrote %d byte(s) TxCredits %d, Fifo %d", __func__, 1208 dev_dbg(&port->dev, "%s wrote %d byte(s) TxCredits %d, Fifo %d\n",
1216 copySize, edge_port->txCredits, fifo->count); 1209 __func__, copySize, edge_port->txCredits, fifo->count);
1217 1210
1218 return copySize; 1211 return copySize;
1219} 1212}
@@ -1236,6 +1229,7 @@ static void send_more_port_data(struct edgeport_serial *edge_serial,
1236 struct edgeport_port *edge_port) 1229 struct edgeport_port *edge_port)
1237{ 1230{
1238 struct TxFifo *fifo = &edge_port->txfifo; 1231 struct TxFifo *fifo = &edge_port->txfifo;
1232 struct device *dev = &edge_port->port->dev;
1239 struct urb *urb; 1233 struct urb *urb;
1240 unsigned char *buffer; 1234 unsigned char *buffer;
1241 int status; 1235 int status;
@@ -1245,16 +1239,14 @@ static void send_more_port_data(struct edgeport_serial *edge_serial,
1245 int secondhalf; 1239 int secondhalf;
1246 unsigned long flags; 1240 unsigned long flags;
1247 1241
1248 dbg("%s(%d)", __func__, edge_port->port->number);
1249
1250 spin_lock_irqsave(&edge_port->ep_lock, flags); 1242 spin_lock_irqsave(&edge_port->ep_lock, flags);
1251 1243
1252 if (edge_port->write_in_progress || 1244 if (edge_port->write_in_progress ||
1253 !edge_port->open || 1245 !edge_port->open ||
1254 (fifo->count == 0)) { 1246 (fifo->count == 0)) {
1255 dbg("%s(%d) EXIT - fifo %d, PendingWrite = %d", 1247 dev_dbg(dev, "%s(%d) EXIT - fifo %d, PendingWrite = %d\n",
1256 __func__, edge_port->port->number, 1248 __func__, edge_port->port->number,
1257 fifo->count, edge_port->write_in_progress); 1249 fifo->count, edge_port->write_in_progress);
1258 goto exit_send; 1250 goto exit_send;
1259 } 1251 }
1260 1252
@@ -1266,7 +1258,7 @@ static void send_more_port_data(struct edgeport_serial *edge_serial,
1266 * it's better to wait for more credits so we can do a larger write. 1258 * it's better to wait for more credits so we can do a larger write.
1267 */ 1259 */
1268 if (edge_port->txCredits < EDGE_FW_GET_TX_CREDITS_SEND_THRESHOLD(edge_port->maxTxCredits, EDGE_FW_BULK_MAX_PACKET_SIZE)) { 1260 if (edge_port->txCredits < EDGE_FW_GET_TX_CREDITS_SEND_THRESHOLD(edge_port->maxTxCredits, EDGE_FW_BULK_MAX_PACKET_SIZE)) {
1269 dbg("%s(%d) Not enough credit - fifo %d TxCredit %d", 1261 dev_dbg(dev, "%s(%d) Not enough credit - fifo %d TxCredit %d\n",
1270 __func__, edge_port->port->number, fifo->count, 1262 __func__, edge_port->port->number, fifo->count,
1271 edge_port->txCredits); 1263 edge_port->txCredits);
1272 goto exit_send; 1264 goto exit_send;
@@ -1315,8 +1307,7 @@ static void send_more_port_data(struct edgeport_serial *edge_serial,
1315 } 1307 }
1316 1308
1317 if (count) 1309 if (count)
1318 usb_serial_debug_data(debug, &edge_port->port->dev, 1310 usb_serial_debug_data(&edge_port->port->dev, __func__, count, &buffer[2]);
1319 __func__, count, &buffer[2]);
1320 1311
1321 /* fill up the urb with all of our data and submit it */ 1312 /* fill up the urb with all of our data and submit it */
1322 usb_fill_bulk_urb(urb, edge_serial->serial->dev, 1313 usb_fill_bulk_urb(urb, edge_serial->serial->dev,
@@ -1341,8 +1332,8 @@ static void send_more_port_data(struct edgeport_serial *edge_serial,
1341 edge_port->txCredits += count; 1332 edge_port->txCredits += count;
1342 edge_port->icount.tx -= count; 1333 edge_port->icount.tx -= count;
1343 } 1334 }
1344 dbg("%s wrote %d byte(s) TxCredit %d, Fifo %d", 1335 dev_dbg(dev, "%s wrote %d byte(s) TxCredit %d, Fifo %d\n",
1345 __func__, count, edge_port->txCredits, fifo->count); 1336 __func__, count, edge_port->txCredits, fifo->count);
1346 1337
1347exit_send: 1338exit_send:
1348 spin_unlock_irqrestore(&edge_port->ep_lock, flags); 1339 spin_unlock_irqrestore(&edge_port->ep_lock, flags);
@@ -1363,17 +1354,13 @@ static int edge_write_room(struct tty_struct *tty)
1363 int room; 1354 int room;
1364 unsigned long flags; 1355 unsigned long flags;
1365 1356
1366 dbg("%s", __func__);
1367
1368 if (edge_port == NULL) 1357 if (edge_port == NULL)
1369 return 0; 1358 return 0;
1370 if (edge_port->closePending) 1359 if (edge_port->closePending)
1371 return 0; 1360 return 0;
1372 1361
1373 dbg("%s - port %d", __func__, port->number);
1374
1375 if (!edge_port->open) { 1362 if (!edge_port->open) {
1376 dbg("%s - port not opened", __func__); 1363 dev_dbg(&port->dev, "%s - port not opened\n", __func__);
1377 return 0; 1364 return 0;
1378 } 1365 }
1379 1366
@@ -1382,7 +1369,7 @@ static int edge_write_room(struct tty_struct *tty)
1382 room = edge_port->txCredits - edge_port->txfifo.count; 1369 room = edge_port->txCredits - edge_port->txfifo.count;
1383 spin_unlock_irqrestore(&edge_port->ep_lock, flags); 1370 spin_unlock_irqrestore(&edge_port->ep_lock, flags);
1384 1371
1385 dbg("%s - returns %d", __func__, room); 1372 dev_dbg(&port->dev, "%s - returns %d\n", __func__, room);
1386 return room; 1373 return room;
1387} 1374}
1388 1375
@@ -1403,15 +1390,13 @@ static int edge_chars_in_buffer(struct tty_struct *tty)
1403 int num_chars; 1390 int num_chars;
1404 unsigned long flags; 1391 unsigned long flags;
1405 1392
1406 dbg("%s", __func__);
1407
1408 if (edge_port == NULL) 1393 if (edge_port == NULL)
1409 return 0; 1394 return 0;
1410 if (edge_port->closePending) 1395 if (edge_port->closePending)
1411 return 0; 1396 return 0;
1412 1397
1413 if (!edge_port->open) { 1398 if (!edge_port->open) {
1414 dbg("%s - port not opened", __func__); 1399 dev_dbg(&port->dev, "%s - port not opened\n", __func__);
1415 return 0; 1400 return 0;
1416 } 1401 }
1417 1402
@@ -1420,8 +1405,8 @@ static int edge_chars_in_buffer(struct tty_struct *tty)
1420 edge_port->txfifo.count; 1405 edge_port->txfifo.count;
1421 spin_unlock_irqrestore(&edge_port->ep_lock, flags); 1406 spin_unlock_irqrestore(&edge_port->ep_lock, flags);
1422 if (num_chars) { 1407 if (num_chars) {
1423 dbg("%s(port %d) - returns %d", __func__, 1408 dev_dbg(&port->dev, "%s(port %d) - returns %d\n", __func__,
1424 port->number, num_chars); 1409 port->number, num_chars);
1425 } 1410 }
1426 1411
1427 return num_chars; 1412 return num_chars;
@@ -1439,13 +1424,11 @@ static void edge_throttle(struct tty_struct *tty)
1439 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 1424 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
1440 int status; 1425 int status;
1441 1426
1442 dbg("%s - port %d", __func__, port->number);
1443
1444 if (edge_port == NULL) 1427 if (edge_port == NULL)
1445 return; 1428 return;
1446 1429
1447 if (!edge_port->open) { 1430 if (!edge_port->open) {
1448 dbg("%s - port not opened", __func__); 1431 dev_dbg(&port->dev, "%s - port not opened\n", __func__);
1449 return; 1432 return;
1450 } 1433 }
1451 1434
@@ -1479,13 +1462,11 @@ static void edge_unthrottle(struct tty_struct *tty)
1479 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 1462 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
1480 int status; 1463 int status;
1481 1464
1482 dbg("%s - port %d", __func__, port->number);
1483
1484 if (edge_port == NULL) 1465 if (edge_port == NULL)
1485 return; 1466 return;
1486 1467
1487 if (!edge_port->open) { 1468 if (!edge_port->open) {
1488 dbg("%s - port not opened", __func__); 1469 dev_dbg(&port->dev, "%s - port not opened\n", __func__);
1489 return; 1470 return;
1490 } 1471 }
1491 1472
@@ -1517,18 +1498,14 @@ static void edge_set_termios(struct tty_struct *tty,
1517 unsigned int cflag; 1498 unsigned int cflag;
1518 1499
1519 cflag = tty->termios.c_cflag; 1500 cflag = tty->termios.c_cflag;
1520 dbg("%s - clfag %08x iflag %08x", __func__, 1501 dev_dbg(&port->dev, "%s - clfag %08x iflag %08x\n", __func__, tty->termios.c_cflag, tty->termios.c_iflag);
1521 tty->termios.c_cflag, tty->termios.c_iflag); 1502 dev_dbg(&port->dev, "%s - old clfag %08x old iflag %08x\n", __func__, old_termios->c_cflag, old_termios->c_iflag);
1522 dbg("%s - old clfag %08x old iflag %08x", __func__,
1523 old_termios->c_cflag, old_termios->c_iflag);
1524
1525 dbg("%s - port %d", __func__, port->number);
1526 1503
1527 if (edge_port == NULL) 1504 if (edge_port == NULL)
1528 return; 1505 return;
1529 1506
1530 if (!edge_port->open) { 1507 if (!edge_port->open) {
1531 dbg("%s - port not opened", __func__); 1508 dev_dbg(&port->dev, "%s - port not opened\n", __func__);
1532 return; 1509 return;
1533 } 1510 }
1534 1511
@@ -1556,7 +1533,7 @@ static int get_lsr_info(struct edgeport_port *edge_port,
1556 spin_lock_irqsave(&edge_port->ep_lock, flags); 1533 spin_lock_irqsave(&edge_port->ep_lock, flags);
1557 if (edge_port->maxTxCredits == edge_port->txCredits && 1534 if (edge_port->maxTxCredits == edge_port->txCredits &&
1558 edge_port->txfifo.count == 0) { 1535 edge_port->txfifo.count == 0) {
1559 dbg("%s -- Empty", __func__); 1536 dev_dbg(&edge_port->port->dev, "%s -- Empty\n", __func__);
1560 result = TIOCSER_TEMT; 1537 result = TIOCSER_TEMT;
1561 } 1538 }
1562 spin_unlock_irqrestore(&edge_port->ep_lock, flags); 1539 spin_unlock_irqrestore(&edge_port->ep_lock, flags);
@@ -1573,8 +1550,6 @@ static int edge_tiocmset(struct tty_struct *tty,
1573 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 1550 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
1574 unsigned int mcr; 1551 unsigned int mcr;
1575 1552
1576 dbg("%s - port %d", __func__, port->number);
1577
1578 mcr = edge_port->shadowMCR; 1553 mcr = edge_port->shadowMCR;
1579 if (set & TIOCM_RTS) 1554 if (set & TIOCM_RTS)
1580 mcr |= MCR_RTS; 1555 mcr |= MCR_RTS;
@@ -1605,8 +1580,6 @@ static int edge_tiocmget(struct tty_struct *tty)
1605 unsigned int msr; 1580 unsigned int msr;
1606 unsigned int mcr; 1581 unsigned int mcr;
1607 1582
1608 dbg("%s - port %d", __func__, port->number);
1609
1610 msr = edge_port->shadowMSR; 1583 msr = edge_port->shadowMSR;
1611 mcr = edge_port->shadowMCR; 1584 mcr = edge_port->shadowMCR;
1612 result = ((mcr & MCR_DTR) ? TIOCM_DTR: 0) /* 0x002 */ 1585 result = ((mcr & MCR_DTR) ? TIOCM_DTR: 0) /* 0x002 */
@@ -1616,9 +1589,6 @@ static int edge_tiocmget(struct tty_struct *tty)
1616 | ((msr & EDGEPORT_MSR_RI) ? TIOCM_RI: 0) /* 0x080 */ 1589 | ((msr & EDGEPORT_MSR_RI) ? TIOCM_RI: 0) /* 0x080 */
1617 | ((msr & EDGEPORT_MSR_DSR) ? TIOCM_DSR: 0); /* 0x100 */ 1590 | ((msr & EDGEPORT_MSR_DSR) ? TIOCM_DSR: 0); /* 0x100 */
1618 1591
1619
1620 dbg("%s -- %x", __func__, result);
1621
1622 return result; 1592 return result;
1623} 1593}
1624 1594
@@ -1642,8 +1612,8 @@ static int edge_get_icount(struct tty_struct *tty,
1642 icount->brk = cnow.brk; 1612 icount->brk = cnow.brk;
1643 icount->buf_overrun = cnow.buf_overrun; 1613 icount->buf_overrun = cnow.buf_overrun;
1644 1614
1645 dbg("%s (%d) TIOCGICOUNT RX=%d, TX=%d", 1615 dev_dbg(&port->dev, "%s (%d) TIOCGICOUNT RX=%d, TX=%d\n", __func__,
1646 __func__, port->number, icount->rx, icount->tx); 1616 port->number, icount->rx, icount->tx);
1647 return 0; 1617 return 0;
1648} 1618}
1649 1619
@@ -1686,19 +1656,19 @@ static int edge_ioctl(struct tty_struct *tty,
1686 struct async_icount cnow; 1656 struct async_icount cnow;
1687 struct async_icount cprev; 1657 struct async_icount cprev;
1688 1658
1689 dbg("%s - port %d, cmd = 0x%x", __func__, port->number, cmd); 1659 dev_dbg(&port->dev, "%s - port %d, cmd = 0x%x\n", __func__, port->number, cmd);
1690 1660
1691 switch (cmd) { 1661 switch (cmd) {
1692 case TIOCSERGETLSR: 1662 case TIOCSERGETLSR:
1693 dbg("%s (%d) TIOCSERGETLSR", __func__, port->number); 1663 dev_dbg(&port->dev, "%s (%d) TIOCSERGETLSR\n", __func__, port->number);
1694 return get_lsr_info(edge_port, (unsigned int __user *) arg); 1664 return get_lsr_info(edge_port, (unsigned int __user *) arg);
1695 1665
1696 case TIOCGSERIAL: 1666 case TIOCGSERIAL:
1697 dbg("%s (%d) TIOCGSERIAL", __func__, port->number); 1667 dev_dbg(&port->dev, "%s (%d) TIOCGSERIAL\n", __func__, port->number);
1698 return get_serial_info(edge_port, (struct serial_struct __user *) arg); 1668 return get_serial_info(edge_port, (struct serial_struct __user *) arg);
1699 1669
1700 case TIOCMIWAIT: 1670 case TIOCMIWAIT:
1701 dbg("%s (%d) TIOCMIWAIT", __func__, port->number); 1671 dev_dbg(&port->dev, "%s (%d) TIOCMIWAIT\n", __func__, port->number);
1702 cprev = edge_port->icount; 1672 cprev = edge_port->icount;
1703 while (1) { 1673 while (1) {
1704 prepare_to_wait(&edge_port->delta_msr_wait, 1674 prepare_to_wait(&edge_port->delta_msr_wait,
@@ -1745,7 +1715,7 @@ static void edge_break(struct tty_struct *tty, int break_state)
1745 /* flush and chase */ 1715 /* flush and chase */
1746 edge_port->chaseResponsePending = true; 1716 edge_port->chaseResponsePending = true;
1747 1717
1748 dbg("%s - Sending IOSP_CMD_CHASE_PORT", __func__); 1718 dev_dbg(&port->dev, "%s - Sending IOSP_CMD_CHASE_PORT\n", __func__);
1749 status = send_iosp_ext_cmd(edge_port, IOSP_CMD_CHASE_PORT, 0); 1719 status = send_iosp_ext_cmd(edge_port, IOSP_CMD_CHASE_PORT, 0);
1750 if (status == 0) { 1720 if (status == 0) {
1751 /* block until chase finished */ 1721 /* block until chase finished */
@@ -1759,16 +1729,16 @@ static void edge_break(struct tty_struct *tty, int break_state)
1759 ((edge_serial->is_epic) && 1729 ((edge_serial->is_epic) &&
1760 (edge_serial->epic_descriptor.Supports.IOSPSetClrBreak))) { 1730 (edge_serial->epic_descriptor.Supports.IOSPSetClrBreak))) {
1761 if (break_state == -1) { 1731 if (break_state == -1) {
1762 dbg("%s - Sending IOSP_CMD_SET_BREAK", __func__); 1732 dev_dbg(&port->dev, "%s - Sending IOSP_CMD_SET_BREAK\n", __func__);
1763 status = send_iosp_ext_cmd(edge_port, 1733 status = send_iosp_ext_cmd(edge_port,
1764 IOSP_CMD_SET_BREAK, 0); 1734 IOSP_CMD_SET_BREAK, 0);
1765 } else { 1735 } else {
1766 dbg("%s - Sending IOSP_CMD_CLEAR_BREAK", __func__); 1736 dev_dbg(&port->dev, "%s - Sending IOSP_CMD_CLEAR_BREAK\n", __func__);
1767 status = send_iosp_ext_cmd(edge_port, 1737 status = send_iosp_ext_cmd(edge_port,
1768 IOSP_CMD_CLEAR_BREAK, 0); 1738 IOSP_CMD_CLEAR_BREAK, 0);
1769 } 1739 }
1770 if (status) 1740 if (status)
1771 dbg("%s - error sending break set/clear command.", 1741 dev_dbg(&port->dev, "%s - error sending break set/clear command.\n",
1772 __func__); 1742 __func__);
1773 } 1743 }
1774} 1744}
@@ -1781,20 +1751,19 @@ static void edge_break(struct tty_struct *tty, int break_state)
1781static void process_rcvd_data(struct edgeport_serial *edge_serial, 1751static void process_rcvd_data(struct edgeport_serial *edge_serial,
1782 unsigned char *buffer, __u16 bufferLength) 1752 unsigned char *buffer, __u16 bufferLength)
1783{ 1753{
1754 struct device *dev = &edge_serial->serial->dev->dev;
1784 struct usb_serial_port *port; 1755 struct usb_serial_port *port;
1785 struct edgeport_port *edge_port; 1756 struct edgeport_port *edge_port;
1786 struct tty_struct *tty; 1757 struct tty_struct *tty;
1787 __u16 lastBufferLength; 1758 __u16 lastBufferLength;
1788 __u16 rxLen; 1759 __u16 rxLen;
1789 1760
1790 dbg("%s", __func__);
1791
1792 lastBufferLength = bufferLength + 1; 1761 lastBufferLength = bufferLength + 1;
1793 1762
1794 while (bufferLength > 0) { 1763 while (bufferLength > 0) {
1795 /* failsafe incase we get a message that we don't understand */ 1764 /* failsafe incase we get a message that we don't understand */
1796 if (lastBufferLength == bufferLength) { 1765 if (lastBufferLength == bufferLength) {
1797 dbg("%s - stuck in loop, exiting it.", __func__); 1766 dev_dbg(dev, "%s - stuck in loop, exiting it.\n", __func__);
1798 break; 1767 break;
1799 } 1768 }
1800 lastBufferLength = bufferLength; 1769 lastBufferLength = bufferLength;
@@ -1815,8 +1784,8 @@ static void process_rcvd_data(struct edgeport_serial *edge_serial,
1815 ++buffer; 1784 ++buffer;
1816 --bufferLength; 1785 --bufferLength;
1817 1786
1818 dbg("%s - Hdr1=%02X Hdr2=%02X", __func__, 1787 dev_dbg(dev, "%s - Hdr1=%02X Hdr2=%02X\n", __func__,
1819 edge_serial->rxHeader1, edge_serial->rxHeader2); 1788 edge_serial->rxHeader1, edge_serial->rxHeader2);
1820 /* Process depending on whether this header is 1789 /* Process depending on whether this header is
1821 * data or status */ 1790 * data or status */
1822 1791
@@ -1855,10 +1824,10 @@ static void process_rcvd_data(struct edgeport_serial *edge_serial,
1855 IOSP_GET_HDR_DATA_LEN( 1824 IOSP_GET_HDR_DATA_LEN(
1856 edge_serial->rxHeader1, 1825 edge_serial->rxHeader1,
1857 edge_serial->rxHeader2); 1826 edge_serial->rxHeader2);
1858 dbg("%s - Data for Port %u Len %u", 1827 dev_dbg(dev, "%s - Data for Port %u Len %u\n",
1859 __func__, 1828 __func__,
1860 edge_serial->rxPort, 1829 edge_serial->rxPort,
1861 edge_serial->rxBytesRemaining); 1830 edge_serial->rxBytesRemaining);
1862 1831
1863 /* ASSERT(DevExt->RxPort < DevExt->NumPorts); 1832 /* ASSERT(DevExt->RxPort < DevExt->NumPorts);
1864 * ASSERT(DevExt->RxBytesRemaining < 1833 * ASSERT(DevExt->RxBytesRemaining <
@@ -1896,7 +1865,7 @@ static void process_rcvd_data(struct edgeport_serial *edge_serial,
1896 tty = tty_port_tty_get( 1865 tty = tty_port_tty_get(
1897 &edge_port->port->port); 1866 &edge_port->port->port);
1898 if (tty) { 1867 if (tty) {
1899 dbg("%s - Sending %d bytes to TTY for port %d", 1868 dev_dbg(dev, "%s - Sending %d bytes to TTY for port %d\n",
1900 __func__, rxLen, edge_serial->rxPort); 1869 __func__, rxLen, edge_serial->rxPort);
1901 edge_tty_recv(&edge_serial->serial->dev->dev, tty, buffer, rxLen); 1870 edge_tty_recv(&edge_serial->serial->dev->dev, tty, buffer, rxLen);
1902 tty_kref_put(tty); 1871 tty_kref_put(tty);
@@ -1935,6 +1904,7 @@ static void process_rcvd_status(struct edgeport_serial *edge_serial,
1935 struct usb_serial_port *port; 1904 struct usb_serial_port *port;
1936 struct edgeport_port *edge_port; 1905 struct edgeport_port *edge_port;
1937 struct tty_struct *tty; 1906 struct tty_struct *tty;
1907 struct device *dev;
1938 __u8 code = edge_serial->rxStatusCode; 1908 __u8 code = edge_serial->rxStatusCode;
1939 1909
1940 /* switch the port pointer to the one being currently talked about */ 1910 /* switch the port pointer to the one being currently talked about */
@@ -1946,16 +1916,15 @@ static void process_rcvd_status(struct edgeport_serial *edge_serial,
1946 __func__, edge_serial->rxPort); 1916 __func__, edge_serial->rxPort);
1947 return; 1917 return;
1948 } 1918 }
1949 1919 dev = &port->dev;
1950 dbg("%s - port %d", __func__, edge_serial->rxPort);
1951 1920
1952 if (code == IOSP_EXT_STATUS) { 1921 if (code == IOSP_EXT_STATUS) {
1953 switch (byte2) { 1922 switch (byte2) {
1954 case IOSP_EXT_STATUS_CHASE_RSP: 1923 case IOSP_EXT_STATUS_CHASE_RSP:
1955 /* we want to do EXT status regardless of port 1924 /* we want to do EXT status regardless of port
1956 * open/closed */ 1925 * open/closed */
1957 dbg("%s - Port %u EXT CHASE_RSP Data = %02x", 1926 dev_dbg(dev, "%s - Port %u EXT CHASE_RSP Data = %02x\n",
1958 __func__, edge_serial->rxPort, byte3); 1927 __func__, edge_serial->rxPort, byte3);
1959 /* Currently, the only EXT_STATUS is Chase, so process 1928 /* Currently, the only EXT_STATUS is Chase, so process
1960 * here instead of one more call to one more subroutine 1929 * here instead of one more call to one more subroutine
1961 * If/when more EXT_STATUS, there'll be more work to do 1930 * If/when more EXT_STATUS, there'll be more work to do
@@ -1970,7 +1939,8 @@ static void process_rcvd_status(struct edgeport_serial *edge_serial,
1970 return; 1939 return;
1971 1940
1972 case IOSP_EXT_STATUS_RX_CHECK_RSP: 1941 case IOSP_EXT_STATUS_RX_CHECK_RSP:
1973 dbg("%s ========== Port %u CHECK_RSP Sequence = %02x =============", __func__, edge_serial->rxPort, byte3); 1942 dev_dbg(dev, "%s ========== Port %u CHECK_RSP Sequence = %02x =============\n",
1943 __func__, edge_serial->rxPort, byte3);
1974 /* Port->RxCheckRsp = true; */ 1944 /* Port->RxCheckRsp = true; */
1975 return; 1945 return;
1976 } 1946 }
@@ -1979,7 +1949,8 @@ static void process_rcvd_status(struct edgeport_serial *edge_serial,
1979 if (code == IOSP_STATUS_OPEN_RSP) { 1949 if (code == IOSP_STATUS_OPEN_RSP) {
1980 edge_port->txCredits = GET_TX_BUFFER_SIZE(byte3); 1950 edge_port->txCredits = GET_TX_BUFFER_SIZE(byte3);
1981 edge_port->maxTxCredits = edge_port->txCredits; 1951 edge_port->maxTxCredits = edge_port->txCredits;
1982 dbg("%s - Port %u Open Response Initial MSR = %02x TxBufferSize = %d", __func__, edge_serial->rxPort, byte2, edge_port->txCredits); 1952 dev_dbg(dev, "%s - Port %u Open Response Initial MSR = %02x TxBufferSize = %d\n",
1953 __func__, edge_serial->rxPort, byte2, edge_port->txCredits);
1983 handle_new_msr(edge_port, byte2); 1954 handle_new_msr(edge_port, byte2);
1984 1955
1985 /* send the current line settings to the port so we are 1956 /* send the current line settings to the port so we are
@@ -2008,27 +1979,27 @@ static void process_rcvd_status(struct edgeport_serial *edge_serial,
2008 switch (code) { 1979 switch (code) {
2009 /* Not currently sent by Edgeport */ 1980 /* Not currently sent by Edgeport */
2010 case IOSP_STATUS_LSR: 1981 case IOSP_STATUS_LSR:
2011 dbg("%s - Port %u LSR Status = %02x", 1982 dev_dbg(dev, "%s - Port %u LSR Status = %02x\n",
2012 __func__, edge_serial->rxPort, byte2); 1983 __func__, edge_serial->rxPort, byte2);
2013 handle_new_lsr(edge_port, false, byte2, 0); 1984 handle_new_lsr(edge_port, false, byte2, 0);
2014 break; 1985 break;
2015 1986
2016 case IOSP_STATUS_LSR_DATA: 1987 case IOSP_STATUS_LSR_DATA:
2017 dbg("%s - Port %u LSR Status = %02x, Data = %02x", 1988 dev_dbg(dev, "%s - Port %u LSR Status = %02x, Data = %02x\n",
2018 __func__, edge_serial->rxPort, byte2, byte3); 1989 __func__, edge_serial->rxPort, byte2, byte3);
2019 /* byte2 is LSR Register */ 1990 /* byte2 is LSR Register */
2020 /* byte3 is broken data byte */ 1991 /* byte3 is broken data byte */
2021 handle_new_lsr(edge_port, true, byte2, byte3); 1992 handle_new_lsr(edge_port, true, byte2, byte3);
2022 break; 1993 break;
2023 /* 1994 /*
2024 * case IOSP_EXT_4_STATUS: 1995 * case IOSP_EXT_4_STATUS:
2025 * dbg("%s - Port %u LSR Status = %02x Data = %02x", 1996 * dev_dbg(dev, "%s - Port %u LSR Status = %02x Data = %02x\n",
2026 * __func__, edge_serial->rxPort, byte2, byte3); 1997 * __func__, edge_serial->rxPort, byte2, byte3);
2027 * break; 1998 * break;
2028 */ 1999 */
2029 case IOSP_STATUS_MSR: 2000 case IOSP_STATUS_MSR:
2030 dbg("%s - Port %u MSR Status = %02x", 2001 dev_dbg(dev, "%s - Port %u MSR Status = %02x\n",
2031 __func__, edge_serial->rxPort, byte2); 2002 __func__, edge_serial->rxPort, byte2);
2032 /* 2003 /*
2033 * Process this new modem status and generate appropriate 2004 * Process this new modem status and generate appropriate
2034 * events, etc, based on the new status. This routine 2005 * events, etc, based on the new status. This routine
@@ -2038,7 +2009,7 @@ static void process_rcvd_status(struct edgeport_serial *edge_serial,
2038 break; 2009 break;
2039 2010
2040 default: 2011 default:
2041 dbg("%s - Unrecognized IOSP status code %u", __func__, code); 2012 dev_dbg(dev, "%s - Unrecognized IOSP status code %u\n", __func__, code);
2042 break; 2013 break;
2043 } 2014 }
2044} 2015}
@@ -2073,8 +2044,6 @@ static void handle_new_msr(struct edgeport_port *edge_port, __u8 newMsr)
2073{ 2044{
2074 struct async_icount *icount; 2045 struct async_icount *icount;
2075 2046
2076 dbg("%s %02x", __func__, newMsr);
2077
2078 if (newMsr & (EDGEPORT_MSR_DELTA_CTS | EDGEPORT_MSR_DELTA_DSR | 2047 if (newMsr & (EDGEPORT_MSR_DELTA_CTS | EDGEPORT_MSR_DELTA_DSR |
2079 EDGEPORT_MSR_DELTA_RI | EDGEPORT_MSR_DELTA_CD)) { 2048 EDGEPORT_MSR_DELTA_RI | EDGEPORT_MSR_DELTA_CD)) {
2080 icount = &edge_port->icount; 2049 icount = &edge_port->icount;
@@ -2107,8 +2076,6 @@ static void handle_new_lsr(struct edgeport_port *edge_port, __u8 lsrData,
2107 (LSR_OVER_ERR | LSR_PAR_ERR | LSR_FRM_ERR | LSR_BREAK)); 2076 (LSR_OVER_ERR | LSR_PAR_ERR | LSR_FRM_ERR | LSR_BREAK));
2108 struct async_icount *icount; 2077 struct async_icount *icount;
2109 2078
2110 dbg("%s - %02x", __func__, newLsr);
2111
2112 edge_port->shadowLSR = lsr; 2079 edge_port->shadowLSR = lsr;
2113 2080
2114 if (newLsr & LSR_BREAK) { 2081 if (newLsr & LSR_BREAK) {
@@ -2156,7 +2123,7 @@ static int sram_write(struct usb_serial *serial, __u16 extAddr, __u16 addr,
2156 __u16 current_length; 2123 __u16 current_length;
2157 unsigned char *transfer_buffer; 2124 unsigned char *transfer_buffer;
2158 2125
2159 dbg("%s - %x, %x, %d", __func__, extAddr, addr, length); 2126 dev_dbg(&serial->dev->dev, "%s - %x, %x, %d\n", __func__, extAddr, addr, length);
2160 2127
2161 transfer_buffer = kmalloc(64, GFP_KERNEL); 2128 transfer_buffer = kmalloc(64, GFP_KERNEL);
2162 if (!transfer_buffer) { 2129 if (!transfer_buffer) {
@@ -2173,8 +2140,7 @@ static int sram_write(struct usb_serial *serial, __u16 extAddr, __u16 addr,
2173 else 2140 else
2174 current_length = length; 2141 current_length = length;
2175 2142
2176/* dbg("%s - writing %x, %x, %d", __func__, 2143/* dev_dbg(&serial->dev->dev, "%s - writing %x, %x, %d\n", __func__, extAddr, addr, current_length); */
2177 extAddr, addr, current_length); */
2178 memcpy(transfer_buffer, data, current_length); 2144 memcpy(transfer_buffer, data, current_length);
2179 result = usb_control_msg(serial->dev, 2145 result = usb_control_msg(serial->dev,
2180 usb_sndctrlpipe(serial->dev, 0), 2146 usb_sndctrlpipe(serial->dev, 0),
@@ -2207,8 +2173,6 @@ static int rom_write(struct usb_serial *serial, __u16 extAddr, __u16 addr,
2207 __u16 current_length; 2173 __u16 current_length;
2208 unsigned char *transfer_buffer; 2174 unsigned char *transfer_buffer;
2209 2175
2210/* dbg("%s - %x, %x, %d", __func__, extAddr, addr, length); */
2211
2212 transfer_buffer = kmalloc(64, GFP_KERNEL); 2176 transfer_buffer = kmalloc(64, GFP_KERNEL);
2213 if (!transfer_buffer) { 2177 if (!transfer_buffer) {
2214 dev_err(&serial->dev->dev, "%s - kmalloc(%d) failed.\n", 2178 dev_err(&serial->dev->dev, "%s - kmalloc(%d) failed.\n",
@@ -2223,8 +2187,6 @@ static int rom_write(struct usb_serial *serial, __u16 extAddr, __u16 addr,
2223 current_length = 64; 2187 current_length = 64;
2224 else 2188 else
2225 current_length = length; 2189 current_length = length;
2226/* dbg("%s - writing %x, %x, %d", __func__,
2227 extAddr, addr, current_length); */
2228 memcpy(transfer_buffer, data, current_length); 2190 memcpy(transfer_buffer, data, current_length);
2229 result = usb_control_msg(serial->dev, 2191 result = usb_control_msg(serial->dev,
2230 usb_sndctrlpipe(serial->dev, 0), 2192 usb_sndctrlpipe(serial->dev, 0),
@@ -2257,8 +2219,6 @@ static int rom_read(struct usb_serial *serial, __u16 extAddr,
2257 __u16 current_length; 2219 __u16 current_length;
2258 unsigned char *transfer_buffer; 2220 unsigned char *transfer_buffer;
2259 2221
2260 dbg("%s - %x, %x, %d", __func__, extAddr, addr, length);
2261
2262 transfer_buffer = kmalloc(64, GFP_KERNEL); 2222 transfer_buffer = kmalloc(64, GFP_KERNEL);
2263 if (!transfer_buffer) { 2223 if (!transfer_buffer) {
2264 dev_err(&serial->dev->dev, 2224 dev_err(&serial->dev->dev,
@@ -2273,8 +2233,6 @@ static int rom_read(struct usb_serial *serial, __u16 extAddr,
2273 current_length = 64; 2233 current_length = 64;
2274 else 2234 else
2275 current_length = length; 2235 current_length = length;
2276/* dbg("%s - %x, %x, %d", __func__,
2277 extAddr, addr, current_length); */
2278 result = usb_control_msg(serial->dev, 2236 result = usb_control_msg(serial->dev,
2279 usb_rcvctrlpipe(serial->dev, 0), 2237 usb_rcvctrlpipe(serial->dev, 0),
2280 USB_REQUEST_ION_READ_ROM, 2238 USB_REQUEST_ION_READ_ROM,
@@ -2305,8 +2263,6 @@ static int send_iosp_ext_cmd(struct edgeport_port *edge_port,
2305 int length = 0; 2263 int length = 0;
2306 int status = 0; 2264 int status = 0;
2307 2265
2308 dbg("%s - %d, %d", __func__, command, param);
2309
2310 buffer = kmalloc(10, GFP_ATOMIC); 2266 buffer = kmalloc(10, GFP_ATOMIC);
2311 if (!buffer) { 2267 if (!buffer) {
2312 dev_err(&edge_port->port->dev, 2268 dev_err(&edge_port->port->dev,
@@ -2339,11 +2295,11 @@ static int write_cmd_usb(struct edgeport_port *edge_port,
2339{ 2295{
2340 struct edgeport_serial *edge_serial = 2296 struct edgeport_serial *edge_serial =
2341 usb_get_serial_data(edge_port->port->serial); 2297 usb_get_serial_data(edge_port->port->serial);
2298 struct device *dev = &edge_port->port->dev;
2342 int status = 0; 2299 int status = 0;
2343 struct urb *urb; 2300 struct urb *urb;
2344 2301
2345 usb_serial_debug_data(debug, &edge_port->port->dev, 2302 usb_serial_debug_data(dev, __func__, length, buffer);
2346 __func__, length, buffer);
2347 2303
2348 /* Allocate our next urb */ 2304 /* Allocate our next urb */
2349 urb = usb_alloc_urb(0, GFP_ATOMIC); 2305 urb = usb_alloc_urb(0, GFP_ATOMIC);
@@ -2351,8 +2307,8 @@ static int write_cmd_usb(struct edgeport_port *edge_port,
2351 return -ENOMEM; 2307 return -ENOMEM;
2352 2308
2353 atomic_inc(&CmdUrbs); 2309 atomic_inc(&CmdUrbs);
2354 dbg("%s - ALLOCATE URB %p (outstanding %d)", 2310 dev_dbg(dev, "%s - ALLOCATE URB %p (outstanding %d)\n",
2355 __func__, urb, atomic_read(&CmdUrbs)); 2311 __func__, urb, atomic_read(&CmdUrbs));
2356 2312
2357 usb_fill_bulk_urb(urb, edge_serial->serial->dev, 2313 usb_fill_bulk_urb(urb, edge_serial->serial->dev,
2358 usb_sndbulkpipe(edge_serial->serial->dev, 2314 usb_sndbulkpipe(edge_serial->serial->dev,
@@ -2364,9 +2320,8 @@ static int write_cmd_usb(struct edgeport_port *edge_port,
2364 2320
2365 if (status) { 2321 if (status) {
2366 /* something went wrong */ 2322 /* something went wrong */
2367 dev_err(&edge_port->port->dev, 2323 dev_err(dev, "%s - usb_submit_urb(write command) failed, status = %d\n",
2368 "%s - usb_submit_urb(write command) failed, status = %d\n", 2324 __func__, status);
2369 __func__, status);
2370 usb_kill_urb(urb); 2325 usb_kill_urb(urb);
2371 usb_free_urb(urb); 2326 usb_free_urb(urb);
2372 atomic_dec(&CmdUrbs); 2327 atomic_dec(&CmdUrbs);
@@ -2378,7 +2333,7 @@ static int write_cmd_usb(struct edgeport_port *edge_port,
2378 2333
2379 if (edge_port->commandPending) { 2334 if (edge_port->commandPending) {
2380 /* command timed out */ 2335 /* command timed out */
2381 dbg("%s - command timed out", __func__); 2336 dev_dbg(dev, "%s - command timed out\n", __func__);
2382 status = -EINVAL; 2337 status = -EINVAL;
2383 } 2338 }
2384#endif 2339#endif
@@ -2396,6 +2351,7 @@ static int send_cmd_write_baud_rate(struct edgeport_port *edge_port,
2396{ 2351{
2397 struct edgeport_serial *edge_serial = 2352 struct edgeport_serial *edge_serial =
2398 usb_get_serial_data(edge_port->port->serial); 2353 usb_get_serial_data(edge_port->port->serial);
2354 struct device *dev = &edge_port->port->dev;
2399 unsigned char *cmdBuffer; 2355 unsigned char *cmdBuffer;
2400 unsigned char *currCmd; 2356 unsigned char *currCmd;
2401 int cmdLen = 0; 2357 int cmdLen = 0;
@@ -2406,26 +2362,24 @@ static int send_cmd_write_baud_rate(struct edgeport_port *edge_port,
2406 2362
2407 if (edge_serial->is_epic && 2363 if (edge_serial->is_epic &&
2408 !edge_serial->epic_descriptor.Supports.IOSPSetBaudRate) { 2364 !edge_serial->epic_descriptor.Supports.IOSPSetBaudRate) {
2409 dbg("SendCmdWriteBaudRate - NOT Setting baud rate for port = %d, baud = %d", 2365 dev_dbg(dev, "SendCmdWriteBaudRate - NOT Setting baud rate for port = %d, baud = %d\n",
2410 edge_port->port->number, baudRate); 2366 edge_port->port->number, baudRate);
2411 return 0; 2367 return 0;
2412 } 2368 }
2413 2369
2414 dbg("%s - port = %d, baud = %d", __func__, 2370 dev_dbg(dev, "%s - port = %d, baud = %d\n", __func__,
2415 edge_port->port->number, baudRate); 2371 edge_port->port->number, baudRate);
2416 2372
2417 status = calc_baud_rate_divisor(baudRate, &divisor); 2373 status = calc_baud_rate_divisor(dev, baudRate, &divisor);
2418 if (status) { 2374 if (status) {
2419 dev_err(&edge_port->port->dev, "%s - bad baud rate\n", 2375 dev_err(dev, "%s - bad baud rate\n", __func__);
2420 __func__);
2421 return status; 2376 return status;
2422 } 2377 }
2423 2378
2424 /* Alloc memory for the string of commands. */ 2379 /* Alloc memory for the string of commands. */
2425 cmdBuffer = kmalloc(0x100, GFP_ATOMIC); 2380 cmdBuffer = kmalloc(0x100, GFP_ATOMIC);
2426 if (!cmdBuffer) { 2381 if (!cmdBuffer) {
2427 dev_err(&edge_port->port->dev, 2382 dev_err(dev, "%s - kmalloc(%d) failed.\n", __func__, 0x100);
2428 "%s - kmalloc(%d) failed.\n", __func__, 0x100);
2429 return -ENOMEM; 2383 return -ENOMEM;
2430 } 2384 }
2431 currCmd = cmdBuffer; 2385 currCmd = cmdBuffer;
@@ -2456,14 +2410,11 @@ static int send_cmd_write_baud_rate(struct edgeport_port *edge_port,
2456 * this function calculates the proper baud rate divisor for the specified 2410 * this function calculates the proper baud rate divisor for the specified
2457 * baud rate. 2411 * baud rate.
2458 *****************************************************************************/ 2412 *****************************************************************************/
2459static int calc_baud_rate_divisor(int baudrate, int *divisor) 2413static int calc_baud_rate_divisor(struct device *dev, int baudrate, int *divisor)
2460{ 2414{
2461 int i; 2415 int i;
2462 __u16 custom; 2416 __u16 custom;
2463 2417
2464
2465 dbg("%s - %d", __func__, baudrate);
2466
2467 for (i = 0; i < ARRAY_SIZE(divisor_table); i++) { 2418 for (i = 0; i < ARRAY_SIZE(divisor_table); i++) {
2468 if (divisor_table[i].BaudRate == baudrate) { 2419 if (divisor_table[i].BaudRate == baudrate) {
2469 *divisor = divisor_table[i].Divisor; 2420 *divisor = divisor_table[i].Divisor;
@@ -2480,7 +2431,7 @@ static int calc_baud_rate_divisor(int baudrate, int *divisor)
2480 2431
2481 *divisor = custom; 2432 *divisor = custom;
2482 2433
2483 dbg("%s - Baud %d = %d", __func__, baudrate, custom); 2434 dev_dbg(dev, "%s - Baud %d = %d\n", __func__, baudrate, custom);
2484 return 0; 2435 return 0;
2485 } 2436 }
2486 2437
@@ -2497,25 +2448,26 @@ static int send_cmd_write_uart_register(struct edgeport_port *edge_port,
2497{ 2448{
2498 struct edgeport_serial *edge_serial = 2449 struct edgeport_serial *edge_serial =
2499 usb_get_serial_data(edge_port->port->serial); 2450 usb_get_serial_data(edge_port->port->serial);
2451 struct device *dev = &edge_port->port->dev;
2500 unsigned char *cmdBuffer; 2452 unsigned char *cmdBuffer;
2501 unsigned char *currCmd; 2453 unsigned char *currCmd;
2502 unsigned long cmdLen = 0; 2454 unsigned long cmdLen = 0;
2503 int status; 2455 int status;
2504 2456
2505 dbg("%s - write to %s register 0x%02x", 2457 dev_dbg(dev, "%s - write to %s register 0x%02x\n",
2506 (regNum == MCR) ? "MCR" : "LCR", __func__, regValue); 2458 (regNum == MCR) ? "MCR" : "LCR", __func__, regValue);
2507 2459
2508 if (edge_serial->is_epic && 2460 if (edge_serial->is_epic &&
2509 !edge_serial->epic_descriptor.Supports.IOSPWriteMCR && 2461 !edge_serial->epic_descriptor.Supports.IOSPWriteMCR &&
2510 regNum == MCR) { 2462 regNum == MCR) {
2511 dbg("SendCmdWriteUartReg - Not writing to MCR Register"); 2463 dev_dbg(dev, "SendCmdWriteUartReg - Not writing to MCR Register\n");
2512 return 0; 2464 return 0;
2513 } 2465 }
2514 2466
2515 if (edge_serial->is_epic && 2467 if (edge_serial->is_epic &&
2516 !edge_serial->epic_descriptor.Supports.IOSPWriteLCR && 2468 !edge_serial->epic_descriptor.Supports.IOSPWriteLCR &&
2517 regNum == LCR) { 2469 regNum == LCR) {
2518 dbg("SendCmdWriteUartReg - Not writing to LCR Register"); 2470 dev_dbg(dev, "SendCmdWriteUartReg - Not writing to LCR Register\n");
2519 return 0; 2471 return 0;
2520 } 2472 }
2521 2473
@@ -2550,6 +2502,7 @@ static int send_cmd_write_uart_register(struct edgeport_port *edge_port,
2550static void change_port_settings(struct tty_struct *tty, 2502static void change_port_settings(struct tty_struct *tty,
2551 struct edgeport_port *edge_port, struct ktermios *old_termios) 2503 struct edgeport_port *edge_port, struct ktermios *old_termios)
2552{ 2504{
2505 struct device *dev = &edge_port->port->dev;
2553 struct edgeport_serial *edge_serial = 2506 struct edgeport_serial *edge_serial =
2554 usb_get_serial_data(edge_port->port->serial); 2507 usb_get_serial_data(edge_port->port->serial);
2555 int baud; 2508 int baud;
@@ -2562,11 +2515,11 @@ static void change_port_settings(struct tty_struct *tty,
2562 __u8 txFlow; 2515 __u8 txFlow;
2563 int status; 2516 int status;
2564 2517
2565 dbg("%s - port %d", __func__, edge_port->port->number); 2518 dev_dbg(dev, "%s - port %d\n", __func__, edge_port->port->number);
2566 2519
2567 if (!edge_port->open && 2520 if (!edge_port->open &&
2568 !edge_port->openPending) { 2521 !edge_port->openPending) {
2569 dbg("%s - port not opened", __func__); 2522 dev_dbg(dev, "%s - port not opened\n", __func__);
2570 return; 2523 return;
2571 } 2524 }
2572 2525
@@ -2575,20 +2528,20 @@ static void change_port_settings(struct tty_struct *tty,
2575 switch (cflag & CSIZE) { 2528 switch (cflag & CSIZE) {
2576 case CS5: 2529 case CS5:
2577 lData = LCR_BITS_5; mask = 0x1f; 2530 lData = LCR_BITS_5; mask = 0x1f;
2578 dbg("%s - data bits = 5", __func__); 2531 dev_dbg(dev, "%s - data bits = 5\n", __func__);
2579 break; 2532 break;
2580 case CS6: 2533 case CS6:
2581 lData = LCR_BITS_6; mask = 0x3f; 2534 lData = LCR_BITS_6; mask = 0x3f;
2582 dbg("%s - data bits = 6", __func__); 2535 dev_dbg(dev, "%s - data bits = 6\n", __func__);
2583 break; 2536 break;
2584 case CS7: 2537 case CS7:
2585 lData = LCR_BITS_7; mask = 0x7f; 2538 lData = LCR_BITS_7; mask = 0x7f;
2586 dbg("%s - data bits = 7", __func__); 2539 dev_dbg(dev, "%s - data bits = 7\n", __func__);
2587 break; 2540 break;
2588 default: 2541 default:
2589 case CS8: 2542 case CS8:
2590 lData = LCR_BITS_8; 2543 lData = LCR_BITS_8;
2591 dbg("%s - data bits = 8", __func__); 2544 dev_dbg(dev, "%s - data bits = 8\n", __func__);
2592 break; 2545 break;
2593 } 2546 }
2594 2547
@@ -2597,28 +2550,28 @@ static void change_port_settings(struct tty_struct *tty,
2597 if (cflag & CMSPAR) { 2550 if (cflag & CMSPAR) {
2598 if (cflag & PARODD) { 2551 if (cflag & PARODD) {
2599 lParity = LCR_PAR_MARK; 2552 lParity = LCR_PAR_MARK;
2600 dbg("%s - parity = mark", __func__); 2553 dev_dbg(dev, "%s - parity = mark\n", __func__);
2601 } else { 2554 } else {
2602 lParity = LCR_PAR_SPACE; 2555 lParity = LCR_PAR_SPACE;
2603 dbg("%s - parity = space", __func__); 2556 dev_dbg(dev, "%s - parity = space\n", __func__);
2604 } 2557 }
2605 } else if (cflag & PARODD) { 2558 } else if (cflag & PARODD) {
2606 lParity = LCR_PAR_ODD; 2559 lParity = LCR_PAR_ODD;
2607 dbg("%s - parity = odd", __func__); 2560 dev_dbg(dev, "%s - parity = odd\n", __func__);
2608 } else { 2561 } else {
2609 lParity = LCR_PAR_EVEN; 2562 lParity = LCR_PAR_EVEN;
2610 dbg("%s - parity = even", __func__); 2563 dev_dbg(dev, "%s - parity = even\n", __func__);
2611 } 2564 }
2612 } else { 2565 } else {
2613 dbg("%s - parity = none", __func__); 2566 dev_dbg(dev, "%s - parity = none\n", __func__);
2614 } 2567 }
2615 2568
2616 if (cflag & CSTOPB) { 2569 if (cflag & CSTOPB) {
2617 lStop = LCR_STOP_2; 2570 lStop = LCR_STOP_2;
2618 dbg("%s - stop bits = 2", __func__); 2571 dev_dbg(dev, "%s - stop bits = 2\n", __func__);
2619 } else { 2572 } else {
2620 lStop = LCR_STOP_1; 2573 lStop = LCR_STOP_1;
2621 dbg("%s - stop bits = 1", __func__); 2574 dev_dbg(dev, "%s - stop bits = 1\n", __func__);
2622 } 2575 }
2623 2576
2624 /* figure out the flow control settings */ 2577 /* figure out the flow control settings */
@@ -2626,9 +2579,9 @@ static void change_port_settings(struct tty_struct *tty,
2626 if (cflag & CRTSCTS) { 2579 if (cflag & CRTSCTS) {
2627 rxFlow |= IOSP_RX_FLOW_RTS; 2580 rxFlow |= IOSP_RX_FLOW_RTS;
2628 txFlow |= IOSP_TX_FLOW_CTS; 2581 txFlow |= IOSP_TX_FLOW_CTS;
2629 dbg("%s - RTS/CTS is enabled", __func__); 2582 dev_dbg(dev, "%s - RTS/CTS is enabled\n", __func__);
2630 } else { 2583 } else {
2631 dbg("%s - RTS/CTS is disabled", __func__); 2584 dev_dbg(dev, "%s - RTS/CTS is disabled\n", __func__);
2632 } 2585 }
2633 2586
2634 /* if we are implementing XON/XOFF, set the start and stop character 2587 /* if we are implementing XON/XOFF, set the start and stop character
@@ -2649,19 +2602,19 @@ static void change_port_settings(struct tty_struct *tty,
2649 /* if we are implementing INBOUND XON/XOFF */ 2602 /* if we are implementing INBOUND XON/XOFF */
2650 if (I_IXOFF(tty)) { 2603 if (I_IXOFF(tty)) {
2651 rxFlow |= IOSP_RX_FLOW_XON_XOFF; 2604 rxFlow |= IOSP_RX_FLOW_XON_XOFF;
2652 dbg("%s - INBOUND XON/XOFF is enabled, XON = %2x, XOFF = %2x", 2605 dev_dbg(dev, "%s - INBOUND XON/XOFF is enabled, XON = %2x, XOFF = %2x\n",
2653 __func__, start_char, stop_char); 2606 __func__, start_char, stop_char);
2654 } else { 2607 } else {
2655 dbg("%s - INBOUND XON/XOFF is disabled", __func__); 2608 dev_dbg(dev, "%s - INBOUND XON/XOFF is disabled\n", __func__);
2656 } 2609 }
2657 2610
2658 /* if we are implementing OUTBOUND XON/XOFF */ 2611 /* if we are implementing OUTBOUND XON/XOFF */
2659 if (I_IXON(tty)) { 2612 if (I_IXON(tty)) {
2660 txFlow |= IOSP_TX_FLOW_XON_XOFF; 2613 txFlow |= IOSP_TX_FLOW_XON_XOFF;
2661 dbg("%s - OUTBOUND XON/XOFF is enabled, XON = %2x, XOFF = %2x", 2614 dev_dbg(dev, "%s - OUTBOUND XON/XOFF is enabled, XON = %2x, XOFF = %2x\n",
2662 __func__, start_char, stop_char); 2615 __func__, start_char, stop_char);
2663 } else { 2616 } else {
2664 dbg("%s - OUTBOUND XON/XOFF is disabled", __func__); 2617 dev_dbg(dev, "%s - OUTBOUND XON/XOFF is disabled\n", __func__);
2665 } 2618 }
2666 } 2619 }
2667 2620
@@ -2704,7 +2657,7 @@ static void change_port_settings(struct tty_struct *tty,
2704 baud = 9600; 2657 baud = 9600;
2705 } 2658 }
2706 2659
2707 dbg("%s - baud rate = %d", __func__, baud); 2660 dev_dbg(dev, "%s - baud rate = %d\n", __func__, baud);
2708 status = send_cmd_write_baud_rate(edge_port, baud); 2661 status = send_cmd_write_baud_rate(edge_port, baud);
2709 if (status == -1) { 2662 if (status == -1) {
2710 /* Speed change was not possible - put back the old speed */ 2663 /* Speed change was not possible - put back the old speed */
@@ -2746,9 +2699,10 @@ static void unicode_to_ascii(char *string, int buflen,
2746 ****************************************************************************/ 2699 ****************************************************************************/
2747static void get_manufacturing_desc(struct edgeport_serial *edge_serial) 2700static void get_manufacturing_desc(struct edgeport_serial *edge_serial)
2748{ 2701{
2702 struct device *dev = &edge_serial->serial->dev->dev;
2749 int response; 2703 int response;
2750 2704
2751 dbg("getting manufacturer descriptor"); 2705 dev_dbg(dev, "getting manufacturer descriptor\n");
2752 2706
2753 response = rom_read(edge_serial->serial, 2707 response = rom_read(edge_serial->serial,
2754 (EDGE_MANUF_DESC_ADDR & 0xffff0000) >> 16, 2708 (EDGE_MANUF_DESC_ADDR & 0xffff0000) >> 16,
@@ -2757,42 +2711,41 @@ static void get_manufacturing_desc(struct edgeport_serial *edge_serial)
2757 (__u8 *)(&edge_serial->manuf_descriptor)); 2711 (__u8 *)(&edge_serial->manuf_descriptor));
2758 2712
2759 if (response < 1) 2713 if (response < 1)
2760 dev_err(&edge_serial->serial->dev->dev, 2714 dev_err(dev, "error in getting manufacturer descriptor\n");
2761 "error in getting manufacturer descriptor\n");
2762 else { 2715 else {
2763 char string[30]; 2716 char string[30];
2764 dbg("**Manufacturer Descriptor"); 2717 dev_dbg(dev, "**Manufacturer Descriptor\n");
2765 dbg(" RomSize: %dK", 2718 dev_dbg(dev, " RomSize: %dK\n",
2766 edge_serial->manuf_descriptor.RomSize); 2719 edge_serial->manuf_descriptor.RomSize);
2767 dbg(" RamSize: %dK", 2720 dev_dbg(dev, " RamSize: %dK\n",
2768 edge_serial->manuf_descriptor.RamSize); 2721 edge_serial->manuf_descriptor.RamSize);
2769 dbg(" CpuRev: %d", 2722 dev_dbg(dev, " CpuRev: %d\n",
2770 edge_serial->manuf_descriptor.CpuRev); 2723 edge_serial->manuf_descriptor.CpuRev);
2771 dbg(" BoardRev: %d", 2724 dev_dbg(dev, " BoardRev: %d\n",
2772 edge_serial->manuf_descriptor.BoardRev); 2725 edge_serial->manuf_descriptor.BoardRev);
2773 dbg(" NumPorts: %d", 2726 dev_dbg(dev, " NumPorts: %d\n",
2774 edge_serial->manuf_descriptor.NumPorts); 2727 edge_serial->manuf_descriptor.NumPorts);
2775 dbg(" DescDate: %d/%d/%d", 2728 dev_dbg(dev, " DescDate: %d/%d/%d\n",
2776 edge_serial->manuf_descriptor.DescDate[0], 2729 edge_serial->manuf_descriptor.DescDate[0],
2777 edge_serial->manuf_descriptor.DescDate[1], 2730 edge_serial->manuf_descriptor.DescDate[1],
2778 edge_serial->manuf_descriptor.DescDate[2]+1900); 2731 edge_serial->manuf_descriptor.DescDate[2]+1900);
2779 unicode_to_ascii(string, sizeof(string), 2732 unicode_to_ascii(string, sizeof(string),
2780 edge_serial->manuf_descriptor.SerialNumber, 2733 edge_serial->manuf_descriptor.SerialNumber,
2781 edge_serial->manuf_descriptor.SerNumLength/2); 2734 edge_serial->manuf_descriptor.SerNumLength/2);
2782 dbg(" SerialNumber: %s", string); 2735 dev_dbg(dev, " SerialNumber: %s\n", string);
2783 unicode_to_ascii(string, sizeof(string), 2736 unicode_to_ascii(string, sizeof(string),
2784 edge_serial->manuf_descriptor.AssemblyNumber, 2737 edge_serial->manuf_descriptor.AssemblyNumber,
2785 edge_serial->manuf_descriptor.AssemblyNumLength/2); 2738 edge_serial->manuf_descriptor.AssemblyNumLength/2);
2786 dbg(" AssemblyNumber: %s", string); 2739 dev_dbg(dev, " AssemblyNumber: %s\n", string);
2787 unicode_to_ascii(string, sizeof(string), 2740 unicode_to_ascii(string, sizeof(string),
2788 edge_serial->manuf_descriptor.OemAssyNumber, 2741 edge_serial->manuf_descriptor.OemAssyNumber,
2789 edge_serial->manuf_descriptor.OemAssyNumLength/2); 2742 edge_serial->manuf_descriptor.OemAssyNumLength/2);
2790 dbg(" OemAssyNumber: %s", string); 2743 dev_dbg(dev, " OemAssyNumber: %s\n", string);
2791 dbg(" UartType: %d", 2744 dev_dbg(dev, " UartType: %d\n",
2792 edge_serial->manuf_descriptor.UartType); 2745 edge_serial->manuf_descriptor.UartType);
2793 dbg(" IonPid: %d", 2746 dev_dbg(dev, " IonPid: %d\n",
2794 edge_serial->manuf_descriptor.IonPid); 2747 edge_serial->manuf_descriptor.IonPid);
2795 dbg(" IonConfig: %d", 2748 dev_dbg(dev, " IonConfig: %d\n",
2796 edge_serial->manuf_descriptor.IonConfig); 2749 edge_serial->manuf_descriptor.IonConfig);
2797 } 2750 }
2798} 2751}
@@ -2805,9 +2758,10 @@ static void get_manufacturing_desc(struct edgeport_serial *edge_serial)
2805 ****************************************************************************/ 2758 ****************************************************************************/
2806static void get_boot_desc(struct edgeport_serial *edge_serial) 2759static void get_boot_desc(struct edgeport_serial *edge_serial)
2807{ 2760{
2761 struct device *dev = &edge_serial->serial->dev->dev;
2808 int response; 2762 int response;
2809 2763
2810 dbg("getting boot descriptor"); 2764 dev_dbg(dev, "getting boot descriptor\n");
2811 2765
2812 response = rom_read(edge_serial->serial, 2766 response = rom_read(edge_serial->serial,
2813 (EDGE_BOOT_DESC_ADDR & 0xffff0000) >> 16, 2767 (EDGE_BOOT_DESC_ADDR & 0xffff0000) >> 16,
@@ -2816,23 +2770,22 @@ static void get_boot_desc(struct edgeport_serial *edge_serial)
2816 (__u8 *)(&edge_serial->boot_descriptor)); 2770 (__u8 *)(&edge_serial->boot_descriptor));
2817 2771
2818 if (response < 1) 2772 if (response < 1)
2819 dev_err(&edge_serial->serial->dev->dev, 2773 dev_err(dev, "error in getting boot descriptor\n");
2820 "error in getting boot descriptor\n");
2821 else { 2774 else {
2822 dbg("**Boot Descriptor:"); 2775 dev_dbg(dev, "**Boot Descriptor:\n");
2823 dbg(" BootCodeLength: %d", 2776 dev_dbg(dev, " BootCodeLength: %d\n",
2824 le16_to_cpu(edge_serial->boot_descriptor.BootCodeLength)); 2777 le16_to_cpu(edge_serial->boot_descriptor.BootCodeLength));
2825 dbg(" MajorVersion: %d", 2778 dev_dbg(dev, " MajorVersion: %d\n",
2826 edge_serial->boot_descriptor.MajorVersion); 2779 edge_serial->boot_descriptor.MajorVersion);
2827 dbg(" MinorVersion: %d", 2780 dev_dbg(dev, " MinorVersion: %d\n",
2828 edge_serial->boot_descriptor.MinorVersion); 2781 edge_serial->boot_descriptor.MinorVersion);
2829 dbg(" BuildNumber: %d", 2782 dev_dbg(dev, " BuildNumber: %d\n",
2830 le16_to_cpu(edge_serial->boot_descriptor.BuildNumber)); 2783 le16_to_cpu(edge_serial->boot_descriptor.BuildNumber));
2831 dbg(" Capabilities: 0x%x", 2784 dev_dbg(dev, " Capabilities: 0x%x\n",
2832 le16_to_cpu(edge_serial->boot_descriptor.Capabilities)); 2785 le16_to_cpu(edge_serial->boot_descriptor.Capabilities));
2833 dbg(" UConfig0: %d", 2786 dev_dbg(dev, " UConfig0: %d\n",
2834 edge_serial->boot_descriptor.UConfig0); 2787 edge_serial->boot_descriptor.UConfig0);
2835 dbg(" UConfig1: %d", 2788 dev_dbg(dev, " UConfig1: %d\n",
2836 edge_serial->boot_descriptor.UConfig1); 2789 edge_serial->boot_descriptor.UConfig1);
2837 } 2790 }
2838} 2791}
@@ -2844,6 +2797,7 @@ static void get_boot_desc(struct edgeport_serial *edge_serial)
2844 ****************************************************************************/ 2797 ****************************************************************************/
2845static void load_application_firmware(struct edgeport_serial *edge_serial) 2798static void load_application_firmware(struct edgeport_serial *edge_serial)
2846{ 2799{
2800 struct device *dev = &edge_serial->serial->dev->dev;
2847 const struct ihex_binrec *rec; 2801 const struct ihex_binrec *rec;
2848 const struct firmware *fw; 2802 const struct firmware *fw;
2849 const char *fw_name; 2803 const char *fw_name;
@@ -2864,7 +2818,7 @@ static void load_application_firmware(struct edgeport_serial *edge_serial)
2864 break; 2818 break;
2865 2819
2866 case EDGE_DOWNLOAD_FILE_NONE: 2820 case EDGE_DOWNLOAD_FILE_NONE:
2867 dbg("No download file specified, skipping download"); 2821 dev_dbg(dev, "No download file specified, skipping download\n");
2868 return; 2822 return;
2869 2823
2870 default: 2824 default:
@@ -2874,7 +2828,7 @@ static void load_application_firmware(struct edgeport_serial *edge_serial)
2874 response = request_ihex_firmware(&fw, fw_name, 2828 response = request_ihex_firmware(&fw, fw_name,
2875 &edge_serial->serial->dev->dev); 2829 &edge_serial->serial->dev->dev);
2876 if (response) { 2830 if (response) {
2877 printk(KERN_ERR "Failed to load image \"%s\" err %d\n", 2831 dev_err(dev, "Failed to load image \"%s\" err %d\n",
2878 fw_name, response); 2832 fw_name, response);
2879 return; 2833 return;
2880 } 2834 }
@@ -2882,7 +2836,7 @@ static void load_application_firmware(struct edgeport_serial *edge_serial)
2882 rec = (const struct ihex_binrec *)fw->data; 2836 rec = (const struct ihex_binrec *)fw->data;
2883 build = (rec->data[2] << 8) | rec->data[3]; 2837 build = (rec->data[2] << 8) | rec->data[3];
2884 2838
2885 dbg("%s %d.%d.%d", fw_info, rec->data[0], rec->data[1], build); 2839 dev_dbg(dev, "%s %d.%d.%d\n", fw_info, rec->data[0], rec->data[1], build);
2886 2840
2887 edge_serial->product_info.FirmwareMajorVersion = rec->data[0]; 2841 edge_serial->product_info.FirmwareMajorVersion = rec->data[0];
2888 edge_serial->product_info.FirmwareMinorVersion = rec->data[1]; 2842 edge_serial->product_info.FirmwareMinorVersion = rec->data[1];
@@ -2905,10 +2859,10 @@ static void load_application_firmware(struct edgeport_serial *edge_serial)
2905 } 2859 }
2906 } 2860 }
2907 2861
2908 dbg("sending exec_dl_code"); 2862 dev_dbg(dev, "sending exec_dl_code\n");
2909 response = usb_control_msg (edge_serial->serial->dev, 2863 response = usb_control_msg (edge_serial->serial->dev,
2910 usb_sndctrlpipe(edge_serial->serial->dev, 0), 2864 usb_sndctrlpipe(edge_serial->serial->dev, 0),
2911 USB_REQUEST_ION_EXEC_DL_CODE, 2865 USB_REQUEST_ION_EXEC_DL_CODE,
2912 0x40, 0x4000, 0x0001, NULL, 0, 3000); 2866 0x40, 0x4000, 0x0001, NULL, 0, 3000);
2913 2867
2914 release_firmware(fw); 2868 release_firmware(fw);
@@ -2923,6 +2877,7 @@ static int edge_startup(struct usb_serial *serial)
2923 struct edgeport_serial *edge_serial; 2877 struct edgeport_serial *edge_serial;
2924 struct edgeport_port *edge_port; 2878 struct edgeport_port *edge_port;
2925 struct usb_device *dev; 2879 struct usb_device *dev;
2880 struct device *ddev = &serial->dev->dev;
2926 int i, j; 2881 int i, j;
2927 int response; 2882 int response;
2928 bool interrupt_in_found; 2883 bool interrupt_in_found;
@@ -2974,32 +2929,31 @@ static int edge_startup(struct usb_serial *serial)
2974 /* serial->num_ports = serial->product_info.NumPorts; */ 2929 /* serial->num_ports = serial->product_info.NumPorts; */
2975 if ((!edge_serial->is_epic) && 2930 if ((!edge_serial->is_epic) &&
2976 (edge_serial->product_info.NumPorts != serial->num_ports)) { 2931 (edge_serial->product_info.NumPorts != serial->num_ports)) {
2977 dev_warn(&serial->dev->dev, "Device Reported %d serial ports " 2932 dev_warn(ddev,
2978 "vs. core thinking we have %d ports, email " 2933 "Device Reported %d serial ports vs. core thinking we have %d ports, email greg@kroah.com this information.\n",
2979 "greg@kroah.com this information.\n",
2980 edge_serial->product_info.NumPorts, 2934 edge_serial->product_info.NumPorts,
2981 serial->num_ports); 2935 serial->num_ports);
2982 } 2936 }
2983 2937
2984 dbg("%s - time 1 %ld", __func__, jiffies); 2938 dev_dbg(ddev, "%s - time 1 %ld\n", __func__, jiffies);
2985 2939
2986 /* If not an EPiC device */ 2940 /* If not an EPiC device */
2987 if (!edge_serial->is_epic) { 2941 if (!edge_serial->is_epic) {
2988 /* now load the application firmware into this device */ 2942 /* now load the application firmware into this device */
2989 load_application_firmware(edge_serial); 2943 load_application_firmware(edge_serial);
2990 2944
2991 dbg("%s - time 2 %ld", __func__, jiffies); 2945 dev_dbg(ddev, "%s - time 2 %ld\n", __func__, jiffies);
2992 2946
2993 /* Check current Edgeport EEPROM and update if necessary */ 2947 /* Check current Edgeport EEPROM and update if necessary */
2994 update_edgeport_E2PROM(edge_serial); 2948 update_edgeport_E2PROM(edge_serial);
2995 2949
2996 dbg("%s - time 3 %ld", __func__, jiffies); 2950 dev_dbg(ddev, "%s - time 3 %ld\n", __func__, jiffies);
2997 2951
2998 /* set the configuration to use #1 */ 2952 /* set the configuration to use #1 */
2999/* dbg("set_configuration 1"); */ 2953/* dev_dbg(ddev, "set_configuration 1\n"); */
3000/* usb_set_configuration (dev, 1); */ 2954/* usb_set_configuration (dev, 1); */
3001 } 2955 }
3002 dbg(" FirmwareMajorVersion %d.%d.%d", 2956 dev_dbg(ddev, " FirmwareMajorVersion %d.%d.%d\n",
3003 edge_serial->product_info.FirmwareMajorVersion, 2957 edge_serial->product_info.FirmwareMajorVersion,
3004 edge_serial->product_info.FirmwareMinorVersion, 2958 edge_serial->product_info.FirmwareMinorVersion,
3005 le16_to_cpu(edge_serial->product_info.FirmwareBuildNumber)); 2959 le16_to_cpu(edge_serial->product_info.FirmwareBuildNumber));
@@ -3011,8 +2965,7 @@ static int edge_startup(struct usb_serial *serial)
3011 for (i = 0; i < serial->num_ports; ++i) { 2965 for (i = 0; i < serial->num_ports; ++i) {
3012 edge_port = kzalloc(sizeof(struct edgeport_port), GFP_KERNEL); 2966 edge_port = kzalloc(sizeof(struct edgeport_port), GFP_KERNEL);
3013 if (edge_port == NULL) { 2967 if (edge_port == NULL) {
3014 dev_err(&serial->dev->dev, "%s - Out of memory\n", 2968 dev_err(ddev, "%s - Out of memory\n", __func__);
3015 __func__);
3016 for (j = 0; j < i; ++j) { 2969 for (j = 0; j < i; ++j) {
3017 kfree(usb_get_serial_port_data(serial->port[j])); 2970 kfree(usb_get_serial_port_data(serial->port[j]));
3018 usb_set_serial_port_data(serial->port[j], 2971 usb_set_serial_port_data(serial->port[j],
@@ -3044,19 +2997,19 @@ static int edge_startup(struct usb_serial *serial)
3044 if (!interrupt_in_found && 2997 if (!interrupt_in_found &&
3045 (usb_endpoint_is_int_in(endpoint))) { 2998 (usb_endpoint_is_int_in(endpoint))) {
3046 /* we found a interrupt in endpoint */ 2999 /* we found a interrupt in endpoint */
3047 dbg("found interrupt in"); 3000 dev_dbg(ddev, "found interrupt in\n");
3048 3001
3049 /* not set up yet, so do it now */ 3002 /* not set up yet, so do it now */
3050 edge_serial->interrupt_read_urb = 3003 edge_serial->interrupt_read_urb =
3051 usb_alloc_urb(0, GFP_KERNEL); 3004 usb_alloc_urb(0, GFP_KERNEL);
3052 if (!edge_serial->interrupt_read_urb) { 3005 if (!edge_serial->interrupt_read_urb) {
3053 dev_err(&dev->dev, "out of memory\n"); 3006 dev_err(ddev, "out of memory\n");
3054 return -ENOMEM; 3007 return -ENOMEM;
3055 } 3008 }
3056 edge_serial->interrupt_in_buffer = 3009 edge_serial->interrupt_in_buffer =
3057 kmalloc(buffer_size, GFP_KERNEL); 3010 kmalloc(buffer_size, GFP_KERNEL);
3058 if (!edge_serial->interrupt_in_buffer) { 3011 if (!edge_serial->interrupt_in_buffer) {
3059 dev_err(&dev->dev, "out of memory\n"); 3012 dev_err(ddev, "out of memory\n");
3060 usb_free_urb(edge_serial->interrupt_read_urb); 3013 usb_free_urb(edge_serial->interrupt_read_urb);
3061 return -ENOMEM; 3014 return -ENOMEM;
3062 } 3015 }
@@ -3081,13 +3034,13 @@ static int edge_startup(struct usb_serial *serial)
3081 if (!bulk_in_found && 3034 if (!bulk_in_found &&
3082 (usb_endpoint_is_bulk_in(endpoint))) { 3035 (usb_endpoint_is_bulk_in(endpoint))) {
3083 /* we found a bulk in endpoint */ 3036 /* we found a bulk in endpoint */
3084 dbg("found bulk in"); 3037 dev_dbg(ddev, "found bulk in\n");
3085 3038
3086 /* not set up yet, so do it now */ 3039 /* not set up yet, so do it now */
3087 edge_serial->read_urb = 3040 edge_serial->read_urb =
3088 usb_alloc_urb(0, GFP_KERNEL); 3041 usb_alloc_urb(0, GFP_KERNEL);
3089 if (!edge_serial->read_urb) { 3042 if (!edge_serial->read_urb) {
3090 dev_err(&dev->dev, "out of memory\n"); 3043 dev_err(ddev, "out of memory\n");
3091 return -ENOMEM; 3044 return -ENOMEM;
3092 } 3045 }
3093 edge_serial->bulk_in_buffer = 3046 edge_serial->bulk_in_buffer =
@@ -3114,7 +3067,7 @@ static int edge_startup(struct usb_serial *serial)
3114 if (!bulk_out_found && 3067 if (!bulk_out_found &&
3115 (usb_endpoint_is_bulk_out(endpoint))) { 3068 (usb_endpoint_is_bulk_out(endpoint))) {
3116 /* we found a bulk out endpoint */ 3069 /* we found a bulk out endpoint */
3117 dbg("found bulk out"); 3070 dev_dbg(ddev, "found bulk out\n");
3118 edge_serial->bulk_out_endpoint = 3071 edge_serial->bulk_out_endpoint =
3119 endpoint->bEndpointAddress; 3072 endpoint->bEndpointAddress;
3120 bulk_out_found = true; 3073 bulk_out_found = true;
@@ -3122,8 +3075,7 @@ static int edge_startup(struct usb_serial *serial)
3122 } 3075 }
3123 3076
3124 if (!interrupt_in_found || !bulk_in_found || !bulk_out_found) { 3077 if (!interrupt_in_found || !bulk_in_found || !bulk_out_found) {
3125 dev_err(&dev->dev, "Error - the proper endpoints " 3078 dev_err(ddev, "Error - the proper endpoints were not found!\n");
3126 "were not found!\n");
3127 return -ENODEV; 3079 return -ENODEV;
3128 } 3080 }
3129 3081
@@ -3132,8 +3084,7 @@ static int edge_startup(struct usb_serial *serial)
3132 response = usb_submit_urb(edge_serial->interrupt_read_urb, 3084 response = usb_submit_urb(edge_serial->interrupt_read_urb,
3133 GFP_KERNEL); 3085 GFP_KERNEL);
3134 if (response) 3086 if (response)
3135 dev_err(&dev->dev, 3087 dev_err(ddev, "%s - Error %d submitting control urb\n",
3136 "%s - Error %d submitting control urb\n",
3137 __func__, response); 3088 __func__, response);
3138 } 3089 }
3139 return response; 3090 return response;
@@ -3148,8 +3099,6 @@ static void edge_disconnect(struct usb_serial *serial)
3148{ 3099{
3149 struct edgeport_serial *edge_serial = usb_get_serial_data(serial); 3100 struct edgeport_serial *edge_serial = usb_get_serial_data(serial);
3150 3101
3151 dbg("%s", __func__);
3152
3153 /* stop reads and writes on all ports */ 3102 /* stop reads and writes on all ports */
3154 /* free up our endpoint stuff */ 3103 /* free up our endpoint stuff */
3155 if (edge_serial->is_epic) { 3104 if (edge_serial->is_epic) {
@@ -3173,8 +3122,6 @@ static void edge_release(struct usb_serial *serial)
3173 struct edgeport_serial *edge_serial = usb_get_serial_data(serial); 3122 struct edgeport_serial *edge_serial = usb_get_serial_data(serial);
3174 int i; 3123 int i;
3175 3124
3176 dbg("%s", __func__);
3177
3178 for (i = 0; i < serial->num_ports; ++i) 3125 for (i = 0; i < serial->num_ports; ++i)
3179 kfree(usb_get_serial_port_data(serial->port[i])); 3126 kfree(usb_get_serial_port_data(serial->port[i]));
3180 3127
@@ -3190,6 +3137,3 @@ MODULE_FIRMWARE("edgeport/boot.fw");
3190MODULE_FIRMWARE("edgeport/boot2.fw"); 3137MODULE_FIRMWARE("edgeport/boot2.fw");
3191MODULE_FIRMWARE("edgeport/down.fw"); 3138MODULE_FIRMWARE("edgeport/down.fw");
3192MODULE_FIRMWARE("edgeport/down2.fw"); 3139MODULE_FIRMWARE("edgeport/down2.fw");
3193
3194module_param(debug, bool, S_IRUGO | S_IWUSR);
3195MODULE_PARM_DESC(debug, "Debug enabled or not");
diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c
index 765978ae752e..a2209cd45093 100644
--- a/drivers/usb/serial/io_ti.c
+++ b/drivers/usb/serial/io_ti.c
@@ -201,8 +201,6 @@ static unsigned char OperationalMajorVersion;
201static unsigned char OperationalMinorVersion; 201static unsigned char OperationalMinorVersion;
202static unsigned short OperationalBuildNumber; 202static unsigned short OperationalBuildNumber;
203 203
204static bool debug;
205
206static int closing_wait = EDGE_CLOSING_WAIT; 204static int closing_wait = EDGE_CLOSING_WAIT;
207static bool ignore_cpu_rev; 205static bool ignore_cpu_rev;
208static int default_uart_mode; /* RS232 */ 206static int default_uart_mode; /* RS232 */
@@ -233,8 +231,8 @@ static int ti_vread_sync(struct usb_device *dev, __u8 request,
233 if (status < 0) 231 if (status < 0)
234 return status; 232 return status;
235 if (status != size) { 233 if (status != size) {
236 dbg("%s - wanted to write %d, but only wrote %d", 234 dev_dbg(&dev->dev, "%s - wanted to write %d, but only wrote %d\n",
237 __func__, size, status); 235 __func__, size, status);
238 return -ECOMM; 236 return -ECOMM;
239 } 237 }
240 return 0; 238 return 0;
@@ -251,8 +249,8 @@ static int ti_vsend_sync(struct usb_device *dev, __u8 request,
251 if (status < 0) 249 if (status < 0)
252 return status; 250 return status;
253 if (status != size) { 251 if (status != size) {
254 dbg("%s - wanted to write %d, but only wrote %d", 252 dev_dbg(&dev->dev, "%s - wanted to write %d, but only wrote %d\n",
255 __func__, size, status); 253 __func__, size, status);
256 return -ECOMM; 254 return -ECOMM;
257 } 255 }
258 return 0; 256 return 0;
@@ -270,7 +268,7 @@ static int purge_port(struct usb_serial_port *port, __u16 mask)
270{ 268{
271 int port_number = port->number - port->serial->minor; 269 int port_number = port->number - port->serial->minor;
272 270
273 dbg("%s - port %d, mask %x", __func__, port_number, mask); 271 dev_dbg(&port->dev, "%s - port %d, mask %x\n", __func__, port_number, mask);
274 272
275 return send_cmd(port->serial->dev, 273 return send_cmd(port->serial->dev,
276 UMPC_PURGE_PORT, 274 UMPC_PURGE_PORT,
@@ -295,7 +293,7 @@ static int read_download_mem(struct usb_device *dev, int start_address,
295 __u8 read_length; 293 __u8 read_length;
296 __be16 be_start_address; 294 __be16 be_start_address;
297 295
298 dbg("%s - @ %x for %d", __func__, start_address, length); 296 dev_dbg(&dev->dev, "%s - @ %x for %d\n", __func__, start_address, length);
299 297
300 /* Read in blocks of 64 bytes 298 /* Read in blocks of 64 bytes
301 * (TI firmware can't handle more than 64 byte reads) 299 * (TI firmware can't handle more than 64 byte reads)
@@ -307,8 +305,7 @@ static int read_download_mem(struct usb_device *dev, int start_address,
307 read_length = (__u8)length; 305 read_length = (__u8)length;
308 306
309 if (read_length > 1) { 307 if (read_length > 1) {
310 dbg("%s - @ %x for %d", __func__, 308 dev_dbg(&dev->dev, "%s - @ %x for %d\n", __func__, start_address, read_length);
311 start_address, read_length);
312 } 309 }
313 be_start_address = cpu_to_be16(start_address); 310 be_start_address = cpu_to_be16(start_address);
314 status = ti_vread_sync(dev, UMPC_MEMORY_READ, 311 status = ti_vread_sync(dev, UMPC_MEMORY_READ,
@@ -317,13 +314,12 @@ static int read_download_mem(struct usb_device *dev, int start_address,
317 buffer, read_length); 314 buffer, read_length);
318 315
319 if (status) { 316 if (status) {
320 dbg("%s - ERROR %x", __func__, status); 317 dev_dbg(&dev->dev, "%s - ERROR %x\n", __func__, status);
321 return status; 318 return status;
322 } 319 }
323 320
324 if (read_length > 1) 321 if (read_length > 1)
325 usb_serial_debug_data(debug, &dev->dev, __func__, 322 usb_serial_debug_data(&dev->dev, __func__, read_length, buffer);
326 read_length, buffer);
327 323
328 /* Update pointers/length */ 324 /* Update pointers/length */
329 start_address += read_length; 325 start_address += read_length;
@@ -353,15 +349,14 @@ static int read_boot_mem(struct edgeport_serial *serial,
353 UMPC_MEMORY_READ, serial->TI_I2C_Type, 349 UMPC_MEMORY_READ, serial->TI_I2C_Type,
354 (__u16)(start_address+i), &buffer[i], 0x01); 350 (__u16)(start_address+i), &buffer[i], 0x01);
355 if (status) { 351 if (status) {
356 dbg("%s - ERROR %x", __func__, status); 352 dev_dbg(&serial->serial->dev->dev, "%s - ERROR %x\n", __func__, status);
357 return status; 353 return status;
358 } 354 }
359 } 355 }
360 356
361 dbg("%s - start_address = %x, length = %d", 357 dev_dbg(&serial->serial->dev->dev, "%s - start_address = %x, length = %d\n",
362 __func__, start_address, length); 358 __func__, start_address, length);
363 usb_serial_debug_data(debug, &serial->serial->dev->dev, 359 usb_serial_debug_data(&serial->serial->dev->dev, __func__, length, buffer);
364 __func__, length, buffer);
365 360
366 serial->TiReadI2C = 1; 361 serial->TiReadI2C = 1;
367 362
@@ -398,10 +393,8 @@ static int write_boot_mem(struct edgeport_serial *serial,
398 return status; 393 return status;
399 } 394 }
400 395
401 dbg("%s - start_sddr = %x, length = %d", 396 dev_dbg(&serial->serial->dev->dev, "%s - start_sddr = %x, length = %d\n", __func__, start_address, length);
402 __func__, start_address, length); 397 usb_serial_debug_data(&serial->serial->dev->dev, __func__, length, buffer);
403 usb_serial_debug_data(debug, &serial->serial->dev->dev,
404 __func__, length, buffer);
405 398
406 return status; 399 return status;
407} 400}
@@ -411,6 +404,7 @@ static int write_boot_mem(struct edgeport_serial *serial,
411static int write_i2c_mem(struct edgeport_serial *serial, 404static int write_i2c_mem(struct edgeport_serial *serial,
412 int start_address, int length, __u8 address_type, __u8 *buffer) 405 int start_address, int length, __u8 address_type, __u8 *buffer)
413{ 406{
407 struct device *dev = &serial->serial->dev->dev;
414 int status = 0; 408 int status = 0;
415 int write_length; 409 int write_length;
416 __be16 be_start_address; 410 __be16 be_start_address;
@@ -424,10 +418,9 @@ static int write_i2c_mem(struct edgeport_serial *serial,
424 if (write_length > length) 418 if (write_length > length)
425 write_length = length; 419 write_length = length;
426 420
427 dbg("%s - BytesInFirstPage Addr = %x, length = %d", 421 dev_dbg(dev, "%s - BytesInFirstPage Addr = %x, length = %d\n",
428 __func__, start_address, write_length); 422 __func__, start_address, write_length);
429 usb_serial_debug_data(debug, &serial->serial->dev->dev, 423 usb_serial_debug_data(dev, __func__, write_length, buffer);
430 __func__, write_length, buffer);
431 424
432 /* Write first page */ 425 /* Write first page */
433 be_start_address = cpu_to_be16(start_address); 426 be_start_address = cpu_to_be16(start_address);
@@ -436,7 +429,7 @@ static int write_i2c_mem(struct edgeport_serial *serial,
436 (__force __u16)be_start_address, 429 (__force __u16)be_start_address,
437 buffer, write_length); 430 buffer, write_length);
438 if (status) { 431 if (status) {
439 dbg("%s - ERROR %d", __func__, status); 432 dev_dbg(dev, "%s - ERROR %d\n", __func__, status);
440 return status; 433 return status;
441 } 434 }
442 435
@@ -452,10 +445,9 @@ static int write_i2c_mem(struct edgeport_serial *serial,
452 else 445 else
453 write_length = length; 446 write_length = length;
454 447
455 dbg("%s - Page Write Addr = %x, length = %d", 448 dev_dbg(dev, "%s - Page Write Addr = %x, length = %d\n",
456 __func__, start_address, write_length); 449 __func__, start_address, write_length);
457 usb_serial_debug_data(debug, &serial->serial->dev->dev, 450 usb_serial_debug_data(dev, __func__, write_length, buffer);
458 __func__, write_length, buffer);
459 451
460 /* Write next page */ 452 /* Write next page */
461 be_start_address = cpu_to_be16(start_address); 453 be_start_address = cpu_to_be16(start_address);
@@ -464,8 +456,7 @@ static int write_i2c_mem(struct edgeport_serial *serial,
464 (__force __u16)be_start_address, 456 (__force __u16)be_start_address,
465 buffer, write_length); 457 buffer, write_length);
466 if (status) { 458 if (status) {
467 dev_err(&serial->serial->dev->dev, "%s - ERROR %d\n", 459 dev_err(dev, "%s - ERROR %d\n", __func__, status);
468 __func__, status);
469 return status; 460 return status;
470 } 461 }
471 462
@@ -508,7 +499,7 @@ static int tx_active(struct edgeport_port *port)
508 if (status) 499 if (status)
509 goto exit_is_tx_active; 500 goto exit_is_tx_active;
510 501
511 dbg("%s - XByteCount 0x%X", __func__, oedb->XByteCount); 502 dev_dbg(&port->port->dev, "%s - XByteCount 0x%X\n", __func__, oedb->XByteCount);
512 503
513 /* and the LSR */ 504 /* and the LSR */
514 status = read_ram(port->port->serial->dev, 505 status = read_ram(port->port->serial->dev,
@@ -516,7 +507,7 @@ static int tx_active(struct edgeport_port *port)
516 507
517 if (status) 508 if (status)
518 goto exit_is_tx_active; 509 goto exit_is_tx_active;
519 dbg("%s - LSR = 0x%X", __func__, *lsr); 510 dev_dbg(&port->port->dev, "%s - LSR = 0x%X\n", __func__, *lsr);
520 511
521 /* If either buffer has data or we are transmitting then return TRUE */ 512 /* If either buffer has data or we are transmitting then return TRUE */
522 if ((oedb->XByteCount & 0x80) != 0) 513 if ((oedb->XByteCount & 0x80) != 0)
@@ -527,7 +518,7 @@ static int tx_active(struct edgeport_port *port)
527 518
528 /* We return Not Active if we get any kind of error */ 519 /* We return Not Active if we get any kind of error */
529exit_is_tx_active: 520exit_is_tx_active:
530 dbg("%s - return %d", __func__, bytes_left); 521 dev_dbg(&port->port->dev, "%s - return %d\n", __func__, bytes_left);
531 522
532 kfree(lsr); 523 kfree(lsr);
533 kfree(oedb); 524 kfree(oedb);
@@ -599,14 +590,13 @@ static int choose_config(struct usb_device *dev)
599 * configuration # 1, which is Config Descriptor 0. 590 * configuration # 1, which is Config Descriptor 0.
600 */ 591 */
601 592
602 dbg("%s - Number of Interfaces = %d", 593 dev_dbg(&dev->dev, "%s - Number of Interfaces = %d\n",
603 __func__, dev->config->desc.bNumInterfaces); 594 __func__, dev->config->desc.bNumInterfaces);
604 dbg("%s - MAX Power = %d", 595 dev_dbg(&dev->dev, "%s - MAX Power = %d\n",
605 __func__, dev->config->desc.bMaxPower * 2); 596 __func__, dev->config->desc.bMaxPower * 2);
606 597
607 if (dev->config->desc.bNumInterfaces != 1) { 598 if (dev->config->desc.bNumInterfaces != 1) {
608 dev_err(&dev->dev, "%s - bNumInterfaces is not 1, ERROR!\n", 599 dev_err(&dev->dev, "%s - bNumInterfaces is not 1, ERROR!\n", __func__);
609 __func__);
610 return -ENODEV; 600 return -ENODEV;
611 } 601 }
612 602
@@ -684,7 +674,7 @@ static int valid_csum(struct ti_i2c_desc *rom_desc, __u8 *buffer)
684 cs = (__u8)(cs + buffer[i]); 674 cs = (__u8)(cs + buffer[i]);
685 675
686 if (cs != rom_desc->CheckSum) { 676 if (cs != rom_desc->CheckSum) {
687 dbg("%s - Mismatch %x - %x", __func__, rom_desc->CheckSum, cs); 677 pr_debug("%s - Mismatch %x - %x", __func__, rom_desc->CheckSum, cs);
688 return -EINVAL; 678 return -EINVAL;
689 } 679 }
690 return 0; 680 return 0;
@@ -736,11 +726,11 @@ static int check_i2c_image(struct edgeport_serial *serial)
736 if ((start_address + sizeof(struct ti_i2c_desc) + 726 if ((start_address + sizeof(struct ti_i2c_desc) +
737 rom_desc->Size) > TI_MAX_I2C_SIZE) { 727 rom_desc->Size) > TI_MAX_I2C_SIZE) {
738 status = -ENODEV; 728 status = -ENODEV;
739 dbg("%s - structure too big, erroring out.", __func__); 729 dev_dbg(dev, "%s - structure too big, erroring out.\n", __func__);
740 break; 730 break;
741 } 731 }
742 732
743 dbg("%s Type = 0x%x", __func__, rom_desc->Type); 733 dev_dbg(dev, "%s Type = 0x%x\n", __func__, rom_desc->Type);
744 734
745 /* Skip type 2 record */ 735 /* Skip type 2 record */
746 ttype = rom_desc->Type & 0x0f; 736 ttype = rom_desc->Type & 0x0f;
@@ -779,18 +769,18 @@ static int get_manuf_info(struct edgeport_serial *serial, __u8 *buffer)
779 int start_address; 769 int start_address;
780 struct ti_i2c_desc *rom_desc; 770 struct ti_i2c_desc *rom_desc;
781 struct edge_ti_manuf_descriptor *desc; 771 struct edge_ti_manuf_descriptor *desc;
772 struct device *dev = &serial->serial->dev->dev;
782 773
783 rom_desc = kmalloc(sizeof(*rom_desc), GFP_KERNEL); 774 rom_desc = kmalloc(sizeof(*rom_desc), GFP_KERNEL);
784 if (!rom_desc) { 775 if (!rom_desc) {
785 dev_err(&serial->serial->dev->dev, "%s - out of memory\n", 776 dev_err(dev, "%s - out of memory\n", __func__);
786 __func__);
787 return -ENOMEM; 777 return -ENOMEM;
788 } 778 }
789 start_address = get_descriptor_addr(serial, I2C_DESC_TYPE_ION, 779 start_address = get_descriptor_addr(serial, I2C_DESC_TYPE_ION,
790 rom_desc); 780 rom_desc);
791 781
792 if (!start_address) { 782 if (!start_address) {
793 dbg("%s - Edge Descriptor not found in I2C", __func__); 783 dev_dbg(dev, "%s - Edge Descriptor not found in I2C\n", __func__);
794 status = -ENODEV; 784 status = -ENODEV;
795 goto exit; 785 goto exit;
796 } 786 }
@@ -804,12 +794,12 @@ static int get_manuf_info(struct edgeport_serial *serial, __u8 *buffer)
804 status = valid_csum(rom_desc, buffer); 794 status = valid_csum(rom_desc, buffer);
805 795
806 desc = (struct edge_ti_manuf_descriptor *)buffer; 796 desc = (struct edge_ti_manuf_descriptor *)buffer;
807 dbg("%s - IonConfig 0x%x", __func__, desc->IonConfig); 797 dev_dbg(dev, "%s - IonConfig 0x%x\n", __func__, desc->IonConfig);
808 dbg("%s - Version %d", __func__, desc->Version); 798 dev_dbg(dev, "%s - Version %d\n", __func__, desc->Version);
809 dbg("%s - Cpu/Board 0x%x", __func__, desc->CpuRev_BoardRev); 799 dev_dbg(dev, "%s - Cpu/Board 0x%x\n", __func__, desc->CpuRev_BoardRev);
810 dbg("%s - NumPorts %d", __func__, desc->NumPorts); 800 dev_dbg(dev, "%s - NumPorts %d\n", __func__, desc->NumPorts);
811 dbg("%s - NumVirtualPorts %d", __func__, desc->NumVirtualPorts); 801 dev_dbg(dev, "%s - NumVirtualPorts %d\n", __func__, desc->NumVirtualPorts);
812 dbg("%s - TotalPorts %d", __func__, desc->TotalPorts); 802 dev_dbg(dev, "%s - TotalPorts %d\n", __func__, desc->TotalPorts);
813 803
814exit: 804exit:
815 kfree(rom_desc); 805 kfree(rom_desc);
@@ -855,8 +845,8 @@ static int build_i2c_fw_hdr(__u8 *header, struct device *dev)
855 845
856 err = request_firmware(&fw, fw_name, dev); 846 err = request_firmware(&fw, fw_name, dev);
857 if (err) { 847 if (err) {
858 printk(KERN_ERR "Failed to load image \"%s\" err %d\n", 848 dev_err(dev, "Failed to load image \"%s\" err %d\n",
859 fw_name, err); 849 fw_name, err);
860 kfree(buffer); 850 kfree(buffer);
861 return err; 851 return err;
862 } 852 }
@@ -903,13 +893,13 @@ static int build_i2c_fw_hdr(__u8 *header, struct device *dev)
903/* Try to figure out what type of I2c we have */ 893/* Try to figure out what type of I2c we have */
904static int i2c_type_bootmode(struct edgeport_serial *serial) 894static int i2c_type_bootmode(struct edgeport_serial *serial)
905{ 895{
896 struct device *dev = &serial->serial->dev->dev;
906 int status; 897 int status;
907 u8 *data; 898 u8 *data;
908 899
909 data = kmalloc(1, GFP_KERNEL); 900 data = kmalloc(1, GFP_KERNEL);
910 if (!data) { 901 if (!data) {
911 dev_err(&serial->serial->dev->dev, 902 dev_err(dev, "%s - out of memory\n", __func__);
912 "%s - out of memory\n", __func__);
913 return -ENOMEM; 903 return -ENOMEM;
914 } 904 }
915 905
@@ -917,11 +907,11 @@ static int i2c_type_bootmode(struct edgeport_serial *serial)
917 status = ti_vread_sync(serial->serial->dev, UMPC_MEMORY_READ, 907 status = ti_vread_sync(serial->serial->dev, UMPC_MEMORY_READ,
918 DTK_ADDR_SPACE_I2C_TYPE_II, 0, data, 0x01); 908 DTK_ADDR_SPACE_I2C_TYPE_II, 0, data, 0x01);
919 if (status) 909 if (status)
920 dbg("%s - read 2 status error = %d", __func__, status); 910 dev_dbg(dev, "%s - read 2 status error = %d\n", __func__, status);
921 else 911 else
922 dbg("%s - read 2 data = 0x%x", __func__, *data); 912 dev_dbg(dev, "%s - read 2 data = 0x%x\n", __func__, *data);
923 if ((!status) && (*data == UMP5152 || *data == UMP3410)) { 913 if ((!status) && (*data == UMP5152 || *data == UMP3410)) {
924 dbg("%s - ROM_TYPE_II", __func__); 914 dev_dbg(dev, "%s - ROM_TYPE_II\n", __func__);
925 serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_II; 915 serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_II;
926 goto out; 916 goto out;
927 } 917 }
@@ -930,16 +920,16 @@ static int i2c_type_bootmode(struct edgeport_serial *serial)
930 status = ti_vread_sync(serial->serial->dev, UMPC_MEMORY_READ, 920 status = ti_vread_sync(serial->serial->dev, UMPC_MEMORY_READ,
931 DTK_ADDR_SPACE_I2C_TYPE_III, 0, data, 0x01); 921 DTK_ADDR_SPACE_I2C_TYPE_III, 0, data, 0x01);
932 if (status) 922 if (status)
933 dbg("%s - read 3 status error = %d", __func__, status); 923 dev_dbg(dev, "%s - read 3 status error = %d\n", __func__, status);
934 else 924 else
935 dbg("%s - read 2 data = 0x%x", __func__, *data); 925 dev_dbg(dev, "%s - read 2 data = 0x%x\n", __func__, *data);
936 if ((!status) && (*data == UMP5152 || *data == UMP3410)) { 926 if ((!status) && (*data == UMP5152 || *data == UMP3410)) {
937 dbg("%s - ROM_TYPE_III", __func__); 927 dev_dbg(dev, "%s - ROM_TYPE_III\n", __func__);
938 serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_III; 928 serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_III;
939 goto out; 929 goto out;
940 } 930 }
941 931
942 dbg("%s - Unknown", __func__); 932 dev_dbg(dev, "%s - Unknown\n", __func__);
943 serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_II; 933 serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_II;
944 status = -ENODEV; 934 status = -ENODEV;
945out: 935out:
@@ -1050,11 +1040,11 @@ static int download_fw(struct edgeport_serial *serial)
1050 if (serial->product_info.TiMode == TI_MODE_DOWNLOAD) { 1040 if (serial->product_info.TiMode == TI_MODE_DOWNLOAD) {
1051 struct ti_i2c_desc *rom_desc; 1041 struct ti_i2c_desc *rom_desc;
1052 1042
1053 dbg("%s - RUNNING IN DOWNLOAD MODE", __func__); 1043 dev_dbg(dev, "%s - RUNNING IN DOWNLOAD MODE\n", __func__);
1054 1044
1055 status = check_i2c_image(serial); 1045 status = check_i2c_image(serial);
1056 if (status) { 1046 if (status) {
1057 dbg("%s - DOWNLOAD MODE -- BAD I2C", __func__); 1047 dev_dbg(dev, "%s - DOWNLOAD MODE -- BAD I2C\n", __func__);
1058 return status; 1048 return status;
1059 } 1049 }
1060 1050
@@ -1074,7 +1064,7 @@ static int download_fw(struct edgeport_serial *serial)
1074 1064
1075 /* Check version number of ION descriptor */ 1065 /* Check version number of ION descriptor */
1076 if (!ignore_cpu_rev && ti_cpu_rev(ti_manuf_desc) < 2) { 1066 if (!ignore_cpu_rev && ti_cpu_rev(ti_manuf_desc) < 2) {
1077 dbg("%s - Wrong CPU Rev %d (Must be 2)", 1067 dev_dbg(dev, "%s - Wrong CPU Rev %d (Must be 2)\n",
1078 __func__, ti_cpu_rev(ti_manuf_desc)); 1068 __func__, ti_cpu_rev(ti_manuf_desc));
1079 kfree(ti_manuf_desc); 1069 kfree(ti_manuf_desc);
1080 return -EINVAL; 1070 return -EINVAL;
@@ -1094,8 +1084,7 @@ static int download_fw(struct edgeport_serial *serial)
1094 struct ti_i2c_firmware_rec *firmware_version; 1084 struct ti_i2c_firmware_rec *firmware_version;
1095 u8 *record; 1085 u8 *record;
1096 1086
1097 dbg("%s - Found Type FIRMWARE (Type 2) record", 1087 dev_dbg(dev, "%s - Found Type FIRMWARE (Type 2) record\n", __func__);
1098 __func__);
1099 1088
1100 firmware_version = kmalloc(sizeof(*firmware_version), 1089 firmware_version = kmalloc(sizeof(*firmware_version),
1101 GFP_KERNEL); 1090 GFP_KERNEL);
@@ -1127,22 +1116,21 @@ static int download_fw(struct edgeport_serial *serial)
1127 download_new_ver = (OperationalMajorVersion << 8) + 1116 download_new_ver = (OperationalMajorVersion << 8) +
1128 (OperationalMinorVersion); 1117 (OperationalMinorVersion);
1129 1118
1130 dbg("%s - >> FW Versions Device %d.%d Driver %d.%d", 1119 dev_dbg(dev, "%s - >> FW Versions Device %d.%d Driver %d.%d\n",
1131 __func__, 1120 __func__, firmware_version->Ver_Major,
1132 firmware_version->Ver_Major, 1121 firmware_version->Ver_Minor,
1133 firmware_version->Ver_Minor, 1122 OperationalMajorVersion,
1134 OperationalMajorVersion, 1123 OperationalMinorVersion);
1135 OperationalMinorVersion);
1136 1124
1137 /* Check if we have an old version in the I2C and 1125 /* Check if we have an old version in the I2C and
1138 update if necessary */ 1126 update if necessary */
1139 if (download_cur_ver < download_new_ver) { 1127 if (download_cur_ver < download_new_ver) {
1140 dbg("%s - Update I2C dld from %d.%d to %d.%d", 1128 dev_dbg(dev, "%s - Update I2C dld from %d.%d to %d.%d\n",
1141 __func__, 1129 __func__,
1142 firmware_version->Ver_Major, 1130 firmware_version->Ver_Major,
1143 firmware_version->Ver_Minor, 1131 firmware_version->Ver_Minor,
1144 OperationalMajorVersion, 1132 OperationalMajorVersion,
1145 OperationalMinorVersion); 1133 OperationalMinorVersion);
1146 1134
1147 record = kmalloc(1, GFP_KERNEL); 1135 record = kmalloc(1, GFP_KERNEL);
1148 if (!record) { 1136 if (!record) {
@@ -1196,9 +1184,7 @@ static int download_fw(struct edgeport_serial *serial)
1196 } 1184 }
1197 1185
1198 if (*record != I2C_DESC_TYPE_FIRMWARE_BLANK) { 1186 if (*record != I2C_DESC_TYPE_FIRMWARE_BLANK) {
1199 dev_err(dev, 1187 dev_err(dev, "%s - error resetting device\n", __func__);
1200 "%s - error resetting device\n",
1201 __func__);
1202 kfree(record); 1188 kfree(record);
1203 kfree(firmware_version); 1189 kfree(firmware_version);
1204 kfree(rom_desc); 1190 kfree(rom_desc);
@@ -1206,15 +1192,14 @@ static int download_fw(struct edgeport_serial *serial)
1206 return -ENODEV; 1192 return -ENODEV;
1207 } 1193 }
1208 1194
1209 dbg("%s - HARDWARE RESET", __func__); 1195 dev_dbg(dev, "%s - HARDWARE RESET\n", __func__);
1210 1196
1211 /* Reset UMP -- Back to BOOT MODE */ 1197 /* Reset UMP -- Back to BOOT MODE */
1212 status = ti_vsend_sync(serial->serial->dev, 1198 status = ti_vsend_sync(serial->serial->dev,
1213 UMPC_HARDWARE_RESET, 1199 UMPC_HARDWARE_RESET,
1214 0, 0, NULL, 0); 1200 0, 0, NULL, 0);
1215 1201
1216 dbg("%s - HARDWARE RESET return %d", 1202 dev_dbg(dev, "%s - HARDWARE RESET return %d\n", __func__, status);
1217 __func__, status);
1218 1203
1219 /* return an error on purpose. */ 1204 /* return an error on purpose. */
1220 kfree(record); 1205 kfree(record);
@@ -1249,8 +1234,7 @@ static int download_fw(struct edgeport_serial *serial)
1249 return -ENOMEM; 1234 return -ENOMEM;
1250 } 1235 }
1251 1236
1252 dbg("%s - Found Type BLANK FIRMWARE (Type F2) record", 1237 dev_dbg(dev, "%s - Found Type BLANK FIRMWARE (Type F2) record\n", __func__);
1253 __func__);
1254 1238
1255 /* 1239 /*
1256 * In order to update the I2C firmware we must change 1240 * In order to update the I2C firmware we must change
@@ -1292,7 +1276,7 @@ static int download_fw(struct edgeport_serial *serial)
1292 HEADER_SIZE, vheader); 1276 HEADER_SIZE, vheader);
1293 1277
1294 if (status) { 1278 if (status) {
1295 dbg("%s - can't read header back", __func__); 1279 dev_dbg(dev, "%s - can't read header back\n", __func__);
1296 kfree(vheader); 1280 kfree(vheader);
1297 kfree(header); 1281 kfree(header);
1298 kfree(rom_desc); 1282 kfree(rom_desc);
@@ -1300,8 +1284,7 @@ static int download_fw(struct edgeport_serial *serial)
1300 return status; 1284 return status;
1301 } 1285 }
1302 if (memcmp(vheader, header, HEADER_SIZE)) { 1286 if (memcmp(vheader, header, HEADER_SIZE)) {
1303 dbg("%s - write download record failed", 1287 dev_dbg(dev, "%s - write download record failed\n", __func__);
1304 __func__);
1305 kfree(vheader); 1288 kfree(vheader);
1306 kfree(header); 1289 kfree(header);
1307 kfree(rom_desc); 1290 kfree(rom_desc);
@@ -1312,13 +1295,13 @@ static int download_fw(struct edgeport_serial *serial)
1312 kfree(vheader); 1295 kfree(vheader);
1313 kfree(header); 1296 kfree(header);
1314 1297
1315 dbg("%s - Start firmware update", __func__); 1298 dev_dbg(dev, "%s - Start firmware update\n", __func__);
1316 1299
1317 /* Tell firmware to copy download image into I2C */ 1300 /* Tell firmware to copy download image into I2C */
1318 status = ti_vsend_sync(serial->serial->dev, 1301 status = ti_vsend_sync(serial->serial->dev,
1319 UMPC_COPY_DNLD_TO_I2C, 0, 0, NULL, 0); 1302 UMPC_COPY_DNLD_TO_I2C, 0, 0, NULL, 0);
1320 1303
1321 dbg("%s - Update complete 0x%x", __func__, status); 1304 dev_dbg(dev, "%s - Update complete 0x%x\n", __func__, status);
1322 if (status) { 1305 if (status) {
1323 dev_err(dev, 1306 dev_err(dev,
1324 "%s - UMPC_COPY_DNLD_TO_I2C failed\n", 1307 "%s - UMPC_COPY_DNLD_TO_I2C failed\n",
@@ -1338,7 +1321,7 @@ static int download_fw(struct edgeport_serial *serial)
1338 /********************************************************************/ 1321 /********************************************************************/
1339 /* Boot Mode */ 1322 /* Boot Mode */
1340 /********************************************************************/ 1323 /********************************************************************/
1341 dbg("%s - RUNNING IN BOOT MODE", __func__); 1324 dev_dbg(dev, "%s - RUNNING IN BOOT MODE\n", __func__);
1342 1325
1343 /* Configure the TI device so we can use the BULK pipes for download */ 1326 /* Configure the TI device so we can use the BULK pipes for download */
1344 status = config_boot_dev(serial->serial->dev); 1327 status = config_boot_dev(serial->serial->dev);
@@ -1347,8 +1330,8 @@ static int download_fw(struct edgeport_serial *serial)
1347 1330
1348 if (le16_to_cpu(serial->serial->dev->descriptor.idVendor) 1331 if (le16_to_cpu(serial->serial->dev->descriptor.idVendor)
1349 != USB_VENDOR_ID_ION) { 1332 != USB_VENDOR_ID_ION) {
1350 dbg("%s - VID = 0x%x", __func__, 1333 dev_dbg(dev, "%s - VID = 0x%x\n", __func__,
1351 le16_to_cpu(serial->serial->dev->descriptor.idVendor)); 1334 le16_to_cpu(serial->serial->dev->descriptor.idVendor));
1352 serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_II; 1335 serial->TI_I2C_Type = DTK_ADDR_SPACE_I2C_TYPE_II;
1353 goto stayinbootmode; 1336 goto stayinbootmode;
1354 } 1337 }
@@ -1385,8 +1368,8 @@ static int download_fw(struct edgeport_serial *serial)
1385 1368
1386 /* Check for version 2 */ 1369 /* Check for version 2 */
1387 if (!ignore_cpu_rev && ti_cpu_rev(ti_manuf_desc) < 2) { 1370 if (!ignore_cpu_rev && ti_cpu_rev(ti_manuf_desc) < 2) {
1388 dbg("%s - Wrong CPU Rev %d (Must be 2)", 1371 dev_dbg(dev, "%s - Wrong CPU Rev %d (Must be 2)\n",
1389 __func__, ti_cpu_rev(ti_manuf_desc)); 1372 __func__, ti_cpu_rev(ti_manuf_desc));
1390 kfree(ti_manuf_desc); 1373 kfree(ti_manuf_desc);
1391 goto stayinbootmode; 1374 goto stayinbootmode;
1392 } 1375 }
@@ -1421,8 +1404,8 @@ static int download_fw(struct edgeport_serial *serial)
1421 1404
1422 err = request_firmware(&fw, fw_name, dev); 1405 err = request_firmware(&fw, fw_name, dev);
1423 if (err) { 1406 if (err) {
1424 printk(KERN_ERR "Failed to load image \"%s\" err %d\n", 1407 dev_err(dev, "Failed to load image \"%s\" err %d\n",
1425 fw_name, err); 1408 fw_name, err);
1426 kfree(buffer); 1409 kfree(buffer);
1427 return err; 1410 return err;
1428 } 1411 }
@@ -1442,23 +1425,20 @@ static int download_fw(struct edgeport_serial *serial)
1442 header->CheckSum = cs; 1425 header->CheckSum = cs;
1443 1426
1444 /* Download the operational code */ 1427 /* Download the operational code */
1445 dbg("%s - Downloading operational code image (TI UMP)", 1428 dev_dbg(dev, "%s - Downloading operational code image (TI UMP)\n", __func__);
1446 __func__);
1447 status = download_code(serial, buffer, buffer_size); 1429 status = download_code(serial, buffer, buffer_size);
1448 1430
1449 kfree(buffer); 1431 kfree(buffer);
1450 1432
1451 if (status) { 1433 if (status) {
1452 dbg("%s - Error downloading operational code image", 1434 dev_dbg(dev, "%s - Error downloading operational code image\n", __func__);
1453 __func__);
1454 return status; 1435 return status;
1455 } 1436 }
1456 1437
1457 /* Device will reboot */ 1438 /* Device will reboot */
1458 serial->product_info.TiMode = TI_MODE_TRANSITIONING; 1439 serial->product_info.TiMode = TI_MODE_TRANSITIONING;
1459 1440
1460 dbg("%s - Download successful -- Device rebooting...", 1441 dev_dbg(dev, "%s - Download successful -- Device rebooting...\n", __func__);
1461 __func__);
1462 1442
1463 /* return an error on purpose */ 1443 /* return an error on purpose */
1464 return -ENODEV; 1444 return -ENODEV;
@@ -1466,7 +1446,7 @@ static int download_fw(struct edgeport_serial *serial)
1466 1446
1467stayinbootmode: 1447stayinbootmode:
1468 /* Eprom is invalid or blank stay in boot mode */ 1448 /* Eprom is invalid or blank stay in boot mode */
1469 dbg("%s - STAYING IN BOOT MODE", __func__); 1449 dev_dbg(dev, "%s - STAYING IN BOOT MODE\n", __func__);
1470 serial->product_info.TiMode = TI_MODE_BOOT; 1450 serial->product_info.TiMode = TI_MODE_BOOT;
1471 1451
1472 return 0; 1452 return 0;
@@ -1487,7 +1467,7 @@ static int restore_mcr(struct edgeport_port *port, __u8 mcr)
1487{ 1467{
1488 int status = 0; 1468 int status = 0;
1489 1469
1490 dbg("%s - %x", __func__, mcr); 1470 dev_dbg(&port->port->dev, "%s - %x\n", __func__, mcr);
1491 1471
1492 status = ti_do_config(port, UMPC_SET_CLR_DTR, mcr & MCR_DTR); 1472 status = ti_do_config(port, UMPC_SET_CLR_DTR, mcr & MCR_DTR);
1493 if (status) 1473 if (status)
@@ -1524,7 +1504,7 @@ static void handle_new_msr(struct edgeport_port *edge_port, __u8 msr)
1524 struct async_icount *icount; 1504 struct async_icount *icount;
1525 struct tty_struct *tty; 1505 struct tty_struct *tty;
1526 1506
1527 dbg("%s - %02x", __func__, msr); 1507 dev_dbg(&edge_port->port->dev, "%s - %02x\n", __func__, msr);
1528 1508
1529 if (msr & (EDGEPORT_MSR_DELTA_CTS | EDGEPORT_MSR_DELTA_DSR | 1509 if (msr & (EDGEPORT_MSR_DELTA_CTS | EDGEPORT_MSR_DELTA_DSR |
1530 EDGEPORT_MSR_DELTA_RI | EDGEPORT_MSR_DELTA_CD)) { 1510 EDGEPORT_MSR_DELTA_RI | EDGEPORT_MSR_DELTA_CD)) {
@@ -1566,7 +1546,7 @@ static void handle_new_lsr(struct edgeport_port *edge_port, int lsr_data,
1566 LSR_FRM_ERR | LSR_BREAK)); 1546 LSR_FRM_ERR | LSR_BREAK));
1567 struct tty_struct *tty; 1547 struct tty_struct *tty;
1568 1548
1569 dbg("%s - %02x", __func__, new_lsr); 1549 dev_dbg(&edge_port->port->dev, "%s - %02x\n", __func__, new_lsr);
1570 1550
1571 edge_port->shadow_lsr = lsr; 1551 edge_port->shadow_lsr = lsr;
1572 1552
@@ -1604,6 +1584,7 @@ static void edge_interrupt_callback(struct urb *urb)
1604 struct edgeport_serial *edge_serial = urb->context; 1584 struct edgeport_serial *edge_serial = urb->context;
1605 struct usb_serial_port *port; 1585 struct usb_serial_port *port;
1606 struct edgeport_port *edge_port; 1586 struct edgeport_port *edge_port;
1587 struct device *dev;
1607 unsigned char *data = urb->transfer_buffer; 1588 unsigned char *data = urb->transfer_buffer;
1608 int length = urb->actual_length; 1589 int length = urb->actual_length;
1609 int port_number; 1590 int port_number;
@@ -1613,8 +1594,6 @@ static void edge_interrupt_callback(struct urb *urb)
1613 __u8 msr; 1594 __u8 msr;
1614 int status = urb->status; 1595 int status = urb->status;
1615 1596
1616 dbg("%s", __func__);
1617
1618 switch (status) { 1597 switch (status) {
1619 case 0: 1598 case 0:
1620 /* success */ 1599 /* success */
@@ -1623,7 +1602,7 @@ static void edge_interrupt_callback(struct urb *urb)
1623 case -ENOENT: 1602 case -ENOENT:
1624 case -ESHUTDOWN: 1603 case -ESHUTDOWN:
1625 /* this urb is terminated, clean up */ 1604 /* this urb is terminated, clean up */
1626 dbg("%s - urb shutting down with status: %d", 1605 dev_dbg(&urb->dev->dev, "%s - urb shutting down with status: %d\n",
1627 __func__, status); 1606 __func__, status);
1628 return; 1607 return;
1629 default: 1608 default:
@@ -1633,27 +1612,26 @@ static void edge_interrupt_callback(struct urb *urb)
1633 } 1612 }
1634 1613
1635 if (!length) { 1614 if (!length) {
1636 dbg("%s - no data in urb", __func__); 1615 dev_dbg(&urb->dev->dev, "%s - no data in urb\n", __func__);
1637 goto exit; 1616 goto exit;
1638 } 1617 }
1639 1618
1640 usb_serial_debug_data(debug, &edge_serial->serial->dev->dev, 1619 dev = &edge_serial->serial->dev->dev;
1641 __func__, length, data); 1620 usb_serial_debug_data(dev, __func__, length, data);
1642 1621
1643 if (length != 2) { 1622 if (length != 2) {
1644 dbg("%s - expecting packet of size 2, got %d", 1623 dev_dbg(dev, "%s - expecting packet of size 2, got %d\n", __func__, length);
1645 __func__, length);
1646 goto exit; 1624 goto exit;
1647 } 1625 }
1648 1626
1649 port_number = TIUMP_GET_PORT_FROM_CODE(data[0]); 1627 port_number = TIUMP_GET_PORT_FROM_CODE(data[0]);
1650 function = TIUMP_GET_FUNC_FROM_CODE(data[0]); 1628 function = TIUMP_GET_FUNC_FROM_CODE(data[0]);
1651 dbg("%s - port_number %d, function %d, info 0x%x", 1629 dev_dbg(dev, "%s - port_number %d, function %d, info 0x%x\n", __func__,
1652 __func__, port_number, function, data[1]); 1630 port_number, function, data[1]);
1653 port = edge_serial->serial->port[port_number]; 1631 port = edge_serial->serial->port[port_number];
1654 edge_port = usb_get_serial_port_data(port); 1632 edge_port = usb_get_serial_port_data(port);
1655 if (!edge_port) { 1633 if (!edge_port) {
1656 dbg("%s - edge_port not found", __func__); 1634 dev_dbg(dev, "%s - edge_port not found\n", __func__);
1657 return; 1635 return;
1658 } 1636 }
1659 switch (function) { 1637 switch (function) {
@@ -1662,13 +1640,13 @@ static void edge_interrupt_callback(struct urb *urb)
1662 if (lsr & UMP_UART_LSR_DATA_MASK) { 1640 if (lsr & UMP_UART_LSR_DATA_MASK) {
1663 /* Save the LSR event for bulk read 1641 /* Save the LSR event for bulk read
1664 completion routine */ 1642 completion routine */
1665 dbg("%s - LSR Event Port %u LSR Status = %02x", 1643 dev_dbg(dev, "%s - LSR Event Port %u LSR Status = %02x\n",
1666 __func__, port_number, lsr); 1644 __func__, port_number, lsr);
1667 edge_port->lsr_event = 1; 1645 edge_port->lsr_event = 1;
1668 edge_port->lsr_mask = lsr; 1646 edge_port->lsr_mask = lsr;
1669 } else { 1647 } else {
1670 dbg("%s - ===== Port %d LSR Status = %02x ======", 1648 dev_dbg(dev, "%s - ===== Port %d LSR Status = %02x ======\n",
1671 __func__, port_number, lsr); 1649 __func__, port_number, lsr);
1672 handle_new_lsr(edge_port, 0, lsr, 0); 1650 handle_new_lsr(edge_port, 0, lsr, 0);
1673 } 1651 }
1674 break; 1652 break;
@@ -1676,8 +1654,8 @@ static void edge_interrupt_callback(struct urb *urb)
1676 case TIUMP_INTERRUPT_CODE_MSR: /* MSR */ 1654 case TIUMP_INTERRUPT_CODE_MSR: /* MSR */
1677 /* Copy MSR from UMP */ 1655 /* Copy MSR from UMP */
1678 msr = data[1]; 1656 msr = data[1];
1679 dbg("%s - ===== Port %u MSR Status = %02x ======", 1657 dev_dbg(dev, "%s - ===== Port %u MSR Status = %02x ======\n",
1680 __func__, port_number, msr); 1658 __func__, port_number, msr);
1681 handle_new_msr(edge_port, msr); 1659 handle_new_msr(edge_port, msr);
1682 break; 1660 break;
1683 1661
@@ -1700,14 +1678,13 @@ exit:
1700static void edge_bulk_in_callback(struct urb *urb) 1678static void edge_bulk_in_callback(struct urb *urb)
1701{ 1679{
1702 struct edgeport_port *edge_port = urb->context; 1680 struct edgeport_port *edge_port = urb->context;
1681 struct device *dev = &edge_port->port->dev;
1703 unsigned char *data = urb->transfer_buffer; 1682 unsigned char *data = urb->transfer_buffer;
1704 struct tty_struct *tty; 1683 struct tty_struct *tty;
1705 int retval = 0; 1684 int retval = 0;
1706 int port_number; 1685 int port_number;
1707 int status = urb->status; 1686 int status = urb->status;
1708 1687
1709 dbg("%s", __func__);
1710
1711 switch (status) { 1688 switch (status) {
1712 case 0: 1689 case 0:
1713 /* success */ 1690 /* success */
@@ -1716,13 +1693,10 @@ static void edge_bulk_in_callback(struct urb *urb)
1716 case -ENOENT: 1693 case -ENOENT:
1717 case -ESHUTDOWN: 1694 case -ESHUTDOWN:
1718 /* this urb is terminated, clean up */ 1695 /* this urb is terminated, clean up */
1719 dbg("%s - urb shutting down with status: %d", 1696 dev_dbg(&urb->dev->dev, "%s - urb shutting down with status: %d\n", __func__, status);
1720 __func__, status);
1721 return; 1697 return;
1722 default: 1698 default:
1723 dev_err(&urb->dev->dev, 1699 dev_err(&urb->dev->dev, "%s - nonzero read bulk status received: %d\n", __func__, status);
1724 "%s - nonzero read bulk status received: %d\n",
1725 __func__, status);
1726 } 1700 }
1727 1701
1728 if (status == -EPIPE) 1702 if (status == -EPIPE)
@@ -1737,8 +1711,8 @@ static void edge_bulk_in_callback(struct urb *urb)
1737 1711
1738 if (edge_port->lsr_event) { 1712 if (edge_port->lsr_event) {
1739 edge_port->lsr_event = 0; 1713 edge_port->lsr_event = 0;
1740 dbg("%s ===== Port %u LSR Status = %02x, Data = %02x ======", 1714 dev_dbg(dev, "%s ===== Port %u LSR Status = %02x, Data = %02x ======\n",
1741 __func__, port_number, edge_port->lsr_mask, *data); 1715 __func__, port_number, edge_port->lsr_mask, *data);
1742 handle_new_lsr(edge_port, 1, edge_port->lsr_mask, *data); 1716 handle_new_lsr(edge_port, 1, edge_port->lsr_mask, *data);
1743 /* Adjust buffer length/pointer */ 1717 /* Adjust buffer length/pointer */
1744 --urb->actual_length; 1718 --urb->actual_length;
@@ -1747,14 +1721,12 @@ static void edge_bulk_in_callback(struct urb *urb)
1747 1721
1748 tty = tty_port_tty_get(&edge_port->port->port); 1722 tty = tty_port_tty_get(&edge_port->port->port);
1749 if (tty && urb->actual_length) { 1723 if (tty && urb->actual_length) {
1750 usb_serial_debug_data(debug, &edge_port->port->dev, 1724 usb_serial_debug_data(dev, __func__, urb->actual_length, data);
1751 __func__, urb->actual_length, data);
1752 if (edge_port->close_pending) 1725 if (edge_port->close_pending)
1753 dbg("%s - close pending, dropping data on the floor", 1726 dev_dbg(dev, "%s - close pending, dropping data on the floor\n",
1754 __func__); 1727 __func__);
1755 else 1728 else
1756 edge_tty_recv(&edge_port->port->dev, tty, data, 1729 edge_tty_recv(dev, tty, data, urb->actual_length);
1757 urb->actual_length);
1758 edge_port->icount.rx += urb->actual_length; 1730 edge_port->icount.rx += urb->actual_length;
1759 } 1731 }
1760 tty_kref_put(tty); 1732 tty_kref_put(tty);
@@ -1769,9 +1741,7 @@ exit:
1769 1741
1770 spin_unlock(&edge_port->ep_lock); 1742 spin_unlock(&edge_port->ep_lock);
1771 if (retval) 1743 if (retval)
1772 dev_err(&urb->dev->dev, 1744 dev_err(dev, "%s - usb_submit_urb failed with result %d\n", __func__, retval);
1773 "%s - usb_submit_urb failed with result %d\n",
1774 __func__, retval);
1775} 1745}
1776 1746
1777static void edge_tty_recv(struct device *dev, struct tty_struct *tty, 1747static void edge_tty_recv(struct device *dev, struct tty_struct *tty,
@@ -1793,8 +1763,6 @@ static void edge_bulk_out_callback(struct urb *urb)
1793 int status = urb->status; 1763 int status = urb->status;
1794 struct tty_struct *tty; 1764 struct tty_struct *tty;
1795 1765
1796 dbg("%s - port %d", __func__, port->number);
1797
1798 edge_port->ep_write_urb_in_use = 0; 1766 edge_port->ep_write_urb_in_use = 0;
1799 1767
1800 switch (status) { 1768 switch (status) {
@@ -1805,7 +1773,7 @@ static void edge_bulk_out_callback(struct urb *urb)
1805 case -ENOENT: 1773 case -ENOENT:
1806 case -ESHUTDOWN: 1774 case -ESHUTDOWN:
1807 /* this urb is terminated, clean up */ 1775 /* this urb is terminated, clean up */
1808 dbg("%s - urb shutting down with status: %d", 1776 dev_dbg(&urb->dev->dev, "%s - urb shutting down with status: %d\n",
1809 __func__, status); 1777 __func__, status);
1810 return; 1778 return;
1811 default: 1779 default:
@@ -1830,8 +1798,6 @@ static int edge_open(struct tty_struct *tty, struct usb_serial_port *port)
1830 u16 open_settings; 1798 u16 open_settings;
1831 u8 transaction_timeout; 1799 u8 transaction_timeout;
1832 1800
1833 dbg("%s - port %d", __func__, port->number);
1834
1835 if (edge_port == NULL) 1801 if (edge_port == NULL)
1836 return -ENODEV; 1802 return -ENODEV;
1837 1803
@@ -1850,9 +1816,8 @@ static int edge_open(struct tty_struct *tty, struct usb_serial_port *port)
1850 return -ENODEV; 1816 return -ENODEV;
1851 } 1817 }
1852 1818
1853 dbg("%s - port_number = %d, uart_base = %04x, dma_address = %04x", 1819 dev_dbg(&port->dev, "%s - port_number = %d, uart_base = %04x, dma_address = %04x\n",
1854 __func__, port_number, edge_port->uart_base, 1820 __func__, port_number, edge_port->uart_base, edge_port->dma_address);
1855 edge_port->dma_address);
1856 1821
1857 dev = port->serial->dev; 1822 dev = port->serial->dev;
1858 1823
@@ -1885,7 +1850,7 @@ static int edge_open(struct tty_struct *tty, struct usb_serial_port *port)
1885 UMP_PIPE_TRANS_TIMEOUT_ENA | 1850 UMP_PIPE_TRANS_TIMEOUT_ENA |
1886 (transaction_timeout << 2)); 1851 (transaction_timeout << 2));
1887 1852
1888 dbg("%s - Sending UMPC_OPEN_PORT", __func__); 1853 dev_dbg(&port->dev, "%s - Sending UMPC_OPEN_PORT\n", __func__);
1889 1854
1890 /* Tell TI to open and start the port */ 1855 /* Tell TI to open and start the port */
1891 status = send_cmd(dev, UMPC_OPEN_PORT, 1856 status = send_cmd(dev, UMPC_OPEN_PORT,
@@ -1924,11 +1889,11 @@ static int edge_open(struct tty_struct *tty, struct usb_serial_port *port)
1924 return status; 1889 return status;
1925 } 1890 }
1926 1891
1927 dbg("ShadowMSR 0x%X", edge_port->shadow_msr); 1892 dev_dbg(&port->dev, "ShadowMSR 0x%X\n", edge_port->shadow_msr);
1928 1893
1929 /* Set Initial MCR */ 1894 /* Set Initial MCR */
1930 edge_port->shadow_mcr = MCR_RTS | MCR_DTR; 1895 edge_port->shadow_mcr = MCR_RTS | MCR_DTR;
1931 dbg("ShadowMCR 0x%X", edge_port->shadow_mcr); 1896 dev_dbg(&port->dev, "ShadowMCR 0x%X\n", edge_port->shadow_mcr);
1932 1897
1933 edge_serial = edge_port->edge_serial; 1898 edge_serial = edge_port->edge_serial;
1934 if (mutex_lock_interruptible(&edge_serial->es_lock)) 1899 if (mutex_lock_interruptible(&edge_serial->es_lock))
@@ -1980,8 +1945,6 @@ static int edge_open(struct tty_struct *tty, struct usb_serial_port *port)
1980 1945
1981 ++edge_serial->num_ports_open; 1946 ++edge_serial->num_ports_open;
1982 1947
1983 dbg("%s - exited", __func__);
1984
1985 goto release_es_lock; 1948 goto release_es_lock;
1986 1949
1987unlink_int_urb: 1950unlink_int_urb:
@@ -1999,8 +1962,6 @@ static void edge_close(struct usb_serial_port *port)
1999 struct usb_serial *serial = port->serial; 1962 struct usb_serial *serial = port->serial;
2000 int port_number; 1963 int port_number;
2001 1964
2002 dbg("%s - port %d", __func__, port->number);
2003
2004 edge_serial = usb_get_serial_data(port->serial); 1965 edge_serial = usb_get_serial_data(port->serial);
2005 edge_port = usb_get_serial_port_data(port); 1966 edge_port = usb_get_serial_port_data(port);
2006 if (edge_serial == NULL || edge_port == NULL) 1967 if (edge_serial == NULL || edge_port == NULL)
@@ -2019,7 +1980,7 @@ static void edge_close(struct usb_serial_port *port)
2019 1980
2020 /* assuming we can still talk to the device, 1981 /* assuming we can still talk to the device,
2021 * send a close port command to it */ 1982 * send a close port command to it */
2022 dbg("%s - send umpc_close_port", __func__); 1983 dev_dbg(&port->dev, "%s - send umpc_close_port\n", __func__);
2023 port_number = port->number - port->serial->minor; 1984 port_number = port->number - port->serial->minor;
2024 1985
2025 mutex_lock(&serial->disc_mutex); 1986 mutex_lock(&serial->disc_mutex);
@@ -2042,8 +2003,6 @@ static void edge_close(struct usb_serial_port *port)
2042 } 2003 }
2043 mutex_unlock(&edge_serial->es_lock); 2004 mutex_unlock(&edge_serial->es_lock);
2044 edge_port->close_pending = 0; 2005 edge_port->close_pending = 0;
2045
2046 dbg("%s - exited", __func__);
2047} 2006}
2048 2007
2049static int edge_write(struct tty_struct *tty, struct usb_serial_port *port, 2008static int edge_write(struct tty_struct *tty, struct usb_serial_port *port,
@@ -2051,10 +2010,8 @@ static int edge_write(struct tty_struct *tty, struct usb_serial_port *port,
2051{ 2010{
2052 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 2011 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
2053 2012
2054 dbg("%s - port %d", __func__, port->number);
2055
2056 if (count == 0) { 2013 if (count == 0) {
2057 dbg("%s - write request of 0 bytes", __func__); 2014 dev_dbg(&port->dev, "%s - write request of 0 bytes\n", __func__);
2058 return 0; 2015 return 0;
2059 } 2016 }
2060 2017
@@ -2077,9 +2034,6 @@ static void edge_send(struct tty_struct *tty)
2077 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 2034 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
2078 unsigned long flags; 2035 unsigned long flags;
2079 2036
2080
2081 dbg("%s - port %d", __func__, port->number);
2082
2083 spin_lock_irqsave(&edge_port->ep_lock, flags); 2037 spin_lock_irqsave(&edge_port->ep_lock, flags);
2084 2038
2085 if (edge_port->ep_write_urb_in_use) { 2039 if (edge_port->ep_write_urb_in_use) {
@@ -2100,8 +2054,7 @@ static void edge_send(struct tty_struct *tty)
2100 2054
2101 spin_unlock_irqrestore(&edge_port->ep_lock, flags); 2055 spin_unlock_irqrestore(&edge_port->ep_lock, flags);
2102 2056
2103 usb_serial_debug_data(debug, &port->dev, __func__, count, 2057 usb_serial_debug_data(&port->dev, __func__, count, port->write_urb->transfer_buffer);
2104 port->write_urb->transfer_buffer);
2105 2058
2106 /* set up our urb */ 2059 /* set up our urb */
2107 port->write_urb->transfer_buffer_length = count; 2060 port->write_urb->transfer_buffer_length = count;
@@ -2130,8 +2083,6 @@ static int edge_write_room(struct tty_struct *tty)
2130 int room = 0; 2083 int room = 0;
2131 unsigned long flags; 2084 unsigned long flags;
2132 2085
2133 dbg("%s - port %d", __func__, port->number);
2134
2135 if (edge_port == NULL) 2086 if (edge_port == NULL)
2136 return 0; 2087 return 0;
2137 if (edge_port->close_pending == 1) 2088 if (edge_port->close_pending == 1)
@@ -2141,7 +2092,7 @@ static int edge_write_room(struct tty_struct *tty)
2141 room = kfifo_avail(&edge_port->write_fifo); 2092 room = kfifo_avail(&edge_port->write_fifo);
2142 spin_unlock_irqrestore(&edge_port->ep_lock, flags); 2093 spin_unlock_irqrestore(&edge_port->ep_lock, flags);
2143 2094
2144 dbg("%s - returns %d", __func__, room); 2095 dev_dbg(&port->dev, "%s - returns %d\n", __func__, room);
2145 return room; 2096 return room;
2146} 2097}
2147 2098
@@ -2152,8 +2103,6 @@ static int edge_chars_in_buffer(struct tty_struct *tty)
2152 int chars = 0; 2103 int chars = 0;
2153 unsigned long flags; 2104 unsigned long flags;
2154 2105
2155 dbg("%s - port %d", __func__, port->number);
2156
2157 if (edge_port == NULL) 2106 if (edge_port == NULL)
2158 return 0; 2107 return 0;
2159 if (edge_port->close_pending == 1) 2108 if (edge_port->close_pending == 1)
@@ -2163,7 +2112,7 @@ static int edge_chars_in_buffer(struct tty_struct *tty)
2163 chars = kfifo_len(&edge_port->write_fifo); 2112 chars = kfifo_len(&edge_port->write_fifo);
2164 spin_unlock_irqrestore(&edge_port->ep_lock, flags); 2113 spin_unlock_irqrestore(&edge_port->ep_lock, flags);
2165 2114
2166 dbg("%s - returns %d", __func__, chars); 2115 dev_dbg(&port->dev, "%s - returns %d\n", __func__, chars);
2167 return chars; 2116 return chars;
2168} 2117}
2169 2118
@@ -2173,8 +2122,6 @@ static void edge_throttle(struct tty_struct *tty)
2173 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 2122 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
2174 int status; 2123 int status;
2175 2124
2176 dbg("%s - port %d", __func__, port->number);
2177
2178 if (edge_port == NULL) 2125 if (edge_port == NULL)
2179 return; 2126 return;
2180 2127
@@ -2200,8 +2147,6 @@ static void edge_unthrottle(struct tty_struct *tty)
2200 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 2147 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
2201 int status; 2148 int status;
2202 2149
2203 dbg("%s - port %d", __func__, port->number);
2204
2205 if (edge_port == NULL) 2150 if (edge_port == NULL)
2206 return; 2151 return;
2207 2152
@@ -2261,6 +2206,7 @@ static int restart_read(struct edgeport_port *edge_port)
2261static void change_port_settings(struct tty_struct *tty, 2206static void change_port_settings(struct tty_struct *tty,
2262 struct edgeport_port *edge_port, struct ktermios *old_termios) 2207 struct edgeport_port *edge_port, struct ktermios *old_termios)
2263{ 2208{
2209 struct device *dev = &edge_port->port->dev;
2264 struct ump_uart_config *config; 2210 struct ump_uart_config *config;
2265 int baud; 2211 int baud;
2266 unsigned cflag; 2212 unsigned cflag;
@@ -2268,13 +2214,12 @@ static void change_port_settings(struct tty_struct *tty,
2268 int port_number = edge_port->port->number - 2214 int port_number = edge_port->port->number -
2269 edge_port->port->serial->minor; 2215 edge_port->port->serial->minor;
2270 2216
2271 dbg("%s - port %d", __func__, edge_port->port->number); 2217 dev_dbg(dev, "%s - port %d\n", __func__, edge_port->port->number);
2272 2218
2273 config = kmalloc (sizeof (*config), GFP_KERNEL); 2219 config = kmalloc (sizeof (*config), GFP_KERNEL);
2274 if (!config) { 2220 if (!config) {
2275 tty->termios = *old_termios; 2221 tty->termios = *old_termios;
2276 dev_err(&edge_port->port->dev, "%s - out of memory\n", 2222 dev_err(dev, "%s - out of memory\n", __func__);
2277 __func__);
2278 return; 2223 return;
2279 } 2224 }
2280 2225
@@ -2290,20 +2235,20 @@ static void change_port_settings(struct tty_struct *tty,
2290 switch (cflag & CSIZE) { 2235 switch (cflag & CSIZE) {
2291 case CS5: 2236 case CS5:
2292 config->bDataBits = UMP_UART_CHAR5BITS; 2237 config->bDataBits = UMP_UART_CHAR5BITS;
2293 dbg("%s - data bits = 5", __func__); 2238 dev_dbg(dev, "%s - data bits = 5\n", __func__);
2294 break; 2239 break;
2295 case CS6: 2240 case CS6:
2296 config->bDataBits = UMP_UART_CHAR6BITS; 2241 config->bDataBits = UMP_UART_CHAR6BITS;
2297 dbg("%s - data bits = 6", __func__); 2242 dev_dbg(dev, "%s - data bits = 6\n", __func__);
2298 break; 2243 break;
2299 case CS7: 2244 case CS7:
2300 config->bDataBits = UMP_UART_CHAR7BITS; 2245 config->bDataBits = UMP_UART_CHAR7BITS;
2301 dbg("%s - data bits = 7", __func__); 2246 dev_dbg(dev, "%s - data bits = 7\n", __func__);
2302 break; 2247 break;
2303 default: 2248 default:
2304 case CS8: 2249 case CS8:
2305 config->bDataBits = UMP_UART_CHAR8BITS; 2250 config->bDataBits = UMP_UART_CHAR8BITS;
2306 dbg("%s - data bits = 8", __func__); 2251 dev_dbg(dev, "%s - data bits = 8\n", __func__);
2307 break; 2252 break;
2308 } 2253 }
2309 2254
@@ -2311,32 +2256,32 @@ static void change_port_settings(struct tty_struct *tty,
2311 if (cflag & PARODD) { 2256 if (cflag & PARODD) {
2312 config->wFlags |= UMP_MASK_UART_FLAGS_PARITY; 2257 config->wFlags |= UMP_MASK_UART_FLAGS_PARITY;
2313 config->bParity = UMP_UART_ODDPARITY; 2258 config->bParity = UMP_UART_ODDPARITY;
2314 dbg("%s - parity = odd", __func__); 2259 dev_dbg(dev, "%s - parity = odd\n", __func__);
2315 } else { 2260 } else {
2316 config->wFlags |= UMP_MASK_UART_FLAGS_PARITY; 2261 config->wFlags |= UMP_MASK_UART_FLAGS_PARITY;
2317 config->bParity = UMP_UART_EVENPARITY; 2262 config->bParity = UMP_UART_EVENPARITY;
2318 dbg("%s - parity = even", __func__); 2263 dev_dbg(dev, "%s - parity = even\n", __func__);
2319 } 2264 }
2320 } else { 2265 } else {
2321 config->bParity = UMP_UART_NOPARITY; 2266 config->bParity = UMP_UART_NOPARITY;
2322 dbg("%s - parity = none", __func__); 2267 dev_dbg(dev, "%s - parity = none\n", __func__);
2323 } 2268 }
2324 2269
2325 if (cflag & CSTOPB) { 2270 if (cflag & CSTOPB) {
2326 config->bStopBits = UMP_UART_STOPBIT2; 2271 config->bStopBits = UMP_UART_STOPBIT2;
2327 dbg("%s - stop bits = 2", __func__); 2272 dev_dbg(dev, "%s - stop bits = 2\n", __func__);
2328 } else { 2273 } else {
2329 config->bStopBits = UMP_UART_STOPBIT1; 2274 config->bStopBits = UMP_UART_STOPBIT1;
2330 dbg("%s - stop bits = 1", __func__); 2275 dev_dbg(dev, "%s - stop bits = 1\n", __func__);
2331 } 2276 }
2332 2277
2333 /* figure out the flow control settings */ 2278 /* figure out the flow control settings */
2334 if (cflag & CRTSCTS) { 2279 if (cflag & CRTSCTS) {
2335 config->wFlags |= UMP_MASK_UART_FLAGS_OUT_X_CTS_FLOW; 2280 config->wFlags |= UMP_MASK_UART_FLAGS_OUT_X_CTS_FLOW;
2336 config->wFlags |= UMP_MASK_UART_FLAGS_RTS_FLOW; 2281 config->wFlags |= UMP_MASK_UART_FLAGS_RTS_FLOW;
2337 dbg("%s - RTS/CTS is enabled", __func__); 2282 dev_dbg(dev, "%s - RTS/CTS is enabled\n", __func__);
2338 } else { 2283 } else {
2339 dbg("%s - RTS/CTS is disabled", __func__); 2284 dev_dbg(dev, "%s - RTS/CTS is disabled\n", __func__);
2340 tty->hw_stopped = 0; 2285 tty->hw_stopped = 0;
2341 restart_read(edge_port); 2286 restart_read(edge_port);
2342 } 2287 }
@@ -2349,18 +2294,18 @@ static void change_port_settings(struct tty_struct *tty,
2349 /* if we are implementing INBOUND XON/XOFF */ 2294 /* if we are implementing INBOUND XON/XOFF */
2350 if (I_IXOFF(tty)) { 2295 if (I_IXOFF(tty)) {
2351 config->wFlags |= UMP_MASK_UART_FLAGS_IN_X; 2296 config->wFlags |= UMP_MASK_UART_FLAGS_IN_X;
2352 dbg("%s - INBOUND XON/XOFF is enabled, XON = %2x, XOFF = %2x", 2297 dev_dbg(dev, "%s - INBOUND XON/XOFF is enabled, XON = %2x, XOFF = %2x\n",
2353 __func__, config->cXon, config->cXoff); 2298 __func__, config->cXon, config->cXoff);
2354 } else 2299 } else
2355 dbg("%s - INBOUND XON/XOFF is disabled", __func__); 2300 dev_dbg(dev, "%s - INBOUND XON/XOFF is disabled\n", __func__);
2356 2301
2357 /* if we are implementing OUTBOUND XON/XOFF */ 2302 /* if we are implementing OUTBOUND XON/XOFF */
2358 if (I_IXON(tty)) { 2303 if (I_IXON(tty)) {
2359 config->wFlags |= UMP_MASK_UART_FLAGS_OUT_X; 2304 config->wFlags |= UMP_MASK_UART_FLAGS_OUT_X;
2360 dbg("%s - OUTBOUND XON/XOFF is enabled, XON = %2x, XOFF = %2x", 2305 dev_dbg(dev, "%s - OUTBOUND XON/XOFF is enabled, XON = %2x, XOFF = %2x\n",
2361 __func__, config->cXon, config->cXoff); 2306 __func__, config->cXon, config->cXoff);
2362 } else 2307 } else
2363 dbg("%s - OUTBOUND XON/XOFF is disabled", __func__); 2308 dev_dbg(dev, "%s - OUTBOUND XON/XOFF is disabled\n", __func__);
2364 2309
2365 tty->termios.c_cflag &= ~CMSPAR; 2310 tty->termios.c_cflag &= ~CMSPAR;
2366 2311
@@ -2377,17 +2322,16 @@ static void change_port_settings(struct tty_struct *tty,
2377 2322
2378 /* FIXME: Recompute actual baud from divisor here */ 2323 /* FIXME: Recompute actual baud from divisor here */
2379 2324
2380 dbg("%s - baud rate = %d, wBaudRate = %d", __func__, baud, 2325 dev_dbg(dev, "%s - baud rate = %d, wBaudRate = %d\n", __func__, baud, config->wBaudRate);
2381 config->wBaudRate);
2382 2326
2383 dbg("wBaudRate: %d", (int)(461550L / config->wBaudRate)); 2327 dev_dbg(dev, "wBaudRate: %d\n", (int)(461550L / config->wBaudRate));
2384 dbg("wFlags: 0x%x", config->wFlags); 2328 dev_dbg(dev, "wFlags: 0x%x\n", config->wFlags);
2385 dbg("bDataBits: %d", config->bDataBits); 2329 dev_dbg(dev, "bDataBits: %d\n", config->bDataBits);
2386 dbg("bParity: %d", config->bParity); 2330 dev_dbg(dev, "bParity: %d\n", config->bParity);
2387 dbg("bStopBits: %d", config->bStopBits); 2331 dev_dbg(dev, "bStopBits: %d\n", config->bStopBits);
2388 dbg("cXon: %d", config->cXon); 2332 dev_dbg(dev, "cXon: %d\n", config->cXon);
2389 dbg("cXoff: %d", config->cXoff); 2333 dev_dbg(dev, "cXoff: %d\n", config->cXoff);
2390 dbg("bUartMode: %d", config->bUartMode); 2334 dev_dbg(dev, "bUartMode: %d\n", config->bUartMode);
2391 2335
2392 /* move the word values into big endian mode */ 2336 /* move the word values into big endian mode */
2393 cpu_to_be16s(&config->wFlags); 2337 cpu_to_be16s(&config->wFlags);
@@ -2397,8 +2341,8 @@ static void change_port_settings(struct tty_struct *tty,
2397 (__u8)(UMPM_UART1_PORT + port_number), 2341 (__u8)(UMPM_UART1_PORT + port_number),
2398 0, (__u8 *)config, sizeof(*config)); 2342 0, (__u8 *)config, sizeof(*config));
2399 if (status) 2343 if (status)
2400 dbg("%s - error %d when trying to write config to device", 2344 dev_dbg(dev, "%s - error %d when trying to write config to device\n",
2401 __func__, status); 2345 __func__, status);
2402 kfree(config); 2346 kfree(config);
2403} 2347}
2404 2348
@@ -2410,11 +2354,11 @@ static void edge_set_termios(struct tty_struct *tty,
2410 2354
2411 cflag = tty->termios.c_cflag; 2355 cflag = tty->termios.c_cflag;
2412 2356
2413 dbg("%s - clfag %08x iflag %08x", __func__, 2357 dev_dbg(&port->dev, "%s - clfag %08x iflag %08x\n", __func__,
2414 tty->termios.c_cflag, tty->termios.c_iflag); 2358 tty->termios.c_cflag, tty->termios.c_iflag);
2415 dbg("%s - old clfag %08x old iflag %08x", __func__, 2359 dev_dbg(&port->dev, "%s - old clfag %08x old iflag %08x\n", __func__,
2416 old_termios->c_cflag, old_termios->c_iflag); 2360 old_termios->c_cflag, old_termios->c_iflag);
2417 dbg("%s - port %d", __func__, port->number); 2361 dev_dbg(&port->dev, "%s - port %d\n", __func__, port->number);
2418 2362
2419 if (edge_port == NULL) 2363 if (edge_port == NULL)
2420 return; 2364 return;
@@ -2430,8 +2374,6 @@ static int edge_tiocmset(struct tty_struct *tty,
2430 unsigned int mcr; 2374 unsigned int mcr;
2431 unsigned long flags; 2375 unsigned long flags;
2432 2376
2433 dbg("%s - port %d", __func__, port->number);
2434
2435 spin_lock_irqsave(&edge_port->ep_lock, flags); 2377 spin_lock_irqsave(&edge_port->ep_lock, flags);
2436 mcr = edge_port->shadow_mcr; 2378 mcr = edge_port->shadow_mcr;
2437 if (set & TIOCM_RTS) 2379 if (set & TIOCM_RTS)
@@ -2464,8 +2406,6 @@ static int edge_tiocmget(struct tty_struct *tty)
2464 unsigned int mcr; 2406 unsigned int mcr;
2465 unsigned long flags; 2407 unsigned long flags;
2466 2408
2467 dbg("%s - port %d", __func__, port->number);
2468
2469 spin_lock_irqsave(&edge_port->ep_lock, flags); 2409 spin_lock_irqsave(&edge_port->ep_lock, flags);
2470 2410
2471 msr = edge_port->shadow_msr; 2411 msr = edge_port->shadow_msr;
@@ -2478,7 +2418,7 @@ static int edge_tiocmget(struct tty_struct *tty)
2478 | ((msr & EDGEPORT_MSR_DSR) ? TIOCM_DSR: 0); /* 0x100 */ 2418 | ((msr & EDGEPORT_MSR_DSR) ? TIOCM_DSR: 0); /* 0x100 */
2479 2419
2480 2420
2481 dbg("%s -- %x", __func__, result); 2421 dev_dbg(&port->dev, "%s -- %x\n", __func__, result);
2482 spin_unlock_irqrestore(&edge_port->ep_lock, flags); 2422 spin_unlock_irqrestore(&edge_port->ep_lock, flags);
2483 2423
2484 return result; 2424 return result;
@@ -2538,15 +2478,15 @@ static int edge_ioctl(struct tty_struct *tty,
2538 struct async_icount cnow; 2478 struct async_icount cnow;
2539 struct async_icount cprev; 2479 struct async_icount cprev;
2540 2480
2541 dbg("%s - port %d, cmd = 0x%x", __func__, port->number, cmd); 2481 dev_dbg(&port->dev, "%s - port %d, cmd = 0x%x\n", __func__, port->number, cmd);
2542 2482
2543 switch (cmd) { 2483 switch (cmd) {
2544 case TIOCGSERIAL: 2484 case TIOCGSERIAL:
2545 dbg("%s - (%d) TIOCGSERIAL", __func__, port->number); 2485 dev_dbg(&port->dev, "%s - TIOCGSERIAL\n", __func__);
2546 return get_serial_info(edge_port, 2486 return get_serial_info(edge_port,
2547 (struct serial_struct __user *) arg); 2487 (struct serial_struct __user *) arg);
2548 case TIOCMIWAIT: 2488 case TIOCMIWAIT:
2549 dbg("%s - (%d) TIOCMIWAIT", __func__, port->number); 2489 dev_dbg(&port->dev, "%s - TIOCMIWAIT\n", __func__);
2550 cprev = edge_port->icount; 2490 cprev = edge_port->icount;
2551 while (1) { 2491 while (1) {
2552 interruptible_sleep_on(&edge_port->delta_msr_wait); 2492 interruptible_sleep_on(&edge_port->delta_msr_wait);
@@ -2578,8 +2518,6 @@ static void edge_break(struct tty_struct *tty, int break_state)
2578 int status; 2518 int status;
2579 int bv = 0; /* Off */ 2519 int bv = 0; /* Off */
2580 2520
2581 dbg("%s - state = %d", __func__, break_state);
2582
2583 /* chase the port close */ 2521 /* chase the port close */
2584 chase_port(edge_port, 0, 0); 2522 chase_port(edge_port, 0, 0);
2585 2523
@@ -2587,8 +2525,8 @@ static void edge_break(struct tty_struct *tty, int break_state)
2587 bv = 1; /* On */ 2525 bv = 1; /* On */
2588 status = ti_do_config(edge_port, UMPC_SET_CLR_BREAK, bv); 2526 status = ti_do_config(edge_port, UMPC_SET_CLR_BREAK, bv);
2589 if (status) 2527 if (status)
2590 dbg("%s - error %d sending break set/clear command.", 2528 dev_dbg(&port->dev, "%s - error %d sending break set/clear command.\n",
2591 __func__, status); 2529 __func__, status);
2592} 2530}
2593 2531
2594static int edge_startup(struct usb_serial *serial) 2532static int edge_startup(struct usb_serial *serial)
@@ -2655,7 +2593,6 @@ cleanup:
2655 2593
2656static void edge_disconnect(struct usb_serial *serial) 2594static void edge_disconnect(struct usb_serial *serial)
2657{ 2595{
2658 dbg("%s", __func__);
2659} 2596}
2660 2597
2661static void edge_release(struct usb_serial *serial) 2598static void edge_release(struct usb_serial *serial)
@@ -2663,8 +2600,6 @@ static void edge_release(struct usb_serial *serial)
2663 int i; 2600 int i;
2664 struct edgeport_port *edge_port; 2601 struct edgeport_port *edge_port;
2665 2602
2666 dbg("%s", __func__);
2667
2668 for (i = 0; i < serial->num_ports; ++i) { 2603 for (i = 0; i < serial->num_ports; ++i) {
2669 edge_port = usb_get_serial_port_data(serial->port[i]); 2604 edge_port = usb_get_serial_port_data(serial->port[i]);
2670 kfifo_free(&edge_port->write_fifo); 2605 kfifo_free(&edge_port->write_fifo);
@@ -2692,7 +2627,7 @@ static ssize_t store_uart_mode(struct device *dev,
2692 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 2627 struct edgeport_port *edge_port = usb_get_serial_port_data(port);
2693 unsigned int v = simple_strtoul(valbuf, NULL, 0); 2628 unsigned int v = simple_strtoul(valbuf, NULL, 0);
2694 2629
2695 dbg("%s: setting uart_mode = %d", __func__, v); 2630 dev_dbg(dev, "%s: setting uart_mode = %d\n", __func__, v);
2696 2631
2697 if (v < 256) 2632 if (v < 256)
2698 edge_port->bUartMode = v; 2633 edge_port->bUartMode = v;
@@ -2789,9 +2724,6 @@ MODULE_DESCRIPTION(DRIVER_DESC);
2789MODULE_LICENSE("GPL"); 2724MODULE_LICENSE("GPL");
2790MODULE_FIRMWARE("edgeport/down3.bin"); 2725MODULE_FIRMWARE("edgeport/down3.bin");
2791 2726
2792module_param(debug, bool, S_IRUGO | S_IWUSR);
2793MODULE_PARM_DESC(debug, "Debug enabled or not");
2794
2795module_param(closing_wait, int, S_IRUGO | S_IWUSR); 2727module_param(closing_wait, int, S_IRUGO | S_IWUSR);
2796MODULE_PARM_DESC(closing_wait, "Maximum wait for data to drain, in .01 secs"); 2728MODULE_PARM_DESC(closing_wait, "Maximum wait for data to drain, in .01 secs");
2797 2729
diff --git a/drivers/usb/serial/ipaq.c b/drivers/usb/serial/ipaq.c
index c85a7eb87d4e..1068bf22e27e 100644
--- a/drivers/usb/serial/ipaq.c
+++ b/drivers/usb/serial/ipaq.c
@@ -33,7 +33,6 @@
33#define DRIVER_AUTHOR "Ganesh Varadarajan <ganesh@veritas.com>" 33#define DRIVER_AUTHOR "Ganesh Varadarajan <ganesh@veritas.com>"
34#define DRIVER_DESC "USB PocketPC PDA driver" 34#define DRIVER_DESC "USB PocketPC PDA driver"
35 35
36static bool debug;
37static int connect_retries = KP_RETRIES; 36static int connect_retries = KP_RETRIES;
38static int initial_wait; 37static int initial_wait;
39 38
@@ -616,9 +615,6 @@ MODULE_AUTHOR(DRIVER_AUTHOR);
616MODULE_DESCRIPTION(DRIVER_DESC); 615MODULE_DESCRIPTION(DRIVER_DESC);
617MODULE_LICENSE("GPL"); 616MODULE_LICENSE("GPL");
618 617
619module_param(debug, bool, S_IRUGO | S_IWUSR);
620MODULE_PARM_DESC(debug, "Debug enabled or not");
621
622module_param(connect_retries, int, S_IRUGO|S_IWUSR); 618module_param(connect_retries, int, S_IRUGO|S_IWUSR);
623MODULE_PARM_DESC(connect_retries, 619MODULE_PARM_DESC(connect_retries,
624 "Maximum number of connect retries (one second each)"); 620 "Maximum number of connect retries (one second each)");
diff --git a/drivers/usb/serial/ipw.c b/drivers/usb/serial/ipw.c
index 2cb30c535839..20a132ec39e2 100644
--- a/drivers/usb/serial/ipw.c
+++ b/drivers/usb/serial/ipw.c
@@ -138,11 +138,10 @@ static const struct usb_device_id id_table[] = {
138}; 138};
139MODULE_DEVICE_TABLE(usb, id_table); 139MODULE_DEVICE_TABLE(usb, id_table);
140 140
141static bool debug;
142
143static int ipw_open(struct tty_struct *tty, struct usb_serial_port *port) 141static int ipw_open(struct tty_struct *tty, struct usb_serial_port *port)
144{ 142{
145 struct usb_device *dev = port->serial->dev; 143 struct usb_device *udev = port->serial->dev;
144 struct device *dev = &port->dev;
146 u8 buf_flow_static[16] = IPW_BYTES_FLOWINIT; 145 u8 buf_flow_static[16] = IPW_BYTES_FLOWINIT;
147 u8 *buf_flow_init; 146 u8 *buf_flow_init;
148 int result; 147 int result;
@@ -154,8 +153,8 @@ static int ipw_open(struct tty_struct *tty, struct usb_serial_port *port)
154 /* --1: Tell the modem to initialize (we think) From sniffs this is 153 /* --1: Tell the modem to initialize (we think) From sniffs this is
155 * always the first thing that gets sent to the modem during 154 * always the first thing that gets sent to the modem during
156 * opening of the device */ 155 * opening of the device */
157 dbg("%s: Sending SIO_INIT (we guess)", __func__); 156 dev_dbg(dev, "%s: Sending SIO_INIT (we guess)\n", __func__);
158 result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 157 result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
159 IPW_SIO_INIT, 158 IPW_SIO_INIT,
160 USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT, 159 USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT,
161 0, 160 0,
@@ -164,22 +163,19 @@ static int ipw_open(struct tty_struct *tty, struct usb_serial_port *port)
164 0, 163 0,
165 100000); 164 100000);
166 if (result < 0) 165 if (result < 0)
167 dev_err(&port->dev, 166 dev_err(dev, "Init of modem failed (error = %d)\n", result);
168 "Init of modem failed (error = %d)\n", result);
169 167
170 /* reset the bulk pipes */ 168 /* reset the bulk pipes */
171 usb_clear_halt(dev, 169 usb_clear_halt(udev, usb_rcvbulkpipe(udev, port->bulk_in_endpointAddress));
172 usb_rcvbulkpipe(dev, port->bulk_in_endpointAddress)); 170 usb_clear_halt(udev, usb_sndbulkpipe(udev, port->bulk_out_endpointAddress));
173 usb_clear_halt(dev,
174 usb_sndbulkpipe(dev, port->bulk_out_endpointAddress));
175 171
176 /*--2: Start reading from the device */ 172 /*--2: Start reading from the device */
177 dbg("%s: setting up bulk read callback", __func__); 173 dev_dbg(dev, "%s: setting up bulk read callback\n", __func__);
178 usb_wwan_open(tty, port); 174 usb_wwan_open(tty, port);
179 175
180 /*--3: Tell the modem to open the floodgates on the rx bulk channel */ 176 /*--3: Tell the modem to open the floodgates on the rx bulk channel */
181 dbg("%s:asking modem for RxRead (RXBULK_ON)", __func__); 177 dev_dbg(dev, "%s:asking modem for RxRead (RXBULK_ON)\n", __func__);
182 result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 178 result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
183 IPW_SIO_RXCTL, 179 IPW_SIO_RXCTL,
184 USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT, 180 USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT,
185 IPW_RXBULK_ON, 181 IPW_RXBULK_ON,
@@ -188,12 +184,11 @@ static int ipw_open(struct tty_struct *tty, struct usb_serial_port *port)
188 0, 184 0,
189 100000); 185 100000);
190 if (result < 0) 186 if (result < 0)
191 dev_err(&port->dev, 187 dev_err(dev, "Enabling bulk RxRead failed (error = %d)\n", result);
192 "Enabling bulk RxRead failed (error = %d)\n", result);
193 188
194 /*--4: setup the initial flowcontrol */ 189 /*--4: setup the initial flowcontrol */
195 dbg("%s:setting init flowcontrol (%s)", __func__, buf_flow_init); 190 dev_dbg(dev, "%s:setting init flowcontrol (%s)\n", __func__, buf_flow_init);
196 result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 191 result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
197 IPW_SIO_HANDFLOW, 192 IPW_SIO_HANDFLOW,
198 USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT, 193 USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT,
199 0, 194 0,
@@ -202,8 +197,7 @@ static int ipw_open(struct tty_struct *tty, struct usb_serial_port *port)
202 0x10, 197 0x10,
203 200000); 198 200000);
204 if (result < 0) 199 if (result < 0)
205 dev_err(&port->dev, 200 dev_err(dev, "initial flowcontrol failed (error = %d)\n", result);
206 "initial flowcontrol failed (error = %d)\n", result);
207 201
208 kfree(buf_flow_init); 202 kfree(buf_flow_init);
209 return 0; 203 return 0;
@@ -233,12 +227,13 @@ static void ipw_release(struct usb_serial *serial)
233 227
234static void ipw_dtr_rts(struct usb_serial_port *port, int on) 228static void ipw_dtr_rts(struct usb_serial_port *port, int on)
235{ 229{
236 struct usb_device *dev = port->serial->dev; 230 struct usb_device *udev = port->serial->dev;
231 struct device *dev = &port->dev;
237 int result; 232 int result;
238 233
239 dbg("%s: on = %d", __func__, on); 234 dev_dbg(dev, "%s: on = %d\n", __func__, on);
240 235
241 result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 236 result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
242 IPW_SIO_SET_PIN, 237 IPW_SIO_SET_PIN,
243 USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT, 238 USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT,
244 on ? IPW_PIN_SETDTR : IPW_PIN_CLRDTR, 239 on ? IPW_PIN_SETDTR : IPW_PIN_CLRDTR,
@@ -247,10 +242,9 @@ static void ipw_dtr_rts(struct usb_serial_port *port, int on)
247 0, 242 0,
248 200000); 243 200000);
249 if (result < 0) 244 if (result < 0)
250 dev_err(&port->dev, "setting dtr failed (error = %d)\n", 245 dev_err(dev, "setting dtr failed (error = %d)\n", result);
251 result);
252 246
253 result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 247 result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
254 IPW_SIO_SET_PIN, USB_TYPE_VENDOR | 248 IPW_SIO_SET_PIN, USB_TYPE_VENDOR |
255 USB_RECIP_INTERFACE | USB_DIR_OUT, 249 USB_RECIP_INTERFACE | USB_DIR_OUT,
256 on ? IPW_PIN_SETRTS : IPW_PIN_CLRRTS, 250 on ? IPW_PIN_SETRTS : IPW_PIN_CLRRTS,
@@ -259,18 +253,18 @@ static void ipw_dtr_rts(struct usb_serial_port *port, int on)
259 0, 253 0,
260 200000); 254 200000);
261 if (result < 0) 255 if (result < 0)
262 dev_err(&port->dev, "setting rts failed (error = %d)\n", 256 dev_err(dev, "setting rts failed (error = %d)\n", result);
263 result);
264} 257}
265 258
266static void ipw_close(struct usb_serial_port *port) 259static void ipw_close(struct usb_serial_port *port)
267{ 260{
268 struct usb_device *dev = port->serial->dev; 261 struct usb_device *udev = port->serial->dev;
262 struct device *dev = &port->dev;
269 int result; 263 int result;
270 264
271 /*--3: purge */ 265 /*--3: purge */
272 dbg("%s:sending purge", __func__); 266 dev_dbg(dev, "%s:sending purge\n", __func__);
273 result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 267 result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
274 IPW_SIO_PURGE, USB_TYPE_VENDOR | 268 IPW_SIO_PURGE, USB_TYPE_VENDOR |
275 USB_RECIP_INTERFACE | USB_DIR_OUT, 269 USB_RECIP_INTERFACE | USB_DIR_OUT,
276 0x03, 270 0x03,
@@ -279,12 +273,12 @@ static void ipw_close(struct usb_serial_port *port)
279 0, 273 0,
280 200000); 274 200000);
281 if (result < 0) 275 if (result < 0)
282 dev_err(&port->dev, "purge failed (error = %d)\n", result); 276 dev_err(dev, "purge failed (error = %d)\n", result);
283 277
284 278
285 /* send RXBULK_off (tell modem to stop transmitting bulk data on 279 /* send RXBULK_off (tell modem to stop transmitting bulk data on
286 rx chan) */ 280 rx chan) */
287 result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 281 result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
288 IPW_SIO_RXCTL, 282 IPW_SIO_RXCTL,
289 USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT, 283 USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT,
290 IPW_RXBULK_OFF, 284 IPW_RXBULK_OFF,
@@ -294,8 +288,7 @@ static void ipw_close(struct usb_serial_port *port)
294 100000); 288 100000);
295 289
296 if (result < 0) 290 if (result < 0)
297 dev_err(&port->dev, 291 dev_err(dev, "Disabling bulk RxRead failed (error = %d)\n", result);
298 "Disabling bulk RxRead failed (error = %d)\n", result);
299 292
300 usb_wwan_close(port); 293 usb_wwan_close(port);
301} 294}
@@ -328,6 +321,3 @@ module_usb_serial_driver(serial_drivers, id_table);
328MODULE_AUTHOR(DRIVER_AUTHOR); 321MODULE_AUTHOR(DRIVER_AUTHOR);
329MODULE_DESCRIPTION(DRIVER_DESC); 322MODULE_DESCRIPTION(DRIVER_DESC);
330MODULE_LICENSE("GPL"); 323MODULE_LICENSE("GPL");
331
332module_param(debug, bool, S_IRUGO | S_IWUSR);
333MODULE_PARM_DESC(debug, "Debug enabled or not");
diff --git a/drivers/usb/serial/ir-usb.c b/drivers/usb/serial/ir-usb.c
index 5a96692b12a2..e24e2d4f4c1b 100644
--- a/drivers/usb/serial/ir-usb.c
+++ b/drivers/usb/serial/ir-usb.c
@@ -38,15 +38,9 @@
38#include <linux/usb/serial.h> 38#include <linux/usb/serial.h>
39#include <linux/usb/irda.h> 39#include <linux/usb/irda.h>
40 40
41/*
42 * Version Information
43 */
44#define DRIVER_VERSION "v0.5"
45#define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com>, Johan Hovold <jhovold@gmail.com>" 41#define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com>, Johan Hovold <jhovold@gmail.com>"
46#define DRIVER_DESC "USB IR Dongle driver" 42#define DRIVER_DESC "USB IR Dongle driver"
47 43
48static bool debug;
49
50/* if overridden by the user, then use their value for the size of the read and 44/* if overridden by the user, then use their value for the size of the read and
51 * write urbs */ 45 * write urbs */
52static int buffer_size; 46static int buffer_size;
@@ -430,18 +424,12 @@ err_buf:
430 424
431static int __init ir_init(void) 425static int __init ir_init(void)
432{ 426{
433 int retval;
434
435 if (buffer_size) { 427 if (buffer_size) {
436 ir_device.bulk_in_size = buffer_size; 428 ir_device.bulk_in_size = buffer_size;
437 ir_device.bulk_out_size = buffer_size; 429 ir_device.bulk_out_size = buffer_size;
438 } 430 }
439 431
440 retval = usb_serial_register_drivers(serial_drivers, KBUILD_MODNAME, ir_id_table); 432 return usb_serial_register_drivers(serial_drivers, KBUILD_MODNAME, ir_id_table);
441 if (retval == 0)
442 printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":"
443 DRIVER_DESC "\n");
444 return retval;
445} 433}
446 434
447static void __exit ir_exit(void) 435static void __exit ir_exit(void)
@@ -457,8 +445,6 @@ MODULE_AUTHOR(DRIVER_AUTHOR);
457MODULE_DESCRIPTION(DRIVER_DESC); 445MODULE_DESCRIPTION(DRIVER_DESC);
458MODULE_LICENSE("GPL"); 446MODULE_LICENSE("GPL");
459 447
460module_param(debug, bool, S_IRUGO | S_IWUSR);
461MODULE_PARM_DESC(debug, "Debug enabled or not");
462module_param(xbof, int, 0); 448module_param(xbof, int, 0);
463MODULE_PARM_DESC(xbof, "Force specific number of XBOFs"); 449MODULE_PARM_DESC(xbof, "Force specific number of XBOFs");
464module_param(buffer_size, int, 0); 450module_param(buffer_size, int, 0);
diff --git a/drivers/usb/serial/iuu_phoenix.c b/drivers/usb/serial/iuu_phoenix.c
index bf3864045c18..01da3ea36e89 100644
--- a/drivers/usb/serial/iuu_phoenix.c
+++ b/drivers/usb/serial/iuu_phoenix.c
@@ -32,13 +32,6 @@
32#include "iuu_phoenix.h" 32#include "iuu_phoenix.h"
33#include <linux/random.h> 33#include <linux/random.h>
34 34
35
36#ifdef CONFIG_USB_SERIAL_DEBUG
37static bool debug = 1;
38#else
39static bool debug;
40#endif
41
42/* 35/*
43 * Version Information 36 * Version Information
44 */ 37 */
@@ -72,7 +65,6 @@ struct iuu_private {
72 u8 *writebuf; /* buffer for writing to device */ 65 u8 *writebuf; /* buffer for writing to device */
73 int writelen; /* num of byte to write to device */ 66 int writelen; /* num of byte to write to device */
74 u8 *buf; /* used for initialize speed */ 67 u8 *buf; /* used for initialize speed */
75 u8 *dbgbuf; /* debug buffer */
76 u8 len; 68 u8 len;
77 int vcc; /* vcc (either 3 or 5 V) */ 69 int vcc; /* vcc (either 3 or 5 V) */
78 u32 baud; 70 u32 baud;
@@ -84,32 +76,31 @@ struct iuu_private {
84static void iuu_free_buf(struct iuu_private *priv) 76static void iuu_free_buf(struct iuu_private *priv)
85{ 77{
86 kfree(priv->buf); 78 kfree(priv->buf);
87 kfree(priv->dbgbuf);
88 kfree(priv->writebuf); 79 kfree(priv->writebuf);
89} 80}
90 81
91static int iuu_alloc_buf(struct iuu_private *priv) 82static int iuu_alloc_buf(struct usb_serial *serial, struct iuu_private *priv)
92{ 83{
93 priv->buf = kzalloc(256, GFP_KERNEL); 84 priv->buf = kzalloc(256, GFP_KERNEL);
94 priv->dbgbuf = kzalloc(256, GFP_KERNEL);
95 priv->writebuf = kzalloc(256, GFP_KERNEL); 85 priv->writebuf = kzalloc(256, GFP_KERNEL);
96 if (!priv->buf || !priv->dbgbuf || !priv->writebuf) { 86 if (!priv->buf || !priv->writebuf) {
97 iuu_free_buf(priv); 87 iuu_free_buf(priv);
98 dbg("%s problem allocation buffer", __func__); 88 dev_dbg(&serial->dev->dev, "%s problem allocation buffer\n", __func__);
99 return -ENOMEM; 89 return -ENOMEM;
100 } 90 }
101 dbg("%s - Privates buffers allocation success", __func__); 91 dev_dbg(&serial->dev->dev, "%s - Privates buffers allocation success\n", __func__);
102 return 0; 92 return 0;
103} 93}
104 94
105static int iuu_startup(struct usb_serial *serial) 95static int iuu_startup(struct usb_serial *serial)
106{ 96{
107 struct iuu_private *priv; 97 struct iuu_private *priv;
98
108 priv = kzalloc(sizeof(struct iuu_private), GFP_KERNEL); 99 priv = kzalloc(sizeof(struct iuu_private), GFP_KERNEL);
109 dbg("%s- priv allocation success", __func__); 100 dev_dbg(&serial->dev->dev, "%s- priv allocation success\n", __func__);
110 if (!priv) 101 if (!priv)
111 return -ENOMEM; 102 return -ENOMEM;
112 if (iuu_alloc_buf(priv)) { 103 if (iuu_alloc_buf(serial, priv)) {
113 kfree(priv); 104 kfree(priv);
114 return -ENOMEM; 105 return -ENOMEM;
115 } 106 }
@@ -130,13 +121,13 @@ static void iuu_release(struct usb_serial *serial)
130 121
131 if (priv) { 122 if (priv) {
132 iuu_free_buf(priv); 123 iuu_free_buf(priv);
133 dbg("%s - I will free all", __func__); 124 dev_dbg(&port->dev, "%s - I will free all\n", __func__);
134 usb_set_serial_port_data(port, NULL); 125 usb_set_serial_port_data(port, NULL);
135 126
136 dbg("%s - priv is not anymore in port structure", __func__); 127 dev_dbg(&port->dev, "%s - priv is not anymore in port structure\n", __func__);
137 kfree(priv); 128 kfree(priv);
138 129
139 dbg("%s priv is now kfree", __func__); 130 dev_dbg(&port->dev, "%s priv is now kfree\n", __func__);
140 } 131 }
141} 132}
142 133
@@ -148,13 +139,13 @@ static int iuu_tiocmset(struct tty_struct *tty,
148 unsigned long flags; 139 unsigned long flags;
149 140
150 /* FIXME: locking on tiomstatus */ 141 /* FIXME: locking on tiomstatus */
151 dbg("%s (%d) msg : SET = 0x%04x, CLEAR = 0x%04x ", __func__, 142 dev_dbg(&port->dev, "%s msg : SET = 0x%04x, CLEAR = 0x%04x\n",
152 port->number, set, clear); 143 __func__, set, clear);
153 144
154 spin_lock_irqsave(&priv->lock, flags); 145 spin_lock_irqsave(&priv->lock, flags);
155 146
156 if ((set & TIOCM_RTS) && !(priv->tiostatus == TIOCM_RTS)) { 147 if ((set & TIOCM_RTS) && !(priv->tiostatus == TIOCM_RTS)) {
157 dbg("%s TIOCMSET RESET called !!!", __func__); 148 dev_dbg(&port->dev, "%s TIOCMSET RESET called !!!\n", __func__);
158 priv->reset = 1; 149 priv->reset = 1;
159 } 150 }
160 if (set & TIOCM_RTS) 151 if (set & TIOCM_RTS)
@@ -190,7 +181,7 @@ static void iuu_rxcmd(struct urb *urb)
190 int status = urb->status; 181 int status = urb->status;
191 182
192 if (status) { 183 if (status) {
193 dbg("%s - status = %d", __func__, status); 184 dev_dbg(&port->dev, "%s - status = %d\n", __func__, status);
194 /* error stop all */ 185 /* error stop all */
195 return; 186 return;
196 } 187 }
@@ -244,13 +235,13 @@ static void iuu_update_status_callback(struct urb *urb)
244 int status = urb->status; 235 int status = urb->status;
245 236
246 if (status) { 237 if (status) {
247 dbg("%s - status = %d", __func__, status); 238 dev_dbg(&port->dev, "%s - status = %d\n", __func__, status);
248 /* error stop all */ 239 /* error stop all */
249 return; 240 return;
250 } 241 }
251 242
252 st = urb->transfer_buffer; 243 st = urb->transfer_buffer;
253 dbg("%s - enter", __func__); 244 dev_dbg(&port->dev, "%s - enter\n", __func__);
254 if (urb->actual_length == 1) { 245 if (urb->actual_length == 1) {
255 switch (st[0]) { 246 switch (st[0]) {
256 case 0x1: 247 case 0x1:
@@ -272,7 +263,7 @@ static void iuu_status_callback(struct urb *urb)
272 int result; 263 int result;
273 int status = urb->status; 264 int status = urb->status;
274 265
275 dbg("%s - status = %d", __func__, status); 266 dev_dbg(&port->dev, "%s - status = %d\n", __func__, status);
276 usb_fill_bulk_urb(port->read_urb, port->serial->dev, 267 usb_fill_bulk_urb(port->read_urb, port->serial->dev,
277 usb_rcvbulkpipe(port->serial->dev, 268 usb_rcvbulkpipe(port->serial->dev,
278 port->bulk_in_endpointAddress), 269 port->bulk_in_endpointAddress),
@@ -311,9 +302,9 @@ static int bulk_immediate(struct usb_serial_port *port, u8 *buf, u8 count)
311 count, &actual, HZ * 1); 302 count, &actual, HZ * 1);
312 303
313 if (status != IUU_OPERATION_OK) 304 if (status != IUU_OPERATION_OK)
314 dbg("%s - error = %2x", __func__, status); 305 dev_dbg(&port->dev, "%s - error = %2x\n", __func__, status);
315 else 306 else
316 dbg("%s - write OK !", __func__); 307 dev_dbg(&port->dev, "%s - write OK !\n", __func__);
317 return status; 308 return status;
318} 309}
319 310
@@ -331,9 +322,9 @@ static int read_immediate(struct usb_serial_port *port, u8 *buf, u8 count)
331 count, &actual, HZ * 1); 322 count, &actual, HZ * 1);
332 323
333 if (status != IUU_OPERATION_OK) 324 if (status != IUU_OPERATION_OK)
334 dbg("%s - error = %2x", __func__, status); 325 dev_dbg(&port->dev, "%s - error = %2x\n", __func__, status);
335 else 326 else
336 dbg("%s - read OK !", __func__); 327 dev_dbg(&port->dev, "%s - read OK !\n", __func__);
337 return status; 328 return status;
338} 329}
339 330
@@ -357,9 +348,9 @@ static int iuu_led(struct usb_serial_port *port, unsigned int R,
357 status = bulk_immediate(port, buf, 8); 348 status = bulk_immediate(port, buf, 8);
358 kfree(buf); 349 kfree(buf);
359 if (status != IUU_OPERATION_OK) 350 if (status != IUU_OPERATION_OK)
360 dbg("%s - led error status = %2x", __func__, status); 351 dev_dbg(&port->dev, "%s - led error status = %2x\n", __func__, status);
361 else 352 else
362 dbg("%s - led OK !", __func__); 353 dev_dbg(&port->dev, "%s - led OK !\n", __func__);
363 return IUU_OPERATION_OK; 354 return IUU_OPERATION_OK;
364} 355}
365 356
@@ -445,7 +436,7 @@ static int iuu_clk(struct usb_serial_port *port, int dwFrq)
445 436
446 status = bulk_immediate(port, (u8 *) priv->buf, Count); 437 status = bulk_immediate(port, (u8 *) priv->buf, Count);
447 if (status != 0) { 438 if (status != 0) {
448 dbg("%s - write error ", __func__); 439 dev_dbg(&port->dev, "%s - write error\n", __func__);
449 return status; 440 return status;
450 } 441 }
451 } else if (frq == 3579000) { 442 } else if (frq == 3579000) {
@@ -554,12 +545,13 @@ static int iuu_clk(struct usb_serial_port *port, int dwFrq)
554 545
555 status = bulk_immediate(port, (u8 *) priv->buf, Count); 546 status = bulk_immediate(port, (u8 *) priv->buf, Count);
556 if (status != IUU_OPERATION_OK) 547 if (status != IUU_OPERATION_OK)
557 dbg("%s - write error ", __func__); 548 dev_dbg(&port->dev, "%s - write error\n", __func__);
558 return status; 549 return status;
559} 550}
560 551
561static int iuu_uart_flush(struct usb_serial_port *port) 552static int iuu_uart_flush(struct usb_serial_port *port)
562{ 553{
554 struct device *dev = &port->dev;
563 int i; 555 int i;
564 int status; 556 int status;
565 u8 rxcmd = IUU_UART_RX; 557 u8 rxcmd = IUU_UART_RX;
@@ -571,27 +563,26 @@ static int iuu_uart_flush(struct usb_serial_port *port)
571 for (i = 0; i < 2; i++) { 563 for (i = 0; i < 2; i++) {
572 status = bulk_immediate(port, &rxcmd, 1); 564 status = bulk_immediate(port, &rxcmd, 1);
573 if (status != IUU_OPERATION_OK) { 565 if (status != IUU_OPERATION_OK) {
574 dbg("%s - uart_flush_write error", __func__); 566 dev_dbg(dev, "%s - uart_flush_write error\n", __func__);
575 return status; 567 return status;
576 } 568 }
577 569
578 status = read_immediate(port, &priv->len, 1); 570 status = read_immediate(port, &priv->len, 1);
579 if (status != IUU_OPERATION_OK) { 571 if (status != IUU_OPERATION_OK) {
580 dbg("%s - uart_flush_read error", __func__); 572 dev_dbg(dev, "%s - uart_flush_read error\n", __func__);
581 return status; 573 return status;
582 } 574 }
583 575
584 if (priv->len > 0) { 576 if (priv->len > 0) {
585 dbg("%s - uart_flush datalen is : %i ", __func__, 577 dev_dbg(dev, "%s - uart_flush datalen is : %i\n", __func__, priv->len);
586 priv->len);
587 status = read_immediate(port, priv->buf, priv->len); 578 status = read_immediate(port, priv->buf, priv->len);
588 if (status != IUU_OPERATION_OK) { 579 if (status != IUU_OPERATION_OK) {
589 dbg("%s - uart_flush_read error", __func__); 580 dev_dbg(dev, "%s - uart_flush_read error\n", __func__);
590 return status; 581 return status;
591 } 582 }
592 } 583 }
593 } 584 }
594 dbg("%s - uart_flush_read OK!", __func__); 585 dev_dbg(dev, "%s - uart_flush_read OK!\n", __func__);
595 iuu_led(port, 0, 0xF000, 0, 0xFF); 586 iuu_led(port, 0, 0xF000, 0, 0xFF);
596 return status; 587 return status;
597} 588}
@@ -610,10 +601,10 @@ static void read_buf_callback(struct urb *urb)
610 return; 601 return;
611 } 602 }
612 603
613 dbg("%s - %i chars to write", __func__, urb->actual_length); 604 dev_dbg(&port->dev, "%s - %i chars to write\n", __func__, urb->actual_length);
614 tty = tty_port_tty_get(&port->port); 605 tty = tty_port_tty_get(&port->port);
615 if (data == NULL) 606 if (data == NULL)
616 dbg("%s - data is NULL !!!", __func__); 607 dev_dbg(&port->dev, "%s - data is NULL !!!\n", __func__);
617 if (tty && urb->actual_length && data) { 608 if (tty && urb->actual_length && data) {
618 tty_insert_flip_string(tty, data, urb->actual_length); 609 tty_insert_flip_string(tty, data, urb->actual_length);
619 tty_flip_buffer_push(tty); 610 tty_flip_buffer_push(tty);
@@ -627,7 +618,6 @@ static int iuu_bulk_write(struct usb_serial_port *port)
627 struct iuu_private *priv = usb_get_serial_port_data(port); 618 struct iuu_private *priv = usb_get_serial_port_data(port);
628 unsigned long flags; 619 unsigned long flags;
629 int result; 620 int result;
630 int i;
631 int buf_len; 621 int buf_len;
632 char *buf_ptr = port->write_urb->transfer_buffer; 622 char *buf_ptr = port->write_urb->transfer_buffer;
633 623
@@ -640,14 +630,8 @@ static int iuu_bulk_write(struct usb_serial_port *port)
640 buf_len = priv->writelen; 630 buf_len = priv->writelen;
641 priv->writelen = 0; 631 priv->writelen = 0;
642 spin_unlock_irqrestore(&priv->lock, flags); 632 spin_unlock_irqrestore(&priv->lock, flags);
643 if (debug == 1) { 633 dev_dbg(&port->dev, "%s - writing %i chars : %*ph\n", __func__,
644 for (i = 0; i < buf_len; i++) 634 buf_len, buf_len, buf_ptr);
645 sprintf(priv->dbgbuf + i*2 ,
646 "%02X", priv->writebuf[i]);
647 priv->dbgbuf[buf_len+i*2] = 0;
648 dbg("%s - writing %i chars : %s", __func__,
649 buf_len, priv->dbgbuf);
650 }
651 usb_fill_bulk_urb(port->write_urb, port->serial->dev, 635 usb_fill_bulk_urb(port->write_urb, port->serial->dev,
652 usb_sndbulkpipe(port->serial->dev, 636 usb_sndbulkpipe(port->serial->dev,
653 port->bulk_out_endpointAddress), 637 port->bulk_out_endpointAddress),
@@ -683,18 +667,18 @@ static void iuu_uart_read_callback(struct urb *urb)
683 priv->poll++; 667 priv->poll++;
684 668
685 if (status) { 669 if (status) {
686 dbg("%s - status = %d", __func__, status); 670 dev_dbg(&port->dev, "%s - status = %d\n", __func__, status);
687 /* error stop all */ 671 /* error stop all */
688 return; 672 return;
689 } 673 }
690 if (data == NULL) 674 if (data == NULL)
691 dbg("%s - data is NULL !!!", __func__); 675 dev_dbg(&port->dev, "%s - data is NULL !!!\n", __func__);
692 676
693 if (urb->actual_length == 1 && data != NULL) 677 if (urb->actual_length == 1 && data != NULL)
694 len = (int) data[0]; 678 len = (int) data[0];
695 679
696 if (urb->actual_length > 1) { 680 if (urb->actual_length > 1) {
697 dbg("%s - urb->actual_length = %i", __func__, 681 dev_dbg(&port->dev, "%s - urb->actual_length = %i\n", __func__,
698 urb->actual_length); 682 urb->actual_length);
699 error = 1; 683 error = 1;
700 return; 684 return;
@@ -702,7 +686,7 @@ static void iuu_uart_read_callback(struct urb *urb)
702 /* if len > 0 call readbuf */ 686 /* if len > 0 call readbuf */
703 687
704 if (len > 0 && error == 0) { 688 if (len > 0 && error == 0) {
705 dbg("%s - call read buf - len to read is %i ", 689 dev_dbg(&port->dev, "%s - call read buf - len to read is %i\n",
706 __func__, len); 690 __func__, len);
707 status = iuu_read_buf(port, len); 691 status = iuu_read_buf(port, len);
708 return; 692 return;
@@ -729,7 +713,7 @@ static void iuu_uart_read_callback(struct urb *urb)
729 } 713 }
730 spin_unlock_irqrestore(&priv->lock, flags); 714 spin_unlock_irqrestore(&priv->lock, flags);
731 /* if nothing to write call again rxcmd */ 715 /* if nothing to write call again rxcmd */
732 dbg("%s - rxcmd recall", __func__); 716 dev_dbg(&port->dev, "%s - rxcmd recall\n", __func__);
733 iuu_led_activity_off(urb); 717 iuu_led_activity_off(urb);
734} 718}
735 719
@@ -769,7 +753,7 @@ static void read_rxcmd_callback(struct urb *urb)
769 port->read_urb->transfer_buffer, 256, 753 port->read_urb->transfer_buffer, 256,
770 iuu_uart_read_callback, port); 754 iuu_uart_read_callback, port);
771 result = usb_submit_urb(port->read_urb, GFP_ATOMIC); 755 result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
772 dbg("%s - submit result = %d", __func__, result); 756 dev_dbg(&port->dev, "%s - submit result = %d\n", __func__, result);
773} 757}
774 758
775static int iuu_uart_on(struct usb_serial_port *port) 759static int iuu_uart_on(struct usb_serial_port *port)
@@ -789,13 +773,13 @@ static int iuu_uart_on(struct usb_serial_port *port)
789 773
790 status = bulk_immediate(port, buf, 4); 774 status = bulk_immediate(port, buf, 4);
791 if (status != IUU_OPERATION_OK) { 775 if (status != IUU_OPERATION_OK) {
792 dbg("%s - uart_on error", __func__); 776 dev_dbg(&port->dev, "%s - uart_on error\n", __func__);
793 goto uart_enable_failed; 777 goto uart_enable_failed;
794 } 778 }
795 /* iuu_reset() the card after iuu_uart_on() */ 779 /* iuu_reset() the card after iuu_uart_on() */
796 status = iuu_uart_flush(port); 780 status = iuu_uart_flush(port);
797 if (status != IUU_OPERATION_OK) 781 if (status != IUU_OPERATION_OK)
798 dbg("%s - uart_flush error", __func__); 782 dev_dbg(&port->dev, "%s - uart_flush error\n", __func__);
799uart_enable_failed: 783uart_enable_failed:
800 kfree(buf); 784 kfree(buf);
801 return status; 785 return status;
@@ -813,7 +797,7 @@ static int iuu_uart_off(struct usb_serial_port *port)
813 797
814 status = bulk_immediate(port, buf, 1); 798 status = bulk_immediate(port, buf, 1);
815 if (status != IUU_OPERATION_OK) 799 if (status != IUU_OPERATION_OK)
816 dbg("%s - uart_off error", __func__); 800 dev_dbg(&port->dev, "%s - uart_off error\n", __func__);
817 801
818 kfree(buf); 802 kfree(buf);
819 return status; 803 return status;
@@ -830,7 +814,7 @@ static int iuu_uart_baud(struct usb_serial_port *port, u32 baud_base,
830 u8 T1reload = 0; 814 u8 T1reload = 0;
831 unsigned int T1FrekvensHZ = 0; 815 unsigned int T1FrekvensHZ = 0;
832 816
833 dbg("%s - enter baud_base=%d", __func__, baud_base); 817 dev_dbg(&port->dev, "%s - enter baud_base=%d\n", __func__, baud_base);
834 dataout = kmalloc(sizeof(u8) * 5, GFP_KERNEL); 818 dataout = kmalloc(sizeof(u8) * 5, GFP_KERNEL);
835 819
836 if (!dataout) 820 if (!dataout)
@@ -911,7 +895,7 @@ static int iuu_uart_baud(struct usb_serial_port *port, u32 baud_base,
911 895
912 status = bulk_immediate(port, dataout, DataCount); 896 status = bulk_immediate(port, dataout, DataCount);
913 if (status != IUU_OPERATION_OK) 897 if (status != IUU_OPERATION_OK)
914 dbg("%s - uart_off error", __func__); 898 dev_dbg(&port->dev, "%s - uart_off error\n", __func__);
915 kfree(dataout); 899 kfree(dataout);
916 return status; 900 return status;
917} 901}
@@ -932,7 +916,7 @@ static void iuu_set_termios(struct tty_struct *tty,
932 /* Just use the ospeed. ispeed should be the same. */ 916 /* Just use the ospeed. ispeed should be the same. */
933 baud = tty->termios.c_ospeed; 917 baud = tty->termios.c_ospeed;
934 918
935 dbg("%s - enter c_ospeed or baud=%d", __func__, baud); 919 dev_dbg(&port->dev, "%s - enter c_ospeed or baud=%d\n", __func__, baud);
936 920
937 /* compute the parity parameter */ 921 /* compute the parity parameter */
938 parity = 0; 922 parity = 0;
@@ -983,7 +967,7 @@ static void iuu_close(struct usb_serial_port *port)
983 if (serial->dev) { 967 if (serial->dev) {
984 /* free writebuf */ 968 /* free writebuf */
985 /* shutdown our urbs */ 969 /* shutdown our urbs */
986 dbg("%s - shutting down urbs", __func__); 970 dev_dbg(&port->dev, "%s - shutting down urbs\n", __func__);
987 usb_kill_urb(port->write_urb); 971 usb_kill_urb(port->write_urb);
988 usb_kill_urb(port->read_urb); 972 usb_kill_urb(port->read_urb);
989 usb_kill_urb(port->interrupt_in_urb); 973 usb_kill_urb(port->interrupt_in_urb);
@@ -1006,6 +990,7 @@ static void iuu_init_termios(struct tty_struct *tty)
1006static int iuu_open(struct tty_struct *tty, struct usb_serial_port *port) 990static int iuu_open(struct tty_struct *tty, struct usb_serial_port *port)
1007{ 991{
1008 struct usb_serial *serial = port->serial; 992 struct usb_serial *serial = port->serial;
993 struct device *dev = &port->dev;
1009 u8 *buf; 994 u8 *buf;
1010 int result; 995 int result;
1011 int baud; 996 int baud;
@@ -1017,7 +1002,7 @@ static int iuu_open(struct tty_struct *tty, struct usb_serial_port *port)
1017 /* Re-encode speed */ 1002 /* Re-encode speed */
1018 tty_encode_baud_rate(tty, baud, baud); 1003 tty_encode_baud_rate(tty, baud, baud);
1019 1004
1020 dbg("%s - port %d, baud %d", __func__, port->number, baud); 1005 dev_dbg(dev, "%s - baud %d\n", __func__, baud);
1021 usb_clear_halt(serial->dev, port->write_urb->pipe); 1006 usb_clear_halt(serial->dev, port->write_urb->pipe);
1022 usb_clear_halt(serial->dev, port->read_urb->pipe); 1007 usb_clear_halt(serial->dev, port->read_urb->pipe);
1023 1008
@@ -1032,14 +1017,14 @@ static int iuu_open(struct tty_struct *tty, struct usb_serial_port *port)
1032 result = usb_control_msg(port->serial->dev, \ 1017 result = usb_control_msg(port->serial->dev, \
1033 usb_rcvctrlpipe(port->serial->dev, 0), \ 1018 usb_rcvctrlpipe(port->serial->dev, 0), \
1034 b, a, c, d, buf, 1, 1000); \ 1019 b, a, c, d, buf, 1, 1000); \
1035 dbg("0x%x:0x%x:0x%x:0x%x %d - %x", a, b, c, d, result, \ 1020 dev_dbg(dev, "0x%x:0x%x:0x%x:0x%x %d - %x\n", a, b, c, d, result, \
1036 buf[0]); } while (0); 1021 buf[0]); } while (0);
1037 1022
1038#define SOUP(a, b, c, d) do { \ 1023#define SOUP(a, b, c, d) do { \
1039 result = usb_control_msg(port->serial->dev, \ 1024 result = usb_control_msg(port->serial->dev, \
1040 usb_sndctrlpipe(port->serial->dev, 0), \ 1025 usb_sndctrlpipe(port->serial->dev, 0), \
1041 b, a, c, d, NULL, 0, 1000); \ 1026 b, a, c, d, NULL, 0, 1000); \
1042 dbg("0x%x:0x%x:0x%x:0x%x %d", a, b, c, d, result); } while (0) 1027 dev_dbg(dev, "0x%x:0x%x:0x%x:0x%x %d\n", a, b, c, d, result); } while (0)
1043 1028
1044 /* This is not UART related but IUU USB driver related or something */ 1029 /* This is not UART related but IUU USB driver related or something */
1045 /* like that. Basically no IUU will accept any commands from the USB */ 1030 /* like that. Basically no IUU will accept any commands from the USB */
@@ -1119,7 +1104,7 @@ static int iuu_open(struct tty_struct *tty, struct usb_serial_port *port)
1119 1104
1120 iuu_uart_flush(port); 1105 iuu_uart_flush(port);
1121 1106
1122 dbg("%s - initialization done", __func__); 1107 dev_dbg(dev, "%s - initialization done\n", __func__);
1123 1108
1124 memset(port->write_urb->transfer_buffer, IUU_UART_RX, 1); 1109 memset(port->write_urb->transfer_buffer, IUU_UART_RX, 1);
1125 usb_fill_bulk_urb(port->write_urb, port->serial->dev, 1110 usb_fill_bulk_urb(port->write_urb, port->serial->dev,
@@ -1129,11 +1114,10 @@ static int iuu_open(struct tty_struct *tty, struct usb_serial_port *port)
1129 read_rxcmd_callback, port); 1114 read_rxcmd_callback, port);
1130 result = usb_submit_urb(port->write_urb, GFP_KERNEL); 1115 result = usb_submit_urb(port->write_urb, GFP_KERNEL);
1131 if (result) { 1116 if (result) {
1132 dev_err(&port->dev, "%s - failed submitting read urb," 1117 dev_err(dev, "%s - failed submitting read urb, error %d\n", __func__, result);
1133 " error %d\n", __func__, result);
1134 iuu_close(port); 1118 iuu_close(port);
1135 } else { 1119 } else {
1136 dbg("%s - rxcmd OK", __func__); 1120 dev_dbg(dev, "%s - rxcmd OK\n", __func__);
1137 } 1121 }
1138 1122
1139 return result; 1123 return result;
@@ -1159,9 +1143,9 @@ static int iuu_vcc_set(struct usb_serial_port *port, unsigned int vcc)
1159 kfree(buf); 1143 kfree(buf);
1160 1144
1161 if (status != IUU_OPERATION_OK) 1145 if (status != IUU_OPERATION_OK)
1162 dbg("%s - vcc error status = %2x", __func__, status); 1146 dev_dbg(&port->dev, "%s - vcc error status = %2x\n", __func__, status);
1163 else 1147 else
1164 dbg("%s - vcc OK !", __func__); 1148 dev_dbg(&port->dev, "%s - vcc OK !\n", __func__);
1165 1149
1166 return status; 1150 return status;
1167} 1151}
@@ -1192,7 +1176,7 @@ static ssize_t store_vcc_mode(struct device *dev,
1192 goto fail_store_vcc_mode; 1176 goto fail_store_vcc_mode;
1193 } 1177 }
1194 1178
1195 dbg("%s: setting vcc_mode = %ld", __func__, v); 1179 dev_dbg(dev, "%s: setting vcc_mode = %ld", __func__, v);
1196 1180
1197 if ((v != 3) && (v != 5)) { 1181 if ((v != 3) && (v != 5)) {
1198 dev_err(dev, "%s - vcc_mode %ld is invalid\n", __func__, v); 1182 dev_err(dev, "%s - vcc_mode %ld is invalid\n", __func__, v);
@@ -1257,8 +1241,6 @@ MODULE_DESCRIPTION(DRIVER_DESC);
1257MODULE_LICENSE("GPL"); 1241MODULE_LICENSE("GPL");
1258 1242
1259MODULE_VERSION(DRIVER_VERSION); 1243MODULE_VERSION(DRIVER_VERSION);
1260module_param(debug, bool, S_IRUGO | S_IWUSR);
1261MODULE_PARM_DESC(debug, "Debug enabled or not");
1262 1244
1263module_param(xmas, bool, S_IRUGO | S_IWUSR); 1245module_param(xmas, bool, S_IRUGO | S_IWUSR);
1264MODULE_PARM_DESC(xmas, "Xmas colors enabled or not"); 1246MODULE_PARM_DESC(xmas, "Xmas colors enabled or not");
diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c
index 7bcbb47e1449..29c943d737d0 100644
--- a/drivers/usb/serial/keyspan.c
+++ b/drivers/usb/serial/keyspan.c
@@ -38,15 +38,12 @@
38#include <linux/tty_flip.h> 38#include <linux/tty_flip.h>
39#include <linux/module.h> 39#include <linux/module.h>
40#include <linux/spinlock.h> 40#include <linux/spinlock.h>
41#include <linux/firmware.h>
42#include <linux/ihex.h>
43#include <linux/uaccess.h> 41#include <linux/uaccess.h>
44#include <linux/usb.h> 42#include <linux/usb.h>
45#include <linux/usb/serial.h> 43#include <linux/usb/serial.h>
44#include <linux/usb/ezusb.h>
46#include "keyspan.h" 45#include "keyspan.h"
47 46
48static bool debug;
49
50/* 47/*
51 * Version Information 48 * Version Information
52 */ 49 */
@@ -165,7 +162,7 @@ static void keyspan_set_termios(struct tty_struct *tty,
165 so other rates can be generated if desired. */ 162 so other rates can be generated if desired. */
166 baud_rate = tty_get_baud_rate(tty); 163 baud_rate = tty_get_baud_rate(tty);
167 /* If no match or invalid, don't change */ 164 /* If no match or invalid, don't change */
168 if (d_details->calculate_baud_rate(baud_rate, d_details->baudclk, 165 if (d_details->calculate_baud_rate(port, baud_rate, d_details->baudclk,
169 NULL, NULL, NULL, device_port) == KEYSPAN_BAUD_RATE_OK) { 166 NULL, NULL, NULL, device_port) == KEYSPAN_BAUD_RATE_OK) {
170 /* FIXME - more to do here to ensure rate changes cleanly */ 167 /* FIXME - more to do here to ensure rate changes cleanly */
171 /* FIXME - calcuate exact rate from divisor ? */ 168 /* FIXME - calcuate exact rate from divisor ? */
@@ -241,8 +238,8 @@ static int keyspan_write(struct tty_struct *tty,
241 dataOffset = 1; 238 dataOffset = 1;
242 } 239 }
243 240
244 dbg("%s - for port %d (%d chars), flip=%d", 241 dev_dbg(&port->dev, "%s - for port %d (%d chars), flip=%d\n",
245 __func__, port->number, count, p_priv->out_flip); 242 __func__, port->number, count, p_priv->out_flip);
246 243
247 for (left = count; left > 0; left -= todo) { 244 for (left = count; left > 0; left -= todo) {
248 todo = left; 245 todo = left;
@@ -255,11 +252,11 @@ static int keyspan_write(struct tty_struct *tty,
255 this_urb = p_priv->out_urbs[flip]; 252 this_urb = p_priv->out_urbs[flip];
256 if (this_urb == NULL) { 253 if (this_urb == NULL) {
257 /* no bulk out, so return 0 bytes written */ 254 /* no bulk out, so return 0 bytes written */
258 dbg("%s - no output urb :(", __func__); 255 dev_dbg(&port->dev, "%s - no output urb :(\n", __func__);
259 return count; 256 return count;
260 } 257 }
261 258
262 dbg("%s - endpoint %d flip %d", 259 dev_dbg(&port->dev, "%s - endpoint %d flip %d\n",
263 __func__, usb_pipeendpoint(this_urb->pipe), flip); 260 __func__, usb_pipeendpoint(this_urb->pipe), flip);
264 261
265 if (this_urb->status == -EINPROGRESS) { 262 if (this_urb->status == -EINPROGRESS) {
@@ -282,7 +279,7 @@ static int keyspan_write(struct tty_struct *tty,
282 279
283 err = usb_submit_urb(this_urb, GFP_ATOMIC); 280 err = usb_submit_urb(this_urb, GFP_ATOMIC);
284 if (err != 0) 281 if (err != 0)
285 dbg("usb_submit_urb(write bulk) failed (%d)", err); 282 dev_dbg(&port->dev, "usb_submit_urb(write bulk) failed (%d)\n", err);
286 p_priv->tx_start_time[flip] = jiffies; 283 p_priv->tx_start_time[flip] = jiffies;
287 284
288 /* Flip for next time if usa26 or usa28 interface 285 /* Flip for next time if usa26 or usa28 interface
@@ -305,8 +302,8 @@ static void usa26_indat_callback(struct urb *urb)
305 endpoint = usb_pipeendpoint(urb->pipe); 302 endpoint = usb_pipeendpoint(urb->pipe);
306 303
307 if (status) { 304 if (status) {
308 dbg("%s - nonzero status: %x on endpoint %d.", 305 dev_dbg(&urb->dev->dev,"%s - nonzero status: %x on endpoint %d.\n",
309 __func__, status, endpoint); 306 __func__, status, endpoint);
310 return; 307 return;
311 } 308 }
312 309
@@ -325,7 +322,7 @@ static void usa26_indat_callback(struct urb *urb)
325 tty_insert_flip_char(tty, data[i], err); 322 tty_insert_flip_char(tty, data[i], err);
326 } else { 323 } else {
327 /* some bytes had errors, every byte has status */ 324 /* some bytes had errors, every byte has status */
328 dbg("%s - RX error!!!!", __func__); 325 dev_dbg(&port->dev, "%s - RX error!!!!\n", __func__);
329 for (i = 0; i + 1 < urb->actual_length; i += 2) { 326 for (i = 0; i + 1 < urb->actual_length; i += 2) {
330 int stat = data[i], flag = 0; 327 int stat = data[i], flag = 0;
331 if (stat & RXERROR_OVERRUN) 328 if (stat & RXERROR_OVERRUN)
@@ -345,7 +342,7 @@ static void usa26_indat_callback(struct urb *urb)
345 /* Resubmit urb so we continue receiving */ 342 /* Resubmit urb so we continue receiving */
346 err = usb_submit_urb(urb, GFP_ATOMIC); 343 err = usb_submit_urb(urb, GFP_ATOMIC);
347 if (err != 0) 344 if (err != 0)
348 dbg("%s - resubmit read urb failed. (%d)", __func__, err); 345 dev_dbg(&port->dev, "%s - resubmit read urb failed. (%d)\n", __func__, err);
349} 346}
350 347
351/* Outdat handling is common for all devices */ 348/* Outdat handling is common for all devices */
@@ -356,7 +353,7 @@ static void usa2x_outdat_callback(struct urb *urb)
356 353
357 port = urb->context; 354 port = urb->context;
358 p_priv = usb_get_serial_port_data(port); 355 p_priv = usb_get_serial_port_data(port);
359 dbg("%s - urb %d", __func__, urb == p_priv->out_urbs[1]); 356 dev_dbg(&port->dev, "%s - urb %d\n", __func__, urb == p_priv->out_urbs[1]);
360 357
361 usb_serial_port_softint(port); 358 usb_serial_port_softint(port);
362} 359}
@@ -374,7 +371,7 @@ static void usa26_outcont_callback(struct urb *urb)
374 p_priv = usb_get_serial_port_data(port); 371 p_priv = usb_get_serial_port_data(port);
375 372
376 if (p_priv->resend_cont) { 373 if (p_priv->resend_cont) {
377 dbg("%s - sending setup", __func__); 374 dev_dbg(&port->dev, "%s - sending setup\n", __func__);
378 keyspan_usa26_send_setup(port->serial, port, 375 keyspan_usa26_send_setup(port->serial, port,
379 p_priv->resend_cont - 1); 376 p_priv->resend_cont - 1);
380 } 377 }
@@ -394,20 +391,22 @@ static void usa26_instat_callback(struct urb *urb)
394 serial = urb->context; 391 serial = urb->context;
395 392
396 if (status) { 393 if (status) {
397 dbg("%s - nonzero status: %x", __func__, status); 394 dev_dbg(&urb->dev->dev, "%s - nonzero status: %x\n", __func__, status);
398 return; 395 return;
399 } 396 }
400 if (urb->actual_length != 9) { 397 if (urb->actual_length != 9) {
401 dbg("%s - %d byte report??", __func__, urb->actual_length); 398 dev_dbg(&urb->dev->dev, "%s - %d byte report??\n", __func__, urb->actual_length);
402 goto exit; 399 goto exit;
403 } 400 }
404 401
405 msg = (struct keyspan_usa26_portStatusMessage *)data; 402 msg = (struct keyspan_usa26_portStatusMessage *)data;
406 403
407#if 0 404#if 0
408 dbg("%s - port status: port %d cts %d dcd %d dsr %d ri %d toff %d txoff %d rxen %d cr %d", 405 dev_dbg(&urb->dev->dev,
409 __func__, msg->port, msg->hskia_cts, msg->gpia_dcd, msg->dsr, msg->ri, msg->_txOff, 406 "%s - port status: port %d cts %d dcd %d dsr %d ri %d toff %d txoff %d rxen %d cr %d",
410 msg->_txXoff, msg->rxEnabled, msg->controlResponse); 407 __func__, msg->port, msg->hskia_cts, msg->gpia_dcd, msg->dsr,
408 msg->ri, msg->_txOff, msg->_txXoff, msg->rxEnabled,
409 msg->controlResponse);
411#endif 410#endif
412 411
413 /* Now do something useful with the data */ 412 /* Now do something useful with the data */
@@ -415,7 +414,7 @@ static void usa26_instat_callback(struct urb *urb)
415 414
416 /* Check port number from message and retrieve private data */ 415 /* Check port number from message and retrieve private data */
417 if (msg->port >= serial->num_ports) { 416 if (msg->port >= serial->num_ports) {
418 dbg("%s - Unexpected port number %d", __func__, msg->port); 417 dev_dbg(&urb->dev->dev, "%s - Unexpected port number %d\n", __func__, msg->port);
419 goto exit; 418 goto exit;
420 } 419 }
421 port = serial->port[msg->port]; 420 port = serial->port[msg->port];
@@ -438,7 +437,7 @@ static void usa26_instat_callback(struct urb *urb)
438 /* Resubmit urb so we continue receiving */ 437 /* Resubmit urb so we continue receiving */
439 err = usb_submit_urb(urb, GFP_ATOMIC); 438 err = usb_submit_urb(urb, GFP_ATOMIC);
440 if (err != 0) 439 if (err != 0)
441 dbg("%s - resubmit read urb failed. (%d)", __func__, err); 440 dev_dbg(&port->dev, "%s - resubmit read urb failed. (%d)\n", __func__, err);
442exit: ; 441exit: ;
443} 442}
444 443
@@ -465,8 +464,8 @@ static void usa28_indat_callback(struct urb *urb)
465 464
466 do { 465 do {
467 if (status) { 466 if (status) {
468 dbg("%s - nonzero status: %x on endpoint %d.", 467 dev_dbg(&urb->dev->dev, "%s - nonzero status: %x on endpoint %d.\n",
469 __func__, status, usb_pipeendpoint(urb->pipe)); 468 __func__, status, usb_pipeendpoint(urb->pipe));
470 return; 469 return;
471 } 470 }
472 471
@@ -484,7 +483,7 @@ static void usa28_indat_callback(struct urb *urb)
484 /* Resubmit urb so we continue receiving */ 483 /* Resubmit urb so we continue receiving */
485 err = usb_submit_urb(urb, GFP_ATOMIC); 484 err = usb_submit_urb(urb, GFP_ATOMIC);
486 if (err != 0) 485 if (err != 0)
487 dbg("%s - resubmit read urb failed. (%d)", 486 dev_dbg(&port->dev, "%s - resubmit read urb failed. (%d)\n",
488 __func__, err); 487 __func__, err);
489 p_priv->in_flip ^= 1; 488 p_priv->in_flip ^= 1;
490 489
@@ -505,7 +504,7 @@ static void usa28_outcont_callback(struct urb *urb)
505 p_priv = usb_get_serial_port_data(port); 504 p_priv = usb_get_serial_port_data(port);
506 505
507 if (p_priv->resend_cont) { 506 if (p_priv->resend_cont) {
508 dbg("%s - sending setup", __func__); 507 dev_dbg(&port->dev, "%s - sending setup\n", __func__);
509 keyspan_usa28_send_setup(port->serial, port, 508 keyspan_usa28_send_setup(port->serial, port,
510 p_priv->resend_cont - 1); 509 p_priv->resend_cont - 1);
511 } 510 }
@@ -526,25 +525,28 @@ static void usa28_instat_callback(struct urb *urb)
526 serial = urb->context; 525 serial = urb->context;
527 526
528 if (status) { 527 if (status) {
529 dbg("%s - nonzero status: %x", __func__, status); 528 dev_dbg(&urb->dev->dev, "%s - nonzero status: %x\n", __func__, status);
530 return; 529 return;
531 } 530 }
532 531
533 if (urb->actual_length != sizeof(struct keyspan_usa28_portStatusMessage)) { 532 if (urb->actual_length != sizeof(struct keyspan_usa28_portStatusMessage)) {
534 dbg("%s - bad length %d", __func__, urb->actual_length); 533 dev_dbg(&urb->dev->dev, "%s - bad length %d\n", __func__, urb->actual_length);
535 goto exit; 534 goto exit;
536 } 535 }
537 536
538 /*dbg("%s %x %x %x %x %x %x %x %x %x %x %x %x", __func__ 537 /*
539 data[0], data[1], data[2], data[3], data[4], data[5], 538 dev_dbg(&urb->dev->dev,
540 data[6], data[7], data[8], data[9], data[10], data[11]);*/ 539 "%s %x %x %x %x %x %x %x %x %x %x %x %x", __func__,
540 data[0], data[1], data[2], data[3], data[4], data[5],
541 data[6], data[7], data[8], data[9], data[10], data[11]);
542 */
541 543
542 /* Now do something useful with the data */ 544 /* Now do something useful with the data */
543 msg = (struct keyspan_usa28_portStatusMessage *)data; 545 msg = (struct keyspan_usa28_portStatusMessage *)data;
544 546
545 /* Check port number from message and retrieve private data */ 547 /* Check port number from message and retrieve private data */
546 if (msg->port >= serial->num_ports) { 548 if (msg->port >= serial->num_ports) {
547 dbg("%s - Unexpected port number %d", __func__, msg->port); 549 dev_dbg(&urb->dev->dev, "%s - Unexpected port number %d\n", __func__, msg->port);
548 goto exit; 550 goto exit;
549 } 551 }
550 port = serial->port[msg->port]; 552 port = serial->port[msg->port];
@@ -567,7 +569,7 @@ static void usa28_instat_callback(struct urb *urb)
567 /* Resubmit urb so we continue receiving */ 569 /* Resubmit urb so we continue receiving */
568 err = usb_submit_urb(urb, GFP_ATOMIC); 570 err = usb_submit_urb(urb, GFP_ATOMIC);
569 if (err != 0) 571 if (err != 0)
570 dbg("%s - resubmit read urb failed. (%d)", __func__, err); 572 dev_dbg(&port->dev, "%s - resubmit read urb failed. (%d)\n", __func__, err);
571exit: ; 573exit: ;
572} 574}
573 575
@@ -589,7 +591,7 @@ static void usa49_glocont_callback(struct urb *urb)
589 p_priv = usb_get_serial_port_data(port); 591 p_priv = usb_get_serial_port_data(port);
590 592
591 if (p_priv->resend_cont) { 593 if (p_priv->resend_cont) {
592 dbg("%s - sending setup", __func__); 594 dev_dbg(&port->dev, "%s - sending setup\n", __func__);
593 keyspan_usa49_send_setup(serial, port, 595 keyspan_usa49_send_setup(serial, port,
594 p_priv->resend_cont - 1); 596 p_priv->resend_cont - 1);
595 break; 597 break;
@@ -613,27 +615,29 @@ static void usa49_instat_callback(struct urb *urb)
613 serial = urb->context; 615 serial = urb->context;
614 616
615 if (status) { 617 if (status) {
616 dbg("%s - nonzero status: %x", __func__, status); 618 dev_dbg(&urb->dev->dev, "%s - nonzero status: %x\n", __func__, status);
617 return; 619 return;
618 } 620 }
619 621
620 if (urb->actual_length != 622 if (urb->actual_length !=
621 sizeof(struct keyspan_usa49_portStatusMessage)) { 623 sizeof(struct keyspan_usa49_portStatusMessage)) {
622 dbg("%s - bad length %d", __func__, urb->actual_length); 624 dev_dbg(&urb->dev->dev, "%s - bad length %d\n", __func__, urb->actual_length);
623 goto exit; 625 goto exit;
624 } 626 }
625 627
626 /*dbg(" %x %x %x %x %x %x %x %x %x %x %x", __func__, 628 /*
627 data[0], data[1], data[2], data[3], data[4], data[5], 629 dev_dbg(&urb->dev->dev, "%s: %x %x %x %x %x %x %x %x %x %x %x",
628 data[6], data[7], data[8], data[9], data[10]);*/ 630 __func__, data[0], data[1], data[2], data[3], data[4],
631 data[5], data[6], data[7], data[8], data[9], data[10]);
632 */
629 633
630 /* Now do something useful with the data */ 634 /* Now do something useful with the data */
631 msg = (struct keyspan_usa49_portStatusMessage *)data; 635 msg = (struct keyspan_usa49_portStatusMessage *)data;
632 636
633 /* Check port number from message and retrieve private data */ 637 /* Check port number from message and retrieve private data */
634 if (msg->portNumber >= serial->num_ports) { 638 if (msg->portNumber >= serial->num_ports) {
635 dbg("%s - Unexpected port number %d", 639 dev_dbg(&urb->dev->dev, "%s - Unexpected port number %d\n",
636 __func__, msg->portNumber); 640 __func__, msg->portNumber);
637 goto exit; 641 goto exit;
638 } 642 }
639 port = serial->port[msg->portNumber]; 643 port = serial->port[msg->portNumber];
@@ -656,7 +660,7 @@ static void usa49_instat_callback(struct urb *urb)
656 /* Resubmit urb so we continue receiving */ 660 /* Resubmit urb so we continue receiving */
657 err = usb_submit_urb(urb, GFP_ATOMIC); 661 err = usb_submit_urb(urb, GFP_ATOMIC);
658 if (err != 0) 662 if (err != 0)
659 dbg("%s - resubmit read urb failed. (%d)", __func__, err); 663 dev_dbg(&port->dev, "%s - resubmit read urb failed. (%d)\n", __func__, err);
660exit: ; 664exit: ;
661} 665}
662 666
@@ -676,8 +680,8 @@ static void usa49_indat_callback(struct urb *urb)
676 endpoint = usb_pipeendpoint(urb->pipe); 680 endpoint = usb_pipeendpoint(urb->pipe);
677 681
678 if (status) { 682 if (status) {
679 dbg("%s - nonzero status: %x on endpoint %d.", __func__, 683 dev_dbg(&urb->dev->dev, "%s - nonzero status: %x on endpoint %d.\n",
680 status, endpoint); 684 __func__, status, endpoint);
681 return; 685 return;
682 } 686 }
683 687
@@ -710,7 +714,7 @@ static void usa49_indat_callback(struct urb *urb)
710 /* Resubmit urb so we continue receiving */ 714 /* Resubmit urb so we continue receiving */
711 err = usb_submit_urb(urb, GFP_ATOMIC); 715 err = usb_submit_urb(urb, GFP_ATOMIC);
712 if (err != 0) 716 if (err != 0)
713 dbg("%s - resubmit read urb failed. (%d)", __func__, err); 717 dev_dbg(&port->dev, "%s - resubmit read urb failed. (%d)\n", __func__, err);
714} 718}
715 719
716static void usa49wg_indat_callback(struct urb *urb) 720static void usa49wg_indat_callback(struct urb *urb)
@@ -725,7 +729,7 @@ static void usa49wg_indat_callback(struct urb *urb)
725 serial = urb->context; 729 serial = urb->context;
726 730
727 if (status) { 731 if (status) {
728 dbg("%s - nonzero status: %x", __func__, status); 732 dev_dbg(&urb->dev->dev, "%s - nonzero status: %x\n", __func__, status);
729 return; 733 return;
730 } 734 }
731 735
@@ -738,7 +742,7 @@ static void usa49wg_indat_callback(struct urb *urb)
738 742
739 /* Check port number from message*/ 743 /* Check port number from message*/
740 if (data[i] >= serial->num_ports) { 744 if (data[i] >= serial->num_ports) {
741 dbg("%s - Unexpected port number %d", 745 dev_dbg(&urb->dev->dev, "%s - Unexpected port number %d\n",
742 __func__, data[i]); 746 __func__, data[i]);
743 return; 747 return;
744 } 748 }
@@ -778,7 +782,7 @@ static void usa49wg_indat_callback(struct urb *urb)
778 /* Resubmit urb so we continue receiving */ 782 /* Resubmit urb so we continue receiving */
779 err = usb_submit_urb(urb, GFP_ATOMIC); 783 err = usb_submit_urb(urb, GFP_ATOMIC);
780 if (err != 0) 784 if (err != 0)
781 dbg("%s - resubmit read urb failed. (%d)", __func__, err); 785 dev_dbg(&urb->dev->dev, "%s - resubmit read urb failed. (%d)\n", __func__, err);
782} 786}
783 787
784/* not used, usa-49 doesn't have per-port control endpoints */ 788/* not used, usa-49 doesn't have per-port control endpoints */
@@ -799,7 +803,7 @@ static void usa90_indat_callback(struct urb *urb)
799 endpoint = usb_pipeendpoint(urb->pipe); 803 endpoint = usb_pipeendpoint(urb->pipe);
800 804
801 if (status) { 805 if (status) {
802 dbg("%s - nonzero status: %x on endpoint %d.", 806 dev_dbg(&urb->dev->dev, "%s - nonzero status: %x on endpoint %d.\n",
803 __func__, status, endpoint); 807 __func__, status, endpoint);
804 return; 808 return;
805 } 809 }
@@ -828,7 +832,7 @@ static void usa90_indat_callback(struct urb *urb)
828 err); 832 err);
829 } else { 833 } else {
830 /* some bytes had errors, every byte has status */ 834 /* some bytes had errors, every byte has status */
831 dbg("%s - RX error!!!!", __func__); 835 dev_dbg(&port->dev, "%s - RX error!!!!\n", __func__);
832 for (i = 0; i + 1 < urb->actual_length; i += 2) { 836 for (i = 0; i + 1 < urb->actual_length; i += 2) {
833 int stat = data[i], flag = 0; 837 int stat = data[i], flag = 0;
834 if (stat & RXERROR_OVERRUN) 838 if (stat & RXERROR_OVERRUN)
@@ -850,7 +854,7 @@ static void usa90_indat_callback(struct urb *urb)
850 /* Resubmit urb so we continue receiving */ 854 /* Resubmit urb so we continue receiving */
851 err = usb_submit_urb(urb, GFP_ATOMIC); 855 err = usb_submit_urb(urb, GFP_ATOMIC);
852 if (err != 0) 856 if (err != 0)
853 dbg("%s - resubmit read urb failed. (%d)", __func__, err); 857 dev_dbg(&port->dev, "%s - resubmit read urb failed. (%d)\n", __func__, err);
854} 858}
855 859
856 860
@@ -868,11 +872,11 @@ static void usa90_instat_callback(struct urb *urb)
868 serial = urb->context; 872 serial = urb->context;
869 873
870 if (status) { 874 if (status) {
871 dbg("%s - nonzero status: %x", __func__, status); 875 dev_dbg(&urb->dev->dev, "%s - nonzero status: %x\n", __func__, status);
872 return; 876 return;
873 } 877 }
874 if (urb->actual_length < 14) { 878 if (urb->actual_length < 14) {
875 dbg("%s - %d byte report??", __func__, urb->actual_length); 879 dev_dbg(&urb->dev->dev, "%s - %d byte report??\n", __func__, urb->actual_length);
876 goto exit; 880 goto exit;
877 } 881 }
878 882
@@ -900,7 +904,7 @@ static void usa90_instat_callback(struct urb *urb)
900 /* Resubmit urb so we continue receiving */ 904 /* Resubmit urb so we continue receiving */
901 err = usb_submit_urb(urb, GFP_ATOMIC); 905 err = usb_submit_urb(urb, GFP_ATOMIC);
902 if (err != 0) 906 if (err != 0)
903 dbg("%s - resubmit read urb failed. (%d)", __func__, err); 907 dev_dbg(&port->dev, "%s - resubmit read urb failed. (%d)\n", __func__, err);
904exit: 908exit:
905 ; 909 ;
906} 910}
@@ -914,7 +918,7 @@ static void usa90_outcont_callback(struct urb *urb)
914 p_priv = usb_get_serial_port_data(port); 918 p_priv = usb_get_serial_port_data(port);
915 919
916 if (p_priv->resend_cont) { 920 if (p_priv->resend_cont) {
917 dbg("%s - sending setup", __func__); 921 dev_dbg(&urb->dev->dev, "%s - sending setup\n", __func__);
918 keyspan_usa90_send_setup(port->serial, port, 922 keyspan_usa90_send_setup(port->serial, port,
919 p_priv->resend_cont - 1); 923 p_priv->resend_cont - 1);
920 } 924 }
@@ -935,13 +939,13 @@ static void usa67_instat_callback(struct urb *urb)
935 serial = urb->context; 939 serial = urb->context;
936 940
937 if (status) { 941 if (status) {
938 dbg("%s - nonzero status: %x", __func__, status); 942 dev_dbg(&urb->dev->dev, "%s - nonzero status: %x\n", __func__, status);
939 return; 943 return;
940 } 944 }
941 945
942 if (urb->actual_length != 946 if (urb->actual_length !=
943 sizeof(struct keyspan_usa67_portStatusMessage)) { 947 sizeof(struct keyspan_usa67_portStatusMessage)) {
944 dbg("%s - bad length %d", __func__, urb->actual_length); 948 dev_dbg(&urb->dev->dev, "%s - bad length %d\n", __func__, urb->actual_length);
945 return; 949 return;
946 } 950 }
947 951
@@ -951,7 +955,7 @@ static void usa67_instat_callback(struct urb *urb)
951 955
952 /* Check port number from message and retrieve private data */ 956 /* Check port number from message and retrieve private data */
953 if (msg->port >= serial->num_ports) { 957 if (msg->port >= serial->num_ports) {
954 dbg("%s - Unexpected port number %d", __func__, msg->port); 958 dev_dbg(&urb->dev->dev, "%s - Unexpected port number %d\n", __func__, msg->port);
955 return; 959 return;
956 } 960 }
957 961
@@ -973,7 +977,7 @@ static void usa67_instat_callback(struct urb *urb)
973 /* Resubmit urb so we continue receiving */ 977 /* Resubmit urb so we continue receiving */
974 err = usb_submit_urb(urb, GFP_ATOMIC); 978 err = usb_submit_urb(urb, GFP_ATOMIC);
975 if (err != 0) 979 if (err != 0)
976 dbg("%s - resubmit read urb failed. (%d)", __func__, err); 980 dev_dbg(&port->dev, "%s - resubmit read urb failed. (%d)\n", __func__, err);
977} 981}
978 982
979static void usa67_glocont_callback(struct urb *urb) 983static void usa67_glocont_callback(struct urb *urb)
@@ -989,7 +993,7 @@ static void usa67_glocont_callback(struct urb *urb)
989 p_priv = usb_get_serial_port_data(port); 993 p_priv = usb_get_serial_port_data(port);
990 994
991 if (p_priv->resend_cont) { 995 if (p_priv->resend_cont) {
992 dbg("%s - sending setup", __func__); 996 dev_dbg(&port->dev, "%s - sending setup\n", __func__);
993 keyspan_usa67_send_setup(serial, port, 997 keyspan_usa67_send_setup(serial, port,
994 p_priv->resend_cont - 1); 998 p_priv->resend_cont - 1);
995 break; 999 break;
@@ -1068,8 +1072,7 @@ static int keyspan_open(struct tty_struct *tty, struct usb_serial_port *port)
1068 usb_clear_halt(urb->dev, urb->pipe); 1072 usb_clear_halt(urb->dev, urb->pipe);
1069 err = usb_submit_urb(urb, GFP_KERNEL); 1073 err = usb_submit_urb(urb, GFP_KERNEL);
1070 if (err != 0) 1074 if (err != 0)
1071 dbg("%s - submit urb %d failed (%d)", 1075 dev_dbg(&port->dev, "%s - submit urb %d failed (%d)\n", __func__, i, err);
1072 __func__, i, err);
1073 } 1076 }
1074 1077
1075 /* Reset low level data toggle on out endpoints */ 1078 /* Reset low level data toggle on out endpoints */
@@ -1092,7 +1095,7 @@ static int keyspan_open(struct tty_struct *tty, struct usb_serial_port *port)
1092 baud_rate = tty_get_baud_rate(tty); 1095 baud_rate = tty_get_baud_rate(tty);
1093 /* If no match or invalid, leave as default */ 1096 /* If no match or invalid, leave as default */
1094 if (baud_rate >= 0 1097 if (baud_rate >= 0
1095 && d_details->calculate_baud_rate(baud_rate, d_details->baudclk, 1098 && d_details->calculate_baud_rate(port, baud_rate, d_details->baudclk,
1096 NULL, NULL, NULL, device_port) == KEYSPAN_BAUD_RATE_OK) { 1099 NULL, NULL, NULL, device_port) == KEYSPAN_BAUD_RATE_OK) {
1097 p_priv->baud = baud_rate; 1100 p_priv->baud = baud_rate;
1098 } 1101 }
@@ -1142,7 +1145,7 @@ static void keyspan_close(struct usb_serial_port *port)
1142 } 1145 }
1143 1146
1144 /*while (p_priv->outcont_urb->status == -EINPROGRESS) { 1147 /*while (p_priv->outcont_urb->status == -EINPROGRESS) {
1145 dbg("%s - urb in progress", __func__); 1148 dev_dbg(&port->dev, "%s - urb in progress\n", __func__);
1146 }*/ 1149 }*/
1147 1150
1148 p_priv->out_flip = 0; 1151 p_priv->out_flip = 0;
@@ -1162,18 +1165,15 @@ static void keyspan_close(struct usb_serial_port *port)
1162/* download the firmware to a pre-renumeration device */ 1165/* download the firmware to a pre-renumeration device */
1163static int keyspan_fake_startup(struct usb_serial *serial) 1166static int keyspan_fake_startup(struct usb_serial *serial)
1164{ 1167{
1165 int response; 1168 char *fw_name;
1166 const struct ihex_binrec *record;
1167 char *fw_name;
1168 const struct firmware *fw;
1169 1169
1170 dbg("Keyspan startup version %04x product %04x", 1170 dev_dbg(&serial->dev->dev, "Keyspan startup version %04x product %04x\n",
1171 le16_to_cpu(serial->dev->descriptor.bcdDevice), 1171 le16_to_cpu(serial->dev->descriptor.bcdDevice),
1172 le16_to_cpu(serial->dev->descriptor.idProduct)); 1172 le16_to_cpu(serial->dev->descriptor.idProduct));
1173 1173
1174 if ((le16_to_cpu(serial->dev->descriptor.bcdDevice) & 0x8000) 1174 if ((le16_to_cpu(serial->dev->descriptor.bcdDevice) & 0x8000)
1175 != 0x8000) { 1175 != 0x8000) {
1176 dbg("Firmware already loaded. Quitting."); 1176 dev_dbg(&serial->dev->dev, "Firmware already loaded. Quitting.\n");
1177 return 1; 1177 return 1;
1178 } 1178 }
1179 1179
@@ -1233,34 +1233,16 @@ static int keyspan_fake_startup(struct usb_serial *serial)
1233 return 1; 1233 return 1;
1234 } 1234 }
1235 1235
1236 if (request_ihex_firmware(&fw, fw_name, &serial->dev->dev)) { 1236 dev_dbg(&serial->dev->dev, "Uploading Keyspan %s firmware.\n", fw_name);
1237 dev_err(&serial->dev->dev, "Required keyspan firmware image (%s) unavailable.\n", fw_name);
1238 return 1;
1239 }
1240
1241 dbg("Uploading Keyspan %s firmware.", fw_name);
1242 1237
1243 /* download the firmware image */ 1238 if (ezusb_fx1_ihex_firmware_download(serial->dev, fw_name) < 0) {
1244 response = ezusb_set_reset(serial, 1); 1239 dev_err(&serial->dev->dev, "failed to load firmware \"%s\"\n",
1245 1240 fw_name);
1246 record = (const struct ihex_binrec *)fw->data; 1241 return -ENOENT;
1247
1248 while (record) {
1249 response = ezusb_writememory(serial, be32_to_cpu(record->addr),
1250 (unsigned char *)record->data,
1251 be16_to_cpu(record->len), 0xa0);
1252 if (response < 0) {
1253 dev_err(&serial->dev->dev, "ezusb_writememory failed for Keyspan firmware (%d %04X %p %d)\n",
1254 response, be32_to_cpu(record->addr),
1255 record->data, be16_to_cpu(record->len));
1256 break;
1257 }
1258 record = ihex_next_binrec(record);
1259 } 1242 }
1260 release_firmware(fw); 1243
1261 /* bring device out of reset. Renumeration will occur in a 1244 /* after downloading firmware Renumeration will occur in a
1262 moment and the new device will bind to the real driver */ 1245 moment and the new device will bind to the real driver */
1263 response = ezusb_set_reset(serial, 0);
1264 1246
1265 /* we don't want this device to have a driver assigned to it. */ 1247 /* we don't want this device to have a driver assigned to it. */
1266 return 1; 1248 return 1;
@@ -1296,10 +1278,10 @@ static struct urb *keyspan_setup_urb(struct usb_serial *serial, int endpoint,
1296 if (endpoint == -1) 1278 if (endpoint == -1)
1297 return NULL; /* endpoint not needed */ 1279 return NULL; /* endpoint not needed */
1298 1280
1299 dbg("%s - alloc for endpoint %d.", __func__, endpoint); 1281 dev_dbg(&serial->interface->dev, "%s - alloc for endpoint %d.\n", __func__, endpoint);
1300 urb = usb_alloc_urb(0, GFP_KERNEL); /* No ISO */ 1282 urb = usb_alloc_urb(0, GFP_KERNEL); /* No ISO */
1301 if (urb == NULL) { 1283 if (urb == NULL) {
1302 dbg("%s - alloc for endpoint %d failed.", __func__, endpoint); 1284 dev_dbg(&serial->interface->dev, "%s - alloc for endpoint %d failed.\n", __func__, endpoint);
1303 return NULL; 1285 return NULL;
1304 } 1286 }
1305 1287
@@ -1332,7 +1314,7 @@ static struct urb *keyspan_setup_urb(struct usb_serial *serial, int endpoint,
1332 return NULL; 1314 return NULL;
1333 } 1315 }
1334 1316
1335 dbg("%s - using urb %p for %s endpoint %x", 1317 dev_dbg(&serial->interface->dev, "%s - using urb %p for %s endpoint %x\n",
1336 __func__, urb, ep_type_name, endpoint); 1318 __func__, urb, ep_type_name, endpoint);
1337 return urb; 1319 return urb;
1338} 1320}
@@ -1464,14 +1446,15 @@ static void keyspan_setup_urbs(struct usb_serial *serial)
1464} 1446}
1465 1447
1466/* usa19 function doesn't require prescaler */ 1448/* usa19 function doesn't require prescaler */
1467static int keyspan_usa19_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi, 1449static int keyspan_usa19_calc_baud(struct usb_serial_port *port,
1450 u32 baud_rate, u32 baudclk, u8 *rate_hi,
1468 u8 *rate_low, u8 *prescaler, int portnum) 1451 u8 *rate_low, u8 *prescaler, int portnum)
1469{ 1452{
1470 u32 b16, /* baud rate times 16 (actual rate used internally) */ 1453 u32 b16, /* baud rate times 16 (actual rate used internally) */
1471 div, /* divisor */ 1454 div, /* divisor */
1472 cnt; /* inverse of divisor (programmed into 8051) */ 1455 cnt; /* inverse of divisor (programmed into 8051) */
1473 1456
1474 dbg("%s - %d.", __func__, baud_rate); 1457 dev_dbg(&port->dev, "%s - %d.\n", __func__, baud_rate);
1475 1458
1476 /* prevent divide by zero... */ 1459 /* prevent divide by zero... */
1477 b16 = baud_rate * 16L; 1460 b16 = baud_rate * 16L;
@@ -1498,19 +1481,20 @@ static int keyspan_usa19_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi,
1498 if (rate_hi) 1481 if (rate_hi)
1499 *rate_hi = (u8) ((cnt >> 8) & 0xff); 1482 *rate_hi = (u8) ((cnt >> 8) & 0xff);
1500 if (rate_low && rate_hi) 1483 if (rate_low && rate_hi)
1501 dbg("%s - %d %02x %02x.", 1484 dev_dbg(&port->dev, "%s - %d %02x %02x.\n",
1502 __func__, baud_rate, *rate_hi, *rate_low); 1485 __func__, baud_rate, *rate_hi, *rate_low);
1503 return KEYSPAN_BAUD_RATE_OK; 1486 return KEYSPAN_BAUD_RATE_OK;
1504} 1487}
1505 1488
1506/* usa19hs function doesn't require prescaler */ 1489/* usa19hs function doesn't require prescaler */
1507static int keyspan_usa19hs_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi, 1490static int keyspan_usa19hs_calc_baud(struct usb_serial_port *port,
1508 u8 *rate_low, u8 *prescaler, int portnum) 1491 u32 baud_rate, u32 baudclk, u8 *rate_hi,
1492 u8 *rate_low, u8 *prescaler, int portnum)
1509{ 1493{
1510 u32 b16, /* baud rate times 16 (actual rate used internally) */ 1494 u32 b16, /* baud rate times 16 (actual rate used internally) */
1511 div; /* divisor */ 1495 div; /* divisor */
1512 1496
1513 dbg("%s - %d.", __func__, baud_rate); 1497 dev_dbg(&port->dev, "%s - %d.\n", __func__, baud_rate);
1514 1498
1515 /* prevent divide by zero... */ 1499 /* prevent divide by zero... */
1516 b16 = baud_rate * 16L; 1500 b16 = baud_rate * 16L;
@@ -1533,13 +1517,14 @@ static int keyspan_usa19hs_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi,
1533 *rate_hi = (u8) ((div >> 8) & 0xff); 1517 *rate_hi = (u8) ((div >> 8) & 0xff);
1534 1518
1535 if (rate_low && rate_hi) 1519 if (rate_low && rate_hi)
1536 dbg("%s - %d %02x %02x.", 1520 dev_dbg(&port->dev, "%s - %d %02x %02x.\n",
1537 __func__, baud_rate, *rate_hi, *rate_low); 1521 __func__, baud_rate, *rate_hi, *rate_low);
1538 1522
1539 return KEYSPAN_BAUD_RATE_OK; 1523 return KEYSPAN_BAUD_RATE_OK;
1540} 1524}
1541 1525
1542static int keyspan_usa19w_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi, 1526static int keyspan_usa19w_calc_baud(struct usb_serial_port *port,
1527 u32 baud_rate, u32 baudclk, u8 *rate_hi,
1543 u8 *rate_low, u8 *prescaler, int portnum) 1528 u8 *rate_low, u8 *prescaler, int portnum)
1544{ 1529{
1545 u32 b16, /* baud rate times 16 (actual rate used internally) */ 1530 u32 b16, /* baud rate times 16 (actual rate used internally) */
@@ -1551,7 +1536,7 @@ static int keyspan_usa19w_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi,
1551 u8 best_prescaler; 1536 u8 best_prescaler;
1552 int i; 1537 int i;
1553 1538
1554 dbg("%s - %d.", __func__, baud_rate); 1539 dev_dbg(&port->dev, "%s - %d.\n", __func__, baud_rate);
1555 1540
1556 /* prevent divide by zero */ 1541 /* prevent divide by zero */
1557 b16 = baud_rate * 16L; 1542 b16 = baud_rate * 16L;
@@ -1596,20 +1581,21 @@ static int keyspan_usa19w_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi,
1596 *rate_hi = (u8) ((div >> 8) & 0xff); 1581 *rate_hi = (u8) ((div >> 8) & 0xff);
1597 if (prescaler) { 1582 if (prescaler) {
1598 *prescaler = best_prescaler; 1583 *prescaler = best_prescaler;
1599 /* dbg("%s - %d %d", __func__, *prescaler, div); */ 1584 /* dev_dbg(&port->dev, "%s - %d %d\n", __func__, *prescaler, div); */
1600 } 1585 }
1601 return KEYSPAN_BAUD_RATE_OK; 1586 return KEYSPAN_BAUD_RATE_OK;
1602} 1587}
1603 1588
1604 /* USA-28 supports different maximum baud rates on each port */ 1589 /* USA-28 supports different maximum baud rates on each port */
1605static int keyspan_usa28_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi, 1590static int keyspan_usa28_calc_baud(struct usb_serial_port *port,
1606 u8 *rate_low, u8 *prescaler, int portnum) 1591 u32 baud_rate, u32 baudclk, u8 *rate_hi,
1592 u8 *rate_low, u8 *prescaler, int portnum)
1607{ 1593{
1608 u32 b16, /* baud rate times 16 (actual rate used internally) */ 1594 u32 b16, /* baud rate times 16 (actual rate used internally) */
1609 div, /* divisor */ 1595 div, /* divisor */
1610 cnt; /* inverse of divisor (programmed into 8051) */ 1596 cnt; /* inverse of divisor (programmed into 8051) */
1611 1597
1612 dbg("%s - %d.", __func__, baud_rate); 1598 dev_dbg(&port->dev, "%s - %d.\n", __func__, baud_rate);
1613 1599
1614 /* prevent divide by zero */ 1600 /* prevent divide by zero */
1615 b16 = baud_rate * 16L; 1601 b16 = baud_rate * 16L;
@@ -1642,7 +1628,7 @@ static int keyspan_usa28_calc_baud(u32 baud_rate, u32 baudclk, u8 *rate_hi,
1642 *rate_low = (u8) (cnt & 0xff); 1628 *rate_low = (u8) (cnt & 0xff);
1643 if (rate_hi) 1629 if (rate_hi)
1644 *rate_hi = (u8) ((cnt >> 8) & 0xff); 1630 *rate_hi = (u8) ((cnt >> 8) & 0xff);
1645 dbg("%s - %d OK.", __func__, baud_rate); 1631 dev_dbg(&port->dev, "%s - %d OK.\n", __func__, baud_rate);
1646 return KEYSPAN_BAUD_RATE_OK; 1632 return KEYSPAN_BAUD_RATE_OK;
1647} 1633}
1648 1634
@@ -1658,7 +1644,7 @@ static int keyspan_usa26_send_setup(struct usb_serial *serial,
1658 struct urb *this_urb; 1644 struct urb *this_urb;
1659 int device_port, err; 1645 int device_port, err;
1660 1646
1661 dbg("%s reset=%d", __func__, reset_port); 1647 dev_dbg(&port->dev, "%s reset=%d\n", __func__, reset_port);
1662 1648
1663 s_priv = usb_get_serial_data(serial); 1649 s_priv = usb_get_serial_data(serial);
1664 p_priv = usb_get_serial_port_data(port); 1650 p_priv = usb_get_serial_port_data(port);
@@ -1668,11 +1654,11 @@ static int keyspan_usa26_send_setup(struct usb_serial *serial,
1668 outcont_urb = d_details->outcont_endpoints[port->number]; 1654 outcont_urb = d_details->outcont_endpoints[port->number];
1669 this_urb = p_priv->outcont_urb; 1655 this_urb = p_priv->outcont_urb;
1670 1656
1671 dbg("%s - endpoint %d", __func__, usb_pipeendpoint(this_urb->pipe)); 1657 dev_dbg(&port->dev, "%s - endpoint %d\n", __func__, usb_pipeendpoint(this_urb->pipe));
1672 1658
1673 /* Make sure we have an urb then send the message */ 1659 /* Make sure we have an urb then send the message */
1674 if (this_urb == NULL) { 1660 if (this_urb == NULL) {
1675 dbg("%s - oops no urb.", __func__); 1661 dev_dbg(&port->dev, "%s - oops no urb.\n", __func__);
1676 return -1; 1662 return -1;
1677 } 1663 }
1678 1664
@@ -1681,7 +1667,7 @@ static int keyspan_usa26_send_setup(struct usb_serial *serial,
1681 if ((reset_port + 1) > p_priv->resend_cont) 1667 if ((reset_port + 1) > p_priv->resend_cont)
1682 p_priv->resend_cont = reset_port + 1; 1668 p_priv->resend_cont = reset_port + 1;
1683 if (this_urb->status == -EINPROGRESS) { 1669 if (this_urb->status == -EINPROGRESS) {
1684 /* dbg("%s - already writing", __func__); */ 1670 /* dev_dbg(&port->dev, "%s - already writing\n", __func__); */
1685 mdelay(5); 1671 mdelay(5);
1686 return -1; 1672 return -1;
1687 } 1673 }
@@ -1692,11 +1678,11 @@ static int keyspan_usa26_send_setup(struct usb_serial *serial,
1692 if (p_priv->old_baud != p_priv->baud) { 1678 if (p_priv->old_baud != p_priv->baud) {
1693 p_priv->old_baud = p_priv->baud; 1679 p_priv->old_baud = p_priv->baud;
1694 msg.setClocking = 0xff; 1680 msg.setClocking = 0xff;
1695 if (d_details->calculate_baud_rate 1681 if (d_details->calculate_baud_rate(port, p_priv->baud, d_details->baudclk,
1696 (p_priv->baud, d_details->baudclk, &msg.baudHi, 1682 &msg.baudHi, &msg.baudLo, &msg.prescaler,
1697 &msg.baudLo, &msg.prescaler, device_port) == KEYSPAN_INVALID_BAUD_RATE) { 1683 device_port) == KEYSPAN_INVALID_BAUD_RATE) {
1698 dbg("%s - Invalid baud rate %d requested, using 9600.", 1684 dev_dbg(&port->dev, "%s - Invalid baud rate %d requested, using 9600.\n",
1699 __func__, p_priv->baud); 1685 __func__, p_priv->baud);
1700 msg.baudLo = 0; 1686 msg.baudLo = 0;
1701 msg.baudHi = 125; /* Values for 9600 baud */ 1687 msg.baudHi = 125; /* Values for 9600 baud */
1702 msg.prescaler = 10; 1688 msg.prescaler = 10;
@@ -1790,12 +1776,12 @@ static int keyspan_usa26_send_setup(struct usb_serial *serial,
1790 1776
1791 err = usb_submit_urb(this_urb, GFP_ATOMIC); 1777 err = usb_submit_urb(this_urb, GFP_ATOMIC);
1792 if (err != 0) 1778 if (err != 0)
1793 dbg("%s - usb_submit_urb(setup) failed (%d)", __func__, err); 1779 dev_dbg(&port->dev, "%s - usb_submit_urb(setup) failed (%d)\n", __func__, err);
1794#if 0 1780#if 0
1795 else { 1781 else {
1796 dbg("%s - usb_submit_urb(%d) OK %d bytes (end %d)", __func__ 1782 dev_dbg(&port->dev, "%s - usb_submit_urb(%d) OK %d bytes (end %d)\n", __func__
1797 outcont_urb, this_urb->transfer_buffer_length, 1783 outcont_urb, this_urb->transfer_buffer_length,
1798 usb_pipeendpoint(this_urb->pipe)); 1784 usb_pipeendpoint(this_urb->pipe));
1799 } 1785 }
1800#endif 1786#endif
1801 1787
@@ -1821,7 +1807,7 @@ static int keyspan_usa28_send_setup(struct usb_serial *serial,
1821 /* only do something if we have a bulk out endpoint */ 1807 /* only do something if we have a bulk out endpoint */
1822 this_urb = p_priv->outcont_urb; 1808 this_urb = p_priv->outcont_urb;
1823 if (this_urb == NULL) { 1809 if (this_urb == NULL) {
1824 dbg("%s - oops no urb.", __func__); 1810 dev_dbg(&port->dev, "%s - oops no urb.\n", __func__);
1825 return -1; 1811 return -1;
1826 } 1812 }
1827 1813
@@ -1830,7 +1816,7 @@ static int keyspan_usa28_send_setup(struct usb_serial *serial,
1830 if ((reset_port + 1) > p_priv->resend_cont) 1816 if ((reset_port + 1) > p_priv->resend_cont)
1831 p_priv->resend_cont = reset_port + 1; 1817 p_priv->resend_cont = reset_port + 1;
1832 if (this_urb->status == -EINPROGRESS) { 1818 if (this_urb->status == -EINPROGRESS) {
1833 dbg("%s already writing", __func__); 1819 dev_dbg(&port->dev, "%s already writing\n", __func__);
1834 mdelay(5); 1820 mdelay(5);
1835 return -1; 1821 return -1;
1836 } 1822 }
@@ -1838,9 +1824,10 @@ static int keyspan_usa28_send_setup(struct usb_serial *serial,
1838 memset(&msg, 0, sizeof(struct keyspan_usa28_portControlMessage)); 1824 memset(&msg, 0, sizeof(struct keyspan_usa28_portControlMessage));
1839 1825
1840 msg.setBaudRate = 1; 1826 msg.setBaudRate = 1;
1841 if (d_details->calculate_baud_rate(p_priv->baud, d_details->baudclk, 1827 if (d_details->calculate_baud_rate(port, p_priv->baud, d_details->baudclk,
1842 &msg.baudHi, &msg.baudLo, NULL, device_port) == KEYSPAN_INVALID_BAUD_RATE) { 1828 &msg.baudHi, &msg.baudLo, NULL,
1843 dbg("%s - Invalid baud rate requested %d.", 1829 device_port) == KEYSPAN_INVALID_BAUD_RATE) {
1830 dev_dbg(&port->dev, "%s - Invalid baud rate requested %d.\n",
1844 __func__, p_priv->baud); 1831 __func__, p_priv->baud);
1845 msg.baudLo = 0xff; 1832 msg.baudLo = 0xff;
1846 msg.baudHi = 0xb2; /* Values for 9600 baud */ 1833 msg.baudHi = 0xb2; /* Values for 9600 baud */
@@ -1915,10 +1902,10 @@ static int keyspan_usa28_send_setup(struct usb_serial *serial,
1915 1902
1916 err = usb_submit_urb(this_urb, GFP_ATOMIC); 1903 err = usb_submit_urb(this_urb, GFP_ATOMIC);
1917 if (err != 0) 1904 if (err != 0)
1918 dbg("%s - usb_submit_urb(setup) failed", __func__); 1905 dev_dbg(&port->dev, "%s - usb_submit_urb(setup) failed\n", __func__);
1919#if 0 1906#if 0
1920 else { 1907 else {
1921 dbg("%s - usb_submit_urb(setup) OK %d bytes", __func__, 1908 dev_dbg(&port->dev, "%s - usb_submit_urb(setup) OK %d bytes\n", __func__,
1922 this_urb->transfer_buffer_length); 1909 this_urb->transfer_buffer_length);
1923 } 1910 }
1924#endif 1911#endif
@@ -1949,13 +1936,13 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial,
1949 1936
1950 /* Make sure we have an urb then send the message */ 1937 /* Make sure we have an urb then send the message */
1951 if (this_urb == NULL) { 1938 if (this_urb == NULL) {
1952 dbg("%s - oops no urb for port %d.", __func__, port->number); 1939 dev_dbg(&port->dev, "%s - oops no urb for port %d.\n", __func__, port->number);
1953 return -1; 1940 return -1;
1954 } 1941 }
1955 1942
1956 dbg("%s - endpoint %d port %d (%d)", 1943 dev_dbg(&port->dev, "%s - endpoint %d port %d (%d)\n",
1957 __func__, usb_pipeendpoint(this_urb->pipe), 1944 __func__, usb_pipeendpoint(this_urb->pipe),
1958 port->number, device_port); 1945 port->number, device_port);
1959 1946
1960 /* Save reset port val for resend. 1947 /* Save reset port val for resend.
1961 Don't overwrite resend for open/close condition. */ 1948 Don't overwrite resend for open/close condition. */
@@ -1963,7 +1950,7 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial,
1963 p_priv->resend_cont = reset_port + 1; 1950 p_priv->resend_cont = reset_port + 1;
1964 1951
1965 if (this_urb->status == -EINPROGRESS) { 1952 if (this_urb->status == -EINPROGRESS) {
1966 /* dbg("%s - already writing", __func__); */ 1953 /* dev_dbg(&port->dev, "%s - already writing\n", __func__); */
1967 mdelay(5); 1954 mdelay(5);
1968 return -1; 1955 return -1;
1969 } 1956 }
@@ -1977,11 +1964,11 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial,
1977 if (p_priv->old_baud != p_priv->baud) { 1964 if (p_priv->old_baud != p_priv->baud) {
1978 p_priv->old_baud = p_priv->baud; 1965 p_priv->old_baud = p_priv->baud;
1979 msg.setClocking = 0xff; 1966 msg.setClocking = 0xff;
1980 if (d_details->calculate_baud_rate 1967 if (d_details->calculate_baud_rate(port, p_priv->baud, d_details->baudclk,
1981 (p_priv->baud, d_details->baudclk, &msg.baudHi, 1968 &msg.baudHi, &msg.baudLo, &msg.prescaler,
1982 &msg.baudLo, &msg.prescaler, device_port) == KEYSPAN_INVALID_BAUD_RATE) { 1969 device_port) == KEYSPAN_INVALID_BAUD_RATE) {
1983 dbg("%s - Invalid baud rate %d requested, using 9600.", 1970 dev_dbg(&port->dev, "%s - Invalid baud rate %d requested, using 9600.\n",
1984 __func__, p_priv->baud); 1971 __func__, p_priv->baud);
1985 msg.baudLo = 0; 1972 msg.baudLo = 0;
1986 msg.baudHi = 125; /* Values for 9600 baud */ 1973 msg.baudHi = 125; /* Values for 9600 baud */
1987 msg.prescaler = 10; 1974 msg.prescaler = 10;
@@ -2100,12 +2087,12 @@ static int keyspan_usa49_send_setup(struct usb_serial *serial,
2100 } 2087 }
2101 err = usb_submit_urb(this_urb, GFP_ATOMIC); 2088 err = usb_submit_urb(this_urb, GFP_ATOMIC);
2102 if (err != 0) 2089 if (err != 0)
2103 dbg("%s - usb_submit_urb(setup) failed (%d)", __func__, err); 2090 dev_dbg(&port->dev, "%s - usb_submit_urb(setup) failed (%d)\n", __func__, err);
2104#if 0 2091#if 0
2105 else { 2092 else {
2106 dbg("%s - usb_submit_urb(%d) OK %d bytes (end %d)", __func__, 2093 dev_dbg(&port->dev, "%s - usb_submit_urb(%d) OK %d bytes (end %d)\n", __func__,
2107 outcont_urb, this_urb->transfer_buffer_length, 2094 outcont_urb, this_urb->transfer_buffer_length,
2108 usb_pipeendpoint(this_urb->pipe)); 2095 usb_pipeendpoint(this_urb->pipe));
2109 } 2096 }
2110#endif 2097#endif
2111 2098
@@ -2131,7 +2118,7 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial,
2131 /* only do something if we have a bulk out endpoint */ 2118 /* only do something if we have a bulk out endpoint */
2132 this_urb = p_priv->outcont_urb; 2119 this_urb = p_priv->outcont_urb;
2133 if (this_urb == NULL) { 2120 if (this_urb == NULL) {
2134 dbg("%s - oops no urb.", __func__); 2121 dev_dbg(&port->dev, "%s - oops no urb.\n", __func__);
2135 return -1; 2122 return -1;
2136 } 2123 }
2137 2124
@@ -2140,7 +2127,7 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial,
2140 if ((reset_port + 1) > p_priv->resend_cont) 2127 if ((reset_port + 1) > p_priv->resend_cont)
2141 p_priv->resend_cont = reset_port + 1; 2128 p_priv->resend_cont = reset_port + 1;
2142 if (this_urb->status == -EINPROGRESS) { 2129 if (this_urb->status == -EINPROGRESS) {
2143 dbg("%s already writing", __func__); 2130 dev_dbg(&port->dev, "%s already writing\n", __func__);
2144 mdelay(5); 2131 mdelay(5);
2145 return -1; 2132 return -1;
2146 } 2133 }
@@ -2151,13 +2138,12 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial,
2151 if (p_priv->old_baud != p_priv->baud) { 2138 if (p_priv->old_baud != p_priv->baud) {
2152 p_priv->old_baud = p_priv->baud; 2139 p_priv->old_baud = p_priv->baud;
2153 msg.setClocking = 0x01; 2140 msg.setClocking = 0x01;
2154 if (d_details->calculate_baud_rate 2141 if (d_details->calculate_baud_rate(port, p_priv->baud, d_details->baudclk,
2155 (p_priv->baud, d_details->baudclk, &msg.baudHi, 2142 &msg.baudHi, &msg.baudLo, &prescaler, 0) == KEYSPAN_INVALID_BAUD_RATE) {
2156 &msg.baudLo, &prescaler, 0) == KEYSPAN_INVALID_BAUD_RATE) { 2143 dev_dbg(&port->dev, "%s - Invalid baud rate %d requested, using 9600.\n",
2157 dbg("%s - Invalid baud rate %d requested, using 9600.", 2144 __func__, p_priv->baud);
2158 __func__, p_priv->baud);
2159 p_priv->baud = 9600; 2145 p_priv->baud = 9600;
2160 d_details->calculate_baud_rate(p_priv->baud, d_details->baudclk, 2146 d_details->calculate_baud_rate(port, p_priv->baud, d_details->baudclk,
2161 &msg.baudHi, &msg.baudLo, &prescaler, 0); 2147 &msg.baudHi, &msg.baudLo, &prescaler, 0);
2162 } 2148 }
2163 msg.setRxMode = 1; 2149 msg.setRxMode = 1;
@@ -2239,7 +2225,7 @@ static int keyspan_usa90_send_setup(struct usb_serial *serial,
2239 2225
2240 err = usb_submit_urb(this_urb, GFP_ATOMIC); 2226 err = usb_submit_urb(this_urb, GFP_ATOMIC);
2241 if (err != 0) 2227 if (err != 0)
2242 dbg("%s - usb_submit_urb(setup) failed (%d)", __func__, err); 2228 dev_dbg(&port->dev, "%s - usb_submit_urb(setup) failed (%d)\n", __func__, err);
2243 return 0; 2229 return 0;
2244} 2230}
2245 2231
@@ -2265,7 +2251,7 @@ static int keyspan_usa67_send_setup(struct usb_serial *serial,
2265 2251
2266 /* Make sure we have an urb then send the message */ 2252 /* Make sure we have an urb then send the message */
2267 if (this_urb == NULL) { 2253 if (this_urb == NULL) {
2268 dbg("%s - oops no urb for port %d.", __func__, 2254 dev_dbg(&port->dev, "%s - oops no urb for port %d.\n", __func__,
2269 port->number); 2255 port->number);
2270 return -1; 2256 return -1;
2271 } 2257 }
@@ -2275,7 +2261,7 @@ static int keyspan_usa67_send_setup(struct usb_serial *serial,
2275 if ((reset_port + 1) > p_priv->resend_cont) 2261 if ((reset_port + 1) > p_priv->resend_cont)
2276 p_priv->resend_cont = reset_port + 1; 2262 p_priv->resend_cont = reset_port + 1;
2277 if (this_urb->status == -EINPROGRESS) { 2263 if (this_urb->status == -EINPROGRESS) {
2278 /* dbg("%s - already writing", __func__); */ 2264 /* dev_dbg(&port->dev, "%s - already writing\n", __func__); */
2279 mdelay(5); 2265 mdelay(5);
2280 return -1; 2266 return -1;
2281 } 2267 }
@@ -2288,11 +2274,11 @@ static int keyspan_usa67_send_setup(struct usb_serial *serial,
2288 if (p_priv->old_baud != p_priv->baud) { 2274 if (p_priv->old_baud != p_priv->baud) {
2289 p_priv->old_baud = p_priv->baud; 2275 p_priv->old_baud = p_priv->baud;
2290 msg.setClocking = 0xff; 2276 msg.setClocking = 0xff;
2291 if (d_details->calculate_baud_rate 2277 if (d_details->calculate_baud_rate(port, p_priv->baud, d_details->baudclk,
2292 (p_priv->baud, d_details->baudclk, &msg.baudHi, 2278 &msg.baudHi, &msg.baudLo, &msg.prescaler,
2293 &msg.baudLo, &msg.prescaler, device_port) == KEYSPAN_INVALID_BAUD_RATE) { 2279 device_port) == KEYSPAN_INVALID_BAUD_RATE) {
2294 dbg("%s - Invalid baud rate %d requested, using 9600.", 2280 dev_dbg(&port->dev, "%s - Invalid baud rate %d requested, using 9600.\n",
2295 __func__, p_priv->baud); 2281 __func__, p_priv->baud);
2296 msg.baudLo = 0; 2282 msg.baudLo = 0;
2297 msg.baudHi = 125; /* Values for 9600 baud */ 2283 msg.baudHi = 125; /* Values for 9600 baud */
2298 msg.prescaler = 10; 2284 msg.prescaler = 10;
@@ -2383,8 +2369,7 @@ static int keyspan_usa67_send_setup(struct usb_serial *serial,
2383 2369
2384 err = usb_submit_urb(this_urb, GFP_ATOMIC); 2370 err = usb_submit_urb(this_urb, GFP_ATOMIC);
2385 if (err != 0) 2371 if (err != 0)
2386 dbg("%s - usb_submit_urb(setup) failed (%d)", __func__, 2372 dev_dbg(&port->dev, "%s - usb_submit_urb(setup) failed (%d)\n", __func__, err);
2387 err);
2388 return 0; 2373 return 0;
2389} 2374}
2390 2375
@@ -2440,8 +2425,7 @@ static int keyspan_startup(struct usb_serial *serial)
2440 /* Setup private data for serial driver */ 2425 /* Setup private data for serial driver */
2441 s_priv = kzalloc(sizeof(struct keyspan_serial_private), GFP_KERNEL); 2426 s_priv = kzalloc(sizeof(struct keyspan_serial_private), GFP_KERNEL);
2442 if (!s_priv) { 2427 if (!s_priv) {
2443 dbg("%s - kmalloc for keyspan_serial_private failed.", 2428 dev_dbg(&serial->dev->dev, "%s - kmalloc for keyspan_serial_private failed.\n", __func__);
2444 __func__);
2445 return -ENOMEM; 2429 return -ENOMEM;
2446 } 2430 }
2447 2431
@@ -2454,7 +2438,7 @@ static int keyspan_startup(struct usb_serial *serial)
2454 p_priv = kzalloc(sizeof(struct keyspan_port_private), 2438 p_priv = kzalloc(sizeof(struct keyspan_port_private),
2455 GFP_KERNEL); 2439 GFP_KERNEL);
2456 if (!p_priv) { 2440 if (!p_priv) {
2457 dbg("%s - kmalloc for keyspan_port_private (%d) failed!.", __func__, i); 2441 dev_dbg(&port->dev, "%s - kmalloc for keyspan_port_private (%d) failed!.\n", __func__, i);
2458 return 1; 2442 return 1;
2459 } 2443 }
2460 p_priv->device_details = d_details; 2444 p_priv->device_details = d_details;
@@ -2466,14 +2450,12 @@ static int keyspan_startup(struct usb_serial *serial)
2466 if (s_priv->instat_urb != NULL) { 2450 if (s_priv->instat_urb != NULL) {
2467 err = usb_submit_urb(s_priv->instat_urb, GFP_KERNEL); 2451 err = usb_submit_urb(s_priv->instat_urb, GFP_KERNEL);
2468 if (err != 0) 2452 if (err != 0)
2469 dbg("%s - submit instat urb failed %d", __func__, 2453 dev_dbg(&serial->dev->dev, "%s - submit instat urb failed %d\n", __func__, err);
2470 err);
2471 } 2454 }
2472 if (s_priv->indat_urb != NULL) { 2455 if (s_priv->indat_urb != NULL) {
2473 err = usb_submit_urb(s_priv->indat_urb, GFP_KERNEL); 2456 err = usb_submit_urb(s_priv->indat_urb, GFP_KERNEL);
2474 if (err != 0) 2457 if (err != 0)
2475 dbg("%s - submit indat urb failed %d", __func__, 2458 dev_dbg(&serial->dev->dev, "%s - submit indat urb failed %d\n", __func__, err);
2476 err);
2477 } 2459 }
2478 2460
2479 return 0; 2461 return 0;
@@ -2527,10 +2509,8 @@ static void keyspan_release(struct usb_serial *serial)
2527 2509
2528 s_priv = usb_get_serial_data(serial); 2510 s_priv = usb_get_serial_data(serial);
2529 2511
2530 /* dbg("Freeing serial->private."); */
2531 kfree(s_priv); 2512 kfree(s_priv);
2532 2513
2533 /* dbg("Freeing port->private."); */
2534 /* Now free per port private data */ 2514 /* Now free per port private data */
2535 for (i = 0; i < serial->num_ports; i++) { 2515 for (i = 0; i < serial->num_ports; i++) {
2536 port = serial->port[i]; 2516 port = serial->port[i];
@@ -2554,7 +2534,3 @@ MODULE_FIRMWARE("keyspan/usa18x.fw");
2554MODULE_FIRMWARE("keyspan/usa19w.fw"); 2534MODULE_FIRMWARE("keyspan/usa19w.fw");
2555MODULE_FIRMWARE("keyspan/usa49w.fw"); 2535MODULE_FIRMWARE("keyspan/usa49w.fw");
2556MODULE_FIRMWARE("keyspan/usa49wlc.fw"); 2536MODULE_FIRMWARE("keyspan/usa49wlc.fw");
2557
2558module_param(debug, bool, S_IRUGO | S_IWUSR);
2559MODULE_PARM_DESC(debug, "Debug enabled or not");
2560
diff --git a/drivers/usb/serial/keyspan.h b/drivers/usb/serial/keyspan.h
index fe1c5d91692c..0a8a40b5711e 100644
--- a/drivers/usb/serial/keyspan.h
+++ b/drivers/usb/serial/keyspan.h
@@ -64,19 +64,23 @@ static int keyspan_tiocmset (struct tty_struct *tty,
64 unsigned int clear); 64 unsigned int clear);
65static int keyspan_fake_startup (struct usb_serial *serial); 65static int keyspan_fake_startup (struct usb_serial *serial);
66 66
67static int keyspan_usa19_calc_baud (u32 baud_rate, u32 baudclk, 67static int keyspan_usa19_calc_baud (struct usb_serial_port *port,
68 u32 baud_rate, u32 baudclk,
68 u8 *rate_hi, u8 *rate_low, 69 u8 *rate_hi, u8 *rate_low,
69 u8 *prescaler, int portnum); 70 u8 *prescaler, int portnum);
70 71
71static int keyspan_usa19w_calc_baud (u32 baud_rate, u32 baudclk, 72static int keyspan_usa19w_calc_baud (struct usb_serial_port *port,
73 u32 baud_rate, u32 baudclk,
72 u8 *rate_hi, u8 *rate_low, 74 u8 *rate_hi, u8 *rate_low,
73 u8 *prescaler, int portnum); 75 u8 *prescaler, int portnum);
74 76
75static int keyspan_usa28_calc_baud (u32 baud_rate, u32 baudclk, 77static int keyspan_usa28_calc_baud (struct usb_serial_port *port,
78 u32 baud_rate, u32 baudclk,
76 u8 *rate_hi, u8 *rate_low, 79 u8 *rate_hi, u8 *rate_low,
77 u8 *prescaler, int portnum); 80 u8 *prescaler, int portnum);
78 81
79static int keyspan_usa19hs_calc_baud (u32 baud_rate, u32 baudclk, 82static int keyspan_usa19hs_calc_baud (struct usb_serial_port *port,
83 u32 baud_rate, u32 baudclk,
80 u8 *rate_hi, u8 *rate_low, 84 u8 *rate_hi, u8 *rate_low,
81 u8 *prescaler, int portnum); 85 u8 *prescaler, int portnum);
82 86
@@ -188,8 +192,9 @@ struct keyspan_device_details {
188 /* Endpoint used for global control functions */ 192 /* Endpoint used for global control functions */
189 int glocont_endpoint; 193 int glocont_endpoint;
190 194
191 int (*calculate_baud_rate) (u32 baud_rate, u32 baudclk, 195 int (*calculate_baud_rate) (struct usb_serial_port *port,
192 u8 *rate_hi, u8 *rate_low, u8 *prescaler, int portnum); 196 u32 baud_rate, u32 baudclk,
197 u8 *rate_hi, u8 *rate_low, u8 *prescaler, int portnum);
193 u32 baudclk; 198 u32 baudclk;
194}; 199};
195 200
diff --git a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c
index dcada8615fcf..ca43ecb4a2bd 100644
--- a/drivers/usb/serial/keyspan_pda.c
+++ b/drivers/usb/serial/keyspan_pda.c
@@ -25,13 +25,10 @@
25#include <linux/module.h> 25#include <linux/module.h>
26#include <linux/spinlock.h> 26#include <linux/spinlock.h>
27#include <linux/workqueue.h> 27#include <linux/workqueue.h>
28#include <linux/firmware.h>
29#include <linux/ihex.h>
30#include <linux/uaccess.h> 28#include <linux/uaccess.h>
31#include <linux/usb.h> 29#include <linux/usb.h>
32#include <linux/usb/serial.h> 30#include <linux/usb/serial.h>
33 31#include <linux/usb/ezusb.h>
34static bool debug;
35 32
36/* make a simple define to handle if we are compiling keyspan_pda or xircom support */ 33/* make a simple define to handle if we are compiling keyspan_pda or xircom support */
37#if defined(CONFIG_USB_SERIAL_KEYSPAN_PDA) || defined(CONFIG_USB_SERIAL_KEYSPAN_PDA_MODULE) 34#if defined(CONFIG_USB_SERIAL_KEYSPAN_PDA) || defined(CONFIG_USB_SERIAL_KEYSPAN_PDA_MODULE)
@@ -137,8 +134,8 @@ static void keyspan_pda_request_unthrottle(struct work_struct *work)
137 0, 134 0,
138 2000); 135 2000);
139 if (result < 0) 136 if (result < 0)
140 dbg("%s - error %d from usb_control_msg", 137 dev_dbg(&serial->dev->dev, "%s - error %d from usb_control_msg\n",
141 __func__, result); 138 __func__, result);
142} 139}
143 140
144 141
@@ -160,12 +157,10 @@ static void keyspan_pda_rx_interrupt(struct urb *urb)
160 case -ENOENT: 157 case -ENOENT:
161 case -ESHUTDOWN: 158 case -ESHUTDOWN:
162 /* this urb is terminated, clean up */ 159 /* this urb is terminated, clean up */
163 dbg("%s - urb shutting down with status: %d", 160 dev_dbg(&urb->dev->dev, "%s - urb shutting down with status: %d\n", __func__, status);
164 __func__, status);
165 return; 161 return;
166 default: 162 default:
167 dbg("%s - nonzero urb status received: %d", 163 dev_dbg(&urb->dev->dev, "%s - nonzero urb status received: %d\n", __func__, status);
168 __func__, status);
169 goto exit; 164 goto exit;
170 } 165 }
171 166
@@ -183,7 +178,7 @@ static void keyspan_pda_rx_interrupt(struct urb *urb)
183 break; 178 break;
184 case 1: 179 case 1:
185 /* status interrupt */ 180 /* status interrupt */
186 dbg(" rx int, d1=%d, d2=%d", data[1], data[2]); 181 dev_dbg(&port->dev, "rx int, d1=%d, d2=%d\n", data[1], data[2]);
187 switch (data[1]) { 182 switch (data[1]) {
188 case 1: /* modemline change */ 183 case 1: /* modemline change */
189 break; 184 break;
@@ -229,7 +224,7 @@ static void keyspan_pda_rx_unthrottle(struct tty_struct *tty)
229 /* just restart the receive interrupt URB */ 224 /* just restart the receive interrupt URB */
230 225
231 if (usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL)) 226 if (usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL))
232 dbg(" usb_submit_urb(read urb) failed"); 227 dev_dbg(&port->dev, "usb_submit_urb(read urb) failed\n");
233} 228}
234 229
235 230
@@ -308,8 +303,8 @@ static void keyspan_pda_break_ctl(struct tty_struct *tty, int break_state)
308 USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT, 303 USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT,
309 value, 0, NULL, 0, 2000); 304 value, 0, NULL, 0, 2000);
310 if (result < 0) 305 if (result < 0)
311 dbg("%s - error %d from usb_control_msg", 306 dev_dbg(&port->dev, "%s - error %d from usb_control_msg\n",
312 __func__, result); 307 __func__, result);
313 /* there is something funky about this.. the TCSBRK that 'cu' performs 308 /* there is something funky about this.. the TCSBRK that 'cu' performs
314 ought to translate into a break_ctl(-1),break_ctl(0) pair HZ/4 309 ought to translate into a break_ctl(-1),break_ctl(0) pair HZ/4
315 seconds apart, but it feels like the break sent isn't as long as it 310 seconds apart, but it feels like the break sent isn't as long as it
@@ -347,7 +342,7 @@ static void keyspan_pda_set_termios(struct tty_struct *tty,
347 speed = keyspan_pda_setbaud(serial, speed); 342 speed = keyspan_pda_setbaud(serial, speed);
348 343
349 if (speed == 0) { 344 if (speed == 0) {
350 dbg("can't handle requested baud rate"); 345 dev_dbg(&port->dev, "can't handle requested baud rate\n");
351 /* It hasn't changed so.. */ 346 /* It hasn't changed so.. */
352 speed = tty_termios_baud_rate(old_termios); 347 speed = tty_termios_baud_rate(old_termios);
353 } 348 }
@@ -459,7 +454,7 @@ static int keyspan_pda_write(struct tty_struct *tty,
459 Block if we can't write anything at all, otherwise write as much as 454 Block if we can't write anything at all, otherwise write as much as
460 we can. */ 455 we can. */
461 if (count == 0) { 456 if (count == 0) {
462 dbg(" write request of 0 bytes"); 457 dev_dbg(&port->dev, "write request of 0 bytes\n");
463 return 0; 458 return 0;
464 } 459 }
465 460
@@ -505,16 +500,16 @@ static int keyspan_pda_write(struct tty_struct *tty,
505 1, 500 1,
506 2000); 501 2000);
507 if (rc > 0) { 502 if (rc > 0) {
508 dbg(" roomquery says %d", *room); 503 dev_dbg(&port->dev, "roomquery says %d\n", *room);
509 priv->tx_room = *room; 504 priv->tx_room = *room;
510 } 505 }
511 kfree(room); 506 kfree(room);
512 if (rc < 0) { 507 if (rc < 0) {
513 dbg(" roomquery failed"); 508 dev_dbg(&port->dev, "roomquery failed\n");
514 goto exit; 509 goto exit;
515 } 510 }
516 if (rc == 0) { 511 if (rc == 0) {
517 dbg(" roomquery returned 0 bytes"); 512 dev_dbg(&port->dev, "roomquery returned 0 bytes\n");
518 rc = -EIO; /* device didn't return any data */ 513 rc = -EIO; /* device didn't return any data */
519 goto exit; 514 goto exit;
520 } 515 }
@@ -536,7 +531,7 @@ static int keyspan_pda_write(struct tty_struct *tty,
536 531
537 rc = usb_submit_urb(port->write_urb, GFP_ATOMIC); 532 rc = usb_submit_urb(port->write_urb, GFP_ATOMIC);
538 if (rc) { 533 if (rc) {
539 dbg(" usb_submit_urb(write bulk) failed"); 534 dev_dbg(&port->dev, "usb_submit_urb(write bulk) failed\n");
540 goto exit; 535 goto exit;
541 } 536 }
542 } else { 537 } else {
@@ -639,11 +634,11 @@ static int keyspan_pda_open(struct tty_struct *tty,
639 1, 634 1,
640 2000); 635 2000);
641 if (rc < 0) { 636 if (rc < 0) {
642 dbg("%s - roomquery failed", __func__); 637 dev_dbg(&port->dev, "%s - roomquery failed\n", __func__);
643 goto error; 638 goto error;
644 } 639 }
645 if (rc == 0) { 640 if (rc == 0) {
646 dbg("%s - roomquery returned 0 bytes", __func__); 641 dev_dbg(&port->dev, "%s - roomquery returned 0 bytes\n", __func__);
647 rc = -EIO; 642 rc = -EIO;
648 goto error; 643 goto error;
649 } 644 }
@@ -654,7 +649,7 @@ static int keyspan_pda_open(struct tty_struct *tty,
654 /*Start reading from the device*/ 649 /*Start reading from the device*/
655 rc = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); 650 rc = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
656 if (rc) { 651 if (rc) {
657 dbg("%s - usb_submit_urb(read int) failed", __func__); 652 dev_dbg(&port->dev, "%s - usb_submit_urb(read int) failed\n", __func__);
658 goto error; 653 goto error;
659 } 654 }
660error: 655error:
@@ -678,11 +673,9 @@ static int keyspan_pda_fake_startup(struct usb_serial *serial)
678{ 673{
679 int response; 674 int response;
680 const char *fw_name; 675 const char *fw_name;
681 const struct ihex_binrec *record;
682 const struct firmware *fw;
683 676
684 /* download the firmware here ... */ 677 /* download the firmware here ... */
685 response = ezusb_set_reset(serial, 1); 678 response = ezusb_fx1_set_reset(serial->dev, 1);
686 679
687 if (0) { ; } 680 if (0) { ; }
688#ifdef KEYSPAN 681#ifdef KEYSPAN
@@ -699,30 +692,15 @@ static int keyspan_pda_fake_startup(struct usb_serial *serial)
699 __func__); 692 __func__);
700 return -ENODEV; 693 return -ENODEV;
701 } 694 }
702 if (request_ihex_firmware(&fw, fw_name, &serial->dev->dev)) { 695
696 if (ezusb_fx1_ihex_firmware_download(serial->dev, fw_name) < 0) {
703 dev_err(&serial->dev->dev, "failed to load firmware \"%s\"\n", 697 dev_err(&serial->dev->dev, "failed to load firmware \"%s\"\n",
704 fw_name); 698 fw_name);
705 return -ENOENT; 699 return -ENOENT;
706 } 700 }
707 record = (const struct ihex_binrec *)fw->data; 701
708 702 /* after downloading firmware Renumeration will occur in a
709 while (record) { 703 moment and the new device will bind to the real driver */
710 response = ezusb_writememory(serial, be32_to_cpu(record->addr),
711 (unsigned char *)record->data,
712 be16_to_cpu(record->len), 0xa0);
713 if (response < 0) {
714 dev_err(&serial->dev->dev, "ezusb_writememory failed "
715 "for Keyspan PDA firmware (%d %04X %p %d)\n",
716 response, be32_to_cpu(record->addr),
717 record->data, be16_to_cpu(record->len));
718 break;
719 }
720 record = ihex_next_binrec(record);
721 }
722 release_firmware(fw);
723 /* bring device out of reset. Renumeration will occur in a moment
724 and the new device will bind to the real driver */
725 response = ezusb_set_reset(serial, 0);
726 704
727 /* we want this device to fail to have a driver assigned to it. */ 705 /* we want this device to fail to have a driver assigned to it. */
728 return 1; 706 return 1;
@@ -828,6 +806,3 @@ module_usb_serial_driver(serial_drivers, id_table_combined);
828MODULE_AUTHOR(DRIVER_AUTHOR); 806MODULE_AUTHOR(DRIVER_AUTHOR);
829MODULE_DESCRIPTION(DRIVER_DESC); 807MODULE_DESCRIPTION(DRIVER_DESC);
830MODULE_LICENSE("GPL"); 808MODULE_LICENSE("GPL");
831
832module_param(debug, bool, S_IRUGO | S_IWUSR);
833MODULE_PARM_DESC(debug, "Debug enabled or not");
diff --git a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c
index def9ad258715..3f6d7376c02d 100644
--- a/drivers/usb/serial/kl5kusb105.c
+++ b/drivers/usb/serial/kl5kusb105.c
@@ -49,8 +49,6 @@
49#include <linux/usb/serial.h> 49#include <linux/usb/serial.h>
50#include "kl5kusb105.h" 50#include "kl5kusb105.h"
51 51
52static bool debug;
53
54/* 52/*
55 * Version Information 53 * Version Information
56 */ 54 */
@@ -239,7 +237,9 @@ static int klsi_105_startup(struct usb_serial *serial)
239 priv = kmalloc(sizeof(struct klsi_105_private), 237 priv = kmalloc(sizeof(struct klsi_105_private),
240 GFP_KERNEL); 238 GFP_KERNEL);
241 if (!priv) { 239 if (!priv) {
242 dbg("%skmalloc for klsi_105_private failed.", __func__); 240 dev_dbg(&serial->interface->dev,
241 "%s - kmalloc for klsi_105_private failed.\n",
242 __func__);
243 i--; 243 i--;
244 goto err_cleanup; 244 goto err_cleanup;
245 } 245 }
@@ -344,14 +344,14 @@ static int klsi_105_open(struct tty_struct *tty, struct usb_serial_port *port)
344 dev_err(&port->dev, "Enabling read failed (error = %d)\n", rc); 344 dev_err(&port->dev, "Enabling read failed (error = %d)\n", rc);
345 retval = rc; 345 retval = rc;
346 } else 346 } else
347 dbg("%s - enabled reading", __func__); 347 dev_dbg(&port->dev, "%s - enabled reading\n", __func__);
348 348
349 rc = klsi_105_get_line_state(port, &line_state); 349 rc = klsi_105_get_line_state(port, &line_state);
350 if (rc >= 0) { 350 if (rc >= 0) {
351 spin_lock_irqsave(&priv->lock, flags); 351 spin_lock_irqsave(&priv->lock, flags);
352 priv->line_state = line_state; 352 priv->line_state = line_state;
353 spin_unlock_irqrestore(&priv->lock, flags); 353 spin_unlock_irqrestore(&priv->lock, flags);
354 dbg("%s - read line state 0x%lx", __func__, line_state); 354 dev_dbg(&port->dev, "%s - read line state 0x%lx\n", __func__, line_state);
355 retval = 0; 355 retval = 0;
356 } else 356 } else
357 retval = rc; 357 retval = rc;
@@ -421,7 +421,7 @@ static void klsi_105_process_read_urb(struct urb *urb)
421 return; 421 return;
422 422
423 if (urb->actual_length <= KLSI_HDR_LEN) { 423 if (urb->actual_length <= KLSI_HDR_LEN) {
424 dbg("%s - malformed packet", __func__); 424 dev_dbg(&port->dev, "%s - malformed packet\n", __func__);
425 return; 425 return;
426 } 426 }
427 427
@@ -431,7 +431,7 @@ static void klsi_105_process_read_urb(struct urb *urb)
431 431
432 len = get_unaligned_le16(data); 432 len = get_unaligned_le16(data);
433 if (len > urb->actual_length - KLSI_HDR_LEN) { 433 if (len > urb->actual_length - KLSI_HDR_LEN) {
434 dbg("%s - packet length mismatch", __func__); 434 dev_dbg(&port->dev, "%s - packet length mismatch\n", __func__);
435 len = urb->actual_length - KLSI_HDR_LEN; 435 len = urb->actual_length - KLSI_HDR_LEN;
436 } 436 }
437 437
@@ -445,6 +445,7 @@ static void klsi_105_set_termios(struct tty_struct *tty,
445 struct ktermios *old_termios) 445 struct ktermios *old_termios)
446{ 446{
447 struct klsi_105_private *priv = usb_get_serial_port_data(port); 447 struct klsi_105_private *priv = usb_get_serial_port_data(port);
448 struct device *dev = &port->dev;
448 unsigned int iflag = tty->termios.c_iflag; 449 unsigned int iflag = tty->termios.c_iflag;
449 unsigned int old_iflag = old_termios->c_iflag; 450 unsigned int old_iflag = old_termios->c_iflag;
450 unsigned int cflag = tty->termios.c_cflag; 451 unsigned int cflag = tty->termios.c_cflag;
@@ -455,8 +456,7 @@ static void klsi_105_set_termios(struct tty_struct *tty,
455 456
456 cfg = kmalloc(sizeof(*cfg), GFP_KERNEL); 457 cfg = kmalloc(sizeof(*cfg), GFP_KERNEL);
457 if (!cfg) { 458 if (!cfg) {
458 dev_err(&port->dev, "%s - out of memory for config buffer.\n", 459 dev_err(dev, "%s - out of memory for config buffer.\n", __func__);
459 __func__);
460 return; 460 return;
461 } 461 }
462 462
@@ -471,7 +471,7 @@ static void klsi_105_set_termios(struct tty_struct *tty,
471 if ((cflag & CBAUD) != (old_cflag & CBAUD)) { 471 if ((cflag & CBAUD) != (old_cflag & CBAUD)) {
472 /* reassert DTR and (maybe) RTS on transition from B0 */ 472 /* reassert DTR and (maybe) RTS on transition from B0 */
473 if ((old_cflag & CBAUD) == B0) { 473 if ((old_cflag & CBAUD) == B0) {
474 dbg("%s: baud was B0", __func__); 474 dev_dbg(dev, "%s: baud was B0\n", __func__);
475#if 0 475#if 0
476 priv->control_state |= TIOCM_DTR; 476 priv->control_state |= TIOCM_DTR;
477 /* don't set RTS if using hardware flow control */ 477 /* don't set RTS if using hardware flow control */
@@ -509,14 +509,13 @@ static void klsi_105_set_termios(struct tty_struct *tty,
509 priv->cfg.baudrate = kl5kusb105a_sio_b115200; 509 priv->cfg.baudrate = kl5kusb105a_sio_b115200;
510 break; 510 break;
511 default: 511 default:
512 dbg("KLSI USB->Serial converter:" 512 dev_dbg(dev, "KLSI USB->Serial converter: unsupported baudrate request, using default of 9600");
513 " unsupported baudrate request, using default of 9600"); 513 priv->cfg.baudrate = kl5kusb105a_sio_b9600;
514 priv->cfg.baudrate = kl5kusb105a_sio_b9600;
515 baud = 9600; 514 baud = 9600;
516 break; 515 break;
517 } 516 }
518 if ((cflag & CBAUD) == B0) { 517 if ((cflag & CBAUD) == B0) {
519 dbg("%s: baud is B0", __func__); 518 dev_dbg(dev, "%s: baud is B0\n", __func__);
520 /* Drop RTS and DTR */ 519 /* Drop RTS and DTR */
521 /* maybe this should be simulated by sending read 520 /* maybe this should be simulated by sending read
522 * disable and read enable messages? 521 * disable and read enable messages?
@@ -533,11 +532,11 @@ static void klsi_105_set_termios(struct tty_struct *tty,
533 /* set the number of data bits */ 532 /* set the number of data bits */
534 switch (cflag & CSIZE) { 533 switch (cflag & CSIZE) {
535 case CS5: 534 case CS5:
536 dbg("%s - 5 bits/byte not supported", __func__); 535 dev_dbg(dev, "%s - 5 bits/byte not supported\n", __func__);
537 spin_unlock_irqrestore(&priv->lock, flags); 536 spin_unlock_irqrestore(&priv->lock, flags);
538 goto err; 537 goto err;
539 case CS6: 538 case CS6:
540 dbg("%s - 6 bits/byte not supported", __func__); 539 dev_dbg(dev, "%s - 6 bits/byte not supported\n", __func__);
541 spin_unlock_irqrestore(&priv->lock, flags); 540 spin_unlock_irqrestore(&priv->lock, flags);
542 goto err; 541 goto err;
543 case CS7: 542 case CS7:
@@ -547,8 +546,7 @@ static void klsi_105_set_termios(struct tty_struct *tty,
547 priv->cfg.databits = kl5kusb105a_dtb_8; 546 priv->cfg.databits = kl5kusb105a_dtb_8;
548 break; 547 break;
549 default: 548 default:
550 dev_err(&port->dev, 549 dev_err(dev, "CSIZE was not CS5-CS8, using default of 8\n");
551 "CSIZE was not CS5-CS8, using default of 8\n");
552 priv->cfg.databits = kl5kusb105a_dtb_8; 550 priv->cfg.databits = kl5kusb105a_dtb_8;
553 break; 551 break;
554 } 552 }
@@ -616,7 +614,7 @@ static void mct_u232_break_ctl(struct tty_struct *tty, int break_state)
616 (struct mct_u232_private *)port->private; 614 (struct mct_u232_private *)port->private;
617 unsigned char lcr = priv->last_lcr; 615 unsigned char lcr = priv->last_lcr;
618 616
619 dbg("%sstate=%d", __func__, break_state); 617 dev_dbg(&port->dev, "%s - state=%d\n", __func__, break_state);
620 618
621 /* LOCKING */ 619 /* LOCKING */
622 if (break_state) 620 if (break_state)
@@ -645,7 +643,7 @@ static int klsi_105_tiocmget(struct tty_struct *tty)
645 spin_lock_irqsave(&priv->lock, flags); 643 spin_lock_irqsave(&priv->lock, flags);
646 priv->line_state = line_state; 644 priv->line_state = line_state;
647 spin_unlock_irqrestore(&priv->lock, flags); 645 spin_unlock_irqrestore(&priv->lock, flags);
648 dbg("%s - read line state 0x%lx", __func__, line_state); 646 dev_dbg(&port->dev, "%s - read line state 0x%lx\n", __func__, line_state);
649 return (int)line_state; 647 return (int)line_state;
650} 648}
651 649
@@ -681,6 +679,3 @@ module_usb_serial_driver(serial_drivers, id_table);
681MODULE_AUTHOR(DRIVER_AUTHOR); 679MODULE_AUTHOR(DRIVER_AUTHOR);
682MODULE_DESCRIPTION(DRIVER_DESC); 680MODULE_DESCRIPTION(DRIVER_DESC);
683MODULE_LICENSE("GPL"); 681MODULE_LICENSE("GPL");
684
685module_param(debug, bool, S_IRUGO | S_IWUSR);
686MODULE_PARM_DESC(debug, "enable extensive debugging messages");
diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c
index bf5c74965d34..5c4d2fbd4e11 100644
--- a/drivers/usb/serial/kobil_sct.c
+++ b/drivers/usb/serial/kobil_sct.c
@@ -38,8 +38,6 @@
38#include <linux/ioctl.h> 38#include <linux/ioctl.h>
39#include "kobil_sct.h" 39#include "kobil_sct.h"
40 40
41static bool debug;
42
43/* Version Information */ 41/* Version Information */
44#define DRIVER_VERSION "21/05/2004" 42#define DRIVER_VERSION "21/05/2004"
45#define DRIVER_AUTHOR "KOBIL Systems GmbH - http://www.kobil.com" 43#define DRIVER_AUTHOR "KOBIL Systems GmbH - http://www.kobil.com"
@@ -139,17 +137,16 @@ static int kobil_startup(struct usb_serial *serial)
139 137
140 switch (priv->device_type) { 138 switch (priv->device_type) {
141 case KOBIL_ADAPTER_B_PRODUCT_ID: 139 case KOBIL_ADAPTER_B_PRODUCT_ID:
142 printk(KERN_DEBUG "KOBIL B1 PRO / KAAN PRO detected\n"); 140 dev_dbg(&serial->dev->dev, "KOBIL B1 PRO / KAAN PRO detected\n");
143 break; 141 break;
144 case KOBIL_ADAPTER_K_PRODUCT_ID: 142 case KOBIL_ADAPTER_K_PRODUCT_ID:
145 printk(KERN_DEBUG 143 dev_dbg(&serial->dev->dev, "KOBIL KAAN Standard Plus / SecOVID Reader Plus detected\n");
146 "KOBIL KAAN Standard Plus / SecOVID Reader Plus detected\n");
147 break; 144 break;
148 case KOBIL_USBTWIN_PRODUCT_ID: 145 case KOBIL_USBTWIN_PRODUCT_ID:
149 printk(KERN_DEBUG "KOBIL USBTWIN detected\n"); 146 dev_dbg(&serial->dev->dev, "KOBIL USBTWIN detected\n");
150 break; 147 break;
151 case KOBIL_KAAN_SIM_PRODUCT_ID: 148 case KOBIL_KAAN_SIM_PRODUCT_ID:
152 printk(KERN_DEBUG "KOBIL KAAN SIM detected\n"); 149 dev_dbg(&serial->dev->dev, "KOBIL KAAN SIM detected\n");
153 break; 150 break;
154 } 151 }
155 usb_set_serial_port_data(serial->port[0], priv); 152 usb_set_serial_port_data(serial->port[0], priv);
@@ -164,13 +161,15 @@ static int kobil_startup(struct usb_serial *serial)
164 for (i = 0; i < altsetting->desc.bNumEndpoints; i++) { 161 for (i = 0; i < altsetting->desc.bNumEndpoints; i++) {
165 endpoint = &altsetting->endpoint[i]; 162 endpoint = &altsetting->endpoint[i];
166 if (usb_endpoint_is_int_out(&endpoint->desc)) { 163 if (usb_endpoint_is_int_out(&endpoint->desc)) {
167 dbg("%s Found interrupt out endpoint. Address: %d", 164 dev_dbg(&serial->dev->dev,
165 "%s Found interrupt out endpoint. Address: %d\n",
168 __func__, endpoint->desc.bEndpointAddress); 166 __func__, endpoint->desc.bEndpointAddress);
169 priv->write_int_endpoint_address = 167 priv->write_int_endpoint_address =
170 endpoint->desc.bEndpointAddress; 168 endpoint->desc.bEndpointAddress;
171 } 169 }
172 if (usb_endpoint_is_int_in(&endpoint->desc)) { 170 if (usb_endpoint_is_int_in(&endpoint->desc)) {
173 dbg("%s Found interrupt in endpoint. Address: %d", 171 dev_dbg(&serial->dev->dev,
172 "%s Found interrupt in endpoint. Address: %d\n",
174 __func__, endpoint->desc.bEndpointAddress); 173 __func__, endpoint->desc.bEndpointAddress);
175 priv->read_int_endpoint_address = 174 priv->read_int_endpoint_address =
176 endpoint->desc.bEndpointAddress; 175 endpoint->desc.bEndpointAddress;
@@ -200,6 +199,7 @@ static void kobil_init_termios(struct tty_struct *tty)
200 199
201static int kobil_open(struct tty_struct *tty, struct usb_serial_port *port) 200static int kobil_open(struct tty_struct *tty, struct usb_serial_port *port)
202{ 201{
202 struct device *dev = &port->dev;
203 int result = 0; 203 int result = 0;
204 struct kobil_private *priv; 204 struct kobil_private *priv;
205 unsigned char *transfer_buffer; 205 unsigned char *transfer_buffer;
@@ -215,12 +215,10 @@ static int kobil_open(struct tty_struct *tty, struct usb_serial_port *port)
215 215
216 /* allocate write_urb */ 216 /* allocate write_urb */
217 if (!port->write_urb) { 217 if (!port->write_urb) {
218 dbg("%s - port %d Allocating port->write_urb", 218 dev_dbg(dev, "%s - Allocating port->write_urb\n", __func__);
219 __func__, port->number);
220 port->write_urb = usb_alloc_urb(0, GFP_KERNEL); 219 port->write_urb = usb_alloc_urb(0, GFP_KERNEL);
221 if (!port->write_urb) { 220 if (!port->write_urb) {
222 dbg("%s - port %d usb_alloc_urb failed", 221 dev_dbg(dev, "%s - usb_alloc_urb failed\n", __func__);
223 __func__, port->number);
224 kfree(transfer_buffer); 222 kfree(transfer_buffer);
225 return -ENOMEM; 223 return -ENOMEM;
226 } 224 }
@@ -247,10 +245,9 @@ static int kobil_open(struct tty_struct *tty, struct usb_serial_port *port)
247 transfer_buffer_length, 245 transfer_buffer_length,
248 KOBIL_TIMEOUT 246 KOBIL_TIMEOUT
249 ); 247 );
250 dbg("%s - port %d Send get_HW_version URB returns: %i", 248 dev_dbg(dev, "%s - Send get_HW_version URB returns: %i\n", __func__, result);
251 __func__, port->number, result); 249 dev_dbg(dev, "Harware version: %i.%i.%i\n", transfer_buffer[0],
252 dbg("Harware version: %i.%i.%i", 250 transfer_buffer[1], transfer_buffer[2]);
253 transfer_buffer[0], transfer_buffer[1], transfer_buffer[2]);
254 251
255 /* get firmware version */ 252 /* get firmware version */
256 result = usb_control_msg(port->serial->dev, 253 result = usb_control_msg(port->serial->dev,
@@ -263,10 +260,9 @@ static int kobil_open(struct tty_struct *tty, struct usb_serial_port *port)
263 transfer_buffer_length, 260 transfer_buffer_length,
264 KOBIL_TIMEOUT 261 KOBIL_TIMEOUT
265 ); 262 );
266 dbg("%s - port %d Send get_FW_version URB returns: %i", 263 dev_dbg(dev, "%s - Send get_FW_version URB returns: %i\n", __func__, result);
267 __func__, port->number, result); 264 dev_dbg(dev, "Firmware version: %i.%i.%i\n", transfer_buffer[0],
268 dbg("Firmware version: %i.%i.%i", 265 transfer_buffer[1], transfer_buffer[2]);
269 transfer_buffer[0], transfer_buffer[1], transfer_buffer[2]);
270 266
271 if (priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID || 267 if (priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID ||
272 priv->device_type == KOBIL_ADAPTER_K_PRODUCT_ID) { 268 priv->device_type == KOBIL_ADAPTER_K_PRODUCT_ID) {
@@ -282,8 +278,7 @@ static int kobil_open(struct tty_struct *tty, struct usb_serial_port *port)
282 0, 278 0,
283 KOBIL_TIMEOUT 279 KOBIL_TIMEOUT
284 ); 280 );
285 dbg("%s - port %d Send set_baudrate URB returns: %i", 281 dev_dbg(dev, "%s - Send set_baudrate URB returns: %i\n", __func__, result);
286 __func__, port->number, result);
287 282
288 /* reset all queues */ 283 /* reset all queues */
289 result = usb_control_msg(port->serial->dev, 284 result = usb_control_msg(port->serial->dev,
@@ -296,16 +291,14 @@ static int kobil_open(struct tty_struct *tty, struct usb_serial_port *port)
296 0, 291 0,
297 KOBIL_TIMEOUT 292 KOBIL_TIMEOUT
298 ); 293 );
299 dbg("%s - port %d Send reset_all_queues URB returns: %i", 294 dev_dbg(dev, "%s - Send reset_all_queues URB returns: %i\n", __func__, result);
300 __func__, port->number, result);
301 } 295 }
302 if (priv->device_type == KOBIL_USBTWIN_PRODUCT_ID || 296 if (priv->device_type == KOBIL_USBTWIN_PRODUCT_ID ||
303 priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID || 297 priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID ||
304 priv->device_type == KOBIL_KAAN_SIM_PRODUCT_ID) { 298 priv->device_type == KOBIL_KAAN_SIM_PRODUCT_ID) {
305 /* start reading (Adapter B 'cause PNP string) */ 299 /* start reading (Adapter B 'cause PNP string) */
306 result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); 300 result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC);
307 dbg("%s - port %d Send read URB returns: %i", 301 dev_dbg(dev, "%s - Send read URB returns: %i\n", __func__, result);
308 __func__, port->number, result);
309 } 302 }
310 303
311 kfree(transfer_buffer); 304 kfree(transfer_buffer);
@@ -333,11 +326,9 @@ static void kobil_read_int_callback(struct urb *urb)
333 struct tty_struct *tty; 326 struct tty_struct *tty;
334 unsigned char *data = urb->transfer_buffer; 327 unsigned char *data = urb->transfer_buffer;
335 int status = urb->status; 328 int status = urb->status;
336/* char *dbg_data; */
337 329
338 if (status) { 330 if (status) {
339 dbg("%s - port %d Read int status not zero: %d", 331 dev_dbg(&port->dev, "%s - Read int status not zero: %d\n", __func__, status);
340 __func__, port->number, status);
341 return; 332 return;
342 } 333 }
343 334
@@ -346,6 +337,8 @@ static void kobil_read_int_callback(struct urb *urb)
346 337
347 /* BEGIN DEBUG */ 338 /* BEGIN DEBUG */
348 /* 339 /*
340 char *dbg_data;
341
349 dbg_data = kzalloc((3 * purb->actual_length + 10) 342 dbg_data = kzalloc((3 * purb->actual_length + 10)
350 * sizeof(char), GFP_KERNEL); 343 * sizeof(char), GFP_KERNEL);
351 if (! dbg_data) { 344 if (! dbg_data) {
@@ -354,7 +347,7 @@ static void kobil_read_int_callback(struct urb *urb)
354 for (i = 0; i < purb->actual_length; i++) { 347 for (i = 0; i < purb->actual_length; i++) {
355 sprintf(dbg_data +3*i, "%02X ", data[i]); 348 sprintf(dbg_data +3*i, "%02X ", data[i]);
356 } 349 }
357 dbg(" <-- %s", dbg_data); 350 dev_dbg(&port->dev, " <-- %s\n", dbg_data);
358 kfree(dbg_data); 351 kfree(dbg_data);
359 */ 352 */
360 /* END DEBUG */ 353 /* END DEBUG */
@@ -365,8 +358,7 @@ static void kobil_read_int_callback(struct urb *urb)
365 tty_kref_put(tty); 358 tty_kref_put(tty);
366 359
367 result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); 360 result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC);
368 dbg("%s - port %d Send read URB returns: %i", 361 dev_dbg(&port->dev, "%s - Send read URB returns: %i\n", __func__, result);
369 __func__, port->number, result);
370} 362}
371 363
372 364
@@ -384,22 +376,20 @@ static int kobil_write(struct tty_struct *tty, struct usb_serial_port *port,
384 struct kobil_private *priv; 376 struct kobil_private *priv;
385 377
386 if (count == 0) { 378 if (count == 0) {
387 dbg("%s - port %d write request of 0 bytes", 379 dev_dbg(&port->dev, "%s - write request of 0 bytes\n", __func__);
388 __func__, port->number);
389 return 0; 380 return 0;
390 } 381 }
391 382
392 priv = usb_get_serial_port_data(port); 383 priv = usb_get_serial_port_data(port);
393 384
394 if (count > (KOBIL_BUF_LENGTH - priv->filled)) { 385 if (count > (KOBIL_BUF_LENGTH - priv->filled)) {
395 dbg("%s - port %d Error: write request bigger than buffer size", __func__, port->number); 386 dev_dbg(&port->dev, "%s - Error: write request bigger than buffer size\n", __func__);
396 return -ENOMEM; 387 return -ENOMEM;
397 } 388 }
398 389
399 /* Copy data to buffer */ 390 /* Copy data to buffer */
400 memcpy(priv->buf + priv->filled, buf, count); 391 memcpy(priv->buf + priv->filled, buf, count);
401 usb_serial_debug_data(debug, &port->dev, __func__, count, 392 usb_serial_debug_data(&port->dev, __func__, count, priv->buf + priv->filled);
402 priv->buf + priv->filled);
403 priv->filled = priv->filled + count; 393 priv->filled = priv->filled + count;
404 394
405 /* only send complete block. TWIN, KAAN SIM and adapter K 395 /* only send complete block. TWIN, KAAN SIM and adapter K
@@ -432,8 +422,7 @@ static int kobil_write(struct tty_struct *tty, struct usb_serial_port *port,
432 422
433 priv->cur_pos = priv->cur_pos + length; 423 priv->cur_pos = priv->cur_pos + length;
434 result = usb_submit_urb(port->write_urb, GFP_NOIO); 424 result = usb_submit_urb(port->write_urb, GFP_NOIO);
435 dbg("%s - port %d Send write URB returns: %i", 425 dev_dbg(&port->dev, "%s - Send write URB returns: %i\n", __func__, result);
436 __func__, port->number, result);
437 todo = priv->filled - priv->cur_pos; 426 todo = priv->filled - priv->cur_pos;
438 427
439 if (todo > 0) 428 if (todo > 0)
@@ -448,8 +437,7 @@ static int kobil_write(struct tty_struct *tty, struct usb_serial_port *port,
448 priv->device_type == KOBIL_ADAPTER_K_PRODUCT_ID) { 437 priv->device_type == KOBIL_ADAPTER_K_PRODUCT_ID) {
449 result = usb_submit_urb(port->interrupt_in_urb, 438 result = usb_submit_urb(port->interrupt_in_urb,
450 GFP_NOIO); 439 GFP_NOIO);
451 dbg("%s - port %d Send read URB returns: %i", 440 dev_dbg(&port->dev, "%s - Send read URB returns: %i\n", __func__, result);
452 __func__, port->number, result);
453 } 441 }
454 } 442 }
455 return count; 443 return count;
@@ -493,8 +481,8 @@ static int kobil_tiocmget(struct tty_struct *tty)
493 transfer_buffer_length, 481 transfer_buffer_length,
494 KOBIL_TIMEOUT); 482 KOBIL_TIMEOUT);
495 483
496 dbg("%s - port %d Send get_status_line_state URB returns: %i. Statusline: %02x", 484 dev_dbg(&port->dev, "%s - Send get_status_line_state URB returns: %i. Statusline: %02x\n",
497 __func__, port->number, result, transfer_buffer[0]); 485 __func__, result, transfer_buffer[0]);
498 486
499 result = 0; 487 result = 0;
500 if ((transfer_buffer[0] & SUSBCR_GSL_DSR) != 0) 488 if ((transfer_buffer[0] & SUSBCR_GSL_DSR) != 0)
@@ -507,6 +495,7 @@ static int kobil_tiocmset(struct tty_struct *tty,
507 unsigned int set, unsigned int clear) 495 unsigned int set, unsigned int clear)
508{ 496{
509 struct usb_serial_port *port = tty->driver_data; 497 struct usb_serial_port *port = tty->driver_data;
498 struct device *dev = &port->dev;
510 struct kobil_private *priv; 499 struct kobil_private *priv;
511 int result; 500 int result;
512 int dtr = 0; 501 int dtr = 0;
@@ -538,11 +527,9 @@ static int kobil_tiocmset(struct tty_struct *tty,
538 527
539 if (priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID) { 528 if (priv->device_type == KOBIL_ADAPTER_B_PRODUCT_ID) {
540 if (dtr != 0) 529 if (dtr != 0)
541 dbg("%s - port %d Setting DTR", 530 dev_dbg(dev, "%s - Setting DTR\n", __func__);
542 __func__, port->number);
543 else 531 else
544 dbg("%s - port %d Clearing DTR", 532 dev_dbg(dev, "%s - Clearing DTR\n", __func__);
545 __func__, port->number);
546 result = usb_control_msg(port->serial->dev, 533 result = usb_control_msg(port->serial->dev,
547 usb_rcvctrlpipe(port->serial->dev, 0), 534 usb_rcvctrlpipe(port->serial->dev, 0),
548 SUSBCRequest_SetStatusLinesOrQueues, 535 SUSBCRequest_SetStatusLinesOrQueues,
@@ -554,11 +541,9 @@ static int kobil_tiocmset(struct tty_struct *tty,
554 KOBIL_TIMEOUT); 541 KOBIL_TIMEOUT);
555 } else { 542 } else {
556 if (rts != 0) 543 if (rts != 0)
557 dbg("%s - port %d Setting RTS", 544 dev_dbg(dev, "%s - Setting RTS\n", __func__);
558 __func__, port->number);
559 else 545 else
560 dbg("%s - port %d Clearing RTS", 546 dev_dbg(dev, "%s - Clearing RTS\n", __func__);
561 __func__, port->number);
562 result = usb_control_msg(port->serial->dev, 547 result = usb_control_msg(port->serial->dev,
563 usb_rcvctrlpipe(port->serial->dev, 0), 548 usb_rcvctrlpipe(port->serial->dev, 0),
564 SUSBCRequest_SetStatusLinesOrQueues, 549 SUSBCRequest_SetStatusLinesOrQueues,
@@ -569,8 +554,7 @@ static int kobil_tiocmset(struct tty_struct *tty,
569 0, 554 0,
570 KOBIL_TIMEOUT); 555 KOBIL_TIMEOUT);
571 } 556 }
572 dbg("%s - port %d Send set_status_line URB returns: %i", 557 dev_dbg(dev, "%s - Send set_status_line URB returns: %i\n", __func__, result);
573 __func__, port->number, result);
574 kfree(transfer_buffer); 558 kfree(transfer_buffer);
575 return (result < 0) ? result : 0; 559 return (result < 0) ? result : 0;
576} 560}
@@ -658,7 +642,8 @@ static int kobil_ioctl(struct tty_struct *tty,
658 KOBIL_TIMEOUT 642 KOBIL_TIMEOUT
659 ); 643 );
660 644
661 dbg("%s - port %d Send reset_all_queues (FLUSH) URB returns: %i", __func__, port->number, result); 645 dev_dbg(&port->dev,
646 "%s - Send reset_all_queues (FLUSH) URB returns: %i", __func__, result);
662 kfree(transfer_buffer); 647 kfree(transfer_buffer);
663 return (result < 0) ? -EIO: 0; 648 return (result < 0) ? -EIO: 0;
664 default: 649 default:
@@ -671,6 +656,3 @@ module_usb_serial_driver(serial_drivers, id_table);
671MODULE_AUTHOR(DRIVER_AUTHOR); 656MODULE_AUTHOR(DRIVER_AUTHOR);
672MODULE_DESCRIPTION(DRIVER_DESC); 657MODULE_DESCRIPTION(DRIVER_DESC);
673MODULE_LICENSE("GPL"); 658MODULE_LICENSE("GPL");
674
675module_param(debug, bool, S_IRUGO | S_IWUSR);
676MODULE_PARM_DESC(debug, "Debug enabled or not");
diff --git a/drivers/usb/serial/mct_u232.c b/drivers/usb/serial/mct_u232.c
index df98cffdba65..f3947712e137 100644
--- a/drivers/usb/serial/mct_u232.c
+++ b/drivers/usb/serial/mct_u232.c
@@ -45,8 +45,6 @@
45#define DRIVER_AUTHOR "Wolfgang Grandegger <wolfgang@ces.ch>" 45#define DRIVER_AUTHOR "Wolfgang Grandegger <wolfgang@ces.ch>"
46#define DRIVER_DESC "Magic Control Technology USB-RS232 converter driver" 46#define DRIVER_DESC "Magic Control Technology USB-RS232 converter driver"
47 47
48static bool debug;
49
50/* 48/*
51 * Function prototypes 49 * Function prototypes
52 */ 50 */
@@ -214,7 +212,7 @@ static int mct_u232_set_baud_rate(struct tty_struct *tty,
214 value, rc); 212 value, rc);
215 else 213 else
216 tty_encode_baud_rate(tty, speed, speed); 214 tty_encode_baud_rate(tty, speed, speed);
217 dbg("set_baud_rate: value: 0x%x, divisor: 0x%x", value, divisor); 215 dev_dbg(&port->dev, "set_baud_rate: value: 0x%x, divisor: 0x%x\n", value, divisor);
218 216
219 /* Mimic the MCT-supplied Windows driver (version 1.21P.0104), which 217 /* Mimic the MCT-supplied Windows driver (version 1.21P.0104), which
220 always sends two extra USB 'device request' messages after the 218 always sends two extra USB 'device request' messages after the
@@ -247,8 +245,8 @@ static int mct_u232_set_baud_rate(struct tty_struct *tty,
247 if (port && C_CRTSCTS(tty)) 245 if (port && C_CRTSCTS(tty))
248 cts_enable_byte = 1; 246 cts_enable_byte = 1;
249 247
250 dbg("set_baud_rate: send second control message, data = %02X", 248 dev_dbg(&port->dev, "set_baud_rate: send second control message, data = %02X\n",
251 cts_enable_byte); 249 cts_enable_byte);
252 buf[0] = cts_enable_byte; 250 buf[0] = cts_enable_byte;
253 rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), 251 rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
254 MCT_U232_SET_CTS_REQUEST, 252 MCT_U232_SET_CTS_REQUEST,
@@ -263,7 +261,8 @@ static int mct_u232_set_baud_rate(struct tty_struct *tty,
263 return rc; 261 return rc;
264} /* mct_u232_set_baud_rate */ 262} /* mct_u232_set_baud_rate */
265 263
266static int mct_u232_set_line_ctrl(struct usb_serial *serial, unsigned char lcr) 264static int mct_u232_set_line_ctrl(struct usb_serial_port *port,
265 unsigned char lcr)
267{ 266{
268 int rc; 267 int rc;
269 unsigned char *buf; 268 unsigned char *buf;
@@ -273,20 +272,19 @@ static int mct_u232_set_line_ctrl(struct usb_serial *serial, unsigned char lcr)
273 return -ENOMEM; 272 return -ENOMEM;
274 273
275 buf[0] = lcr; 274 buf[0] = lcr;
276 rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), 275 rc = usb_control_msg(port->serial->dev, usb_sndctrlpipe(port->serial->dev, 0),
277 MCT_U232_SET_LINE_CTRL_REQUEST, 276 MCT_U232_SET_LINE_CTRL_REQUEST,
278 MCT_U232_SET_REQUEST_TYPE, 277 MCT_U232_SET_REQUEST_TYPE,
279 0, 0, buf, MCT_U232_SET_LINE_CTRL_SIZE, 278 0, 0, buf, MCT_U232_SET_LINE_CTRL_SIZE,
280 WDR_TIMEOUT); 279 WDR_TIMEOUT);
281 if (rc < 0) 280 if (rc < 0)
282 dev_err(&serial->dev->dev, 281 dev_err(&port->dev, "Set LINE CTRL 0x%x failed (error = %d)\n", lcr, rc);
283 "Set LINE CTRL 0x%x failed (error = %d)\n", lcr, rc); 282 dev_dbg(&port->dev, "set_line_ctrl: 0x%x\n", lcr);
284 dbg("set_line_ctrl: 0x%x", lcr);
285 kfree(buf); 283 kfree(buf);
286 return rc; 284 return rc;
287} /* mct_u232_set_line_ctrl */ 285} /* mct_u232_set_line_ctrl */
288 286
289static int mct_u232_set_modem_ctrl(struct usb_serial *serial, 287static int mct_u232_set_modem_ctrl(struct usb_serial_port *port,
290 unsigned int control_state) 288 unsigned int control_state)
291{ 289{
292 int rc; 290 int rc;
@@ -304,25 +302,24 @@ static int mct_u232_set_modem_ctrl(struct usb_serial *serial,
304 mcr |= MCT_U232_MCR_RTS; 302 mcr |= MCT_U232_MCR_RTS;
305 303
306 buf[0] = mcr; 304 buf[0] = mcr;
307 rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), 305 rc = usb_control_msg(port->serial->dev, usb_sndctrlpipe(port->serial->dev, 0),
308 MCT_U232_SET_MODEM_CTRL_REQUEST, 306 MCT_U232_SET_MODEM_CTRL_REQUEST,
309 MCT_U232_SET_REQUEST_TYPE, 307 MCT_U232_SET_REQUEST_TYPE,
310 0, 0, buf, MCT_U232_SET_MODEM_CTRL_SIZE, 308 0, 0, buf, MCT_U232_SET_MODEM_CTRL_SIZE,
311 WDR_TIMEOUT); 309 WDR_TIMEOUT);
312 kfree(buf); 310 kfree(buf);
313 311
314 dbg("set_modem_ctrl: state=0x%x ==> mcr=0x%x", control_state, mcr); 312 dev_dbg(&port->dev, "set_modem_ctrl: state=0x%x ==> mcr=0x%x\n", control_state, mcr);
315 313
316 if (rc < 0) { 314 if (rc < 0) {
317 dev_err(&serial->dev->dev, 315 dev_err(&port->dev, "Set MODEM CTRL 0x%x failed (error = %d)\n", mcr, rc);
318 "Set MODEM CTRL 0x%x failed (error = %d)\n", mcr, rc);
319 return rc; 316 return rc;
320 } 317 }
321 return 0; 318 return 0;
322} /* mct_u232_set_modem_ctrl */ 319} /* mct_u232_set_modem_ctrl */
323 320
324static int mct_u232_get_modem_stat(struct usb_serial *serial, 321static int mct_u232_get_modem_stat(struct usb_serial_port *port,
325 unsigned char *msr) 322 unsigned char *msr)
326{ 323{
327 int rc; 324 int rc;
328 unsigned char *buf; 325 unsigned char *buf;
@@ -332,19 +329,18 @@ static int mct_u232_get_modem_stat(struct usb_serial *serial,
332 *msr = 0; 329 *msr = 0;
333 return -ENOMEM; 330 return -ENOMEM;
334 } 331 }
335 rc = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), 332 rc = usb_control_msg(port->serial->dev, usb_rcvctrlpipe(port->serial->dev, 0),
336 MCT_U232_GET_MODEM_STAT_REQUEST, 333 MCT_U232_GET_MODEM_STAT_REQUEST,
337 MCT_U232_GET_REQUEST_TYPE, 334 MCT_U232_GET_REQUEST_TYPE,
338 0, 0, buf, MCT_U232_GET_MODEM_STAT_SIZE, 335 0, 0, buf, MCT_U232_GET_MODEM_STAT_SIZE,
339 WDR_TIMEOUT); 336 WDR_TIMEOUT);
340 if (rc < 0) { 337 if (rc < 0) {
341 dev_err(&serial->dev->dev, 338 dev_err(&port->dev, "Get MODEM STATus failed (error = %d)\n", rc);
342 "Get MODEM STATus failed (error = %d)\n", rc);
343 *msr = 0; 339 *msr = 0;
344 } else { 340 } else {
345 *msr = buf[0]; 341 *msr = buf[0];
346 } 342 }
347 dbg("get_modem_stat: 0x%x", *msr); 343 dev_dbg(&port->dev, "get_modem_stat: 0x%x\n", *msr);
348 kfree(buf); 344 kfree(buf);
349 return rc; 345 return rc;
350} /* mct_u232_get_modem_stat */ 346} /* mct_u232_get_modem_stat */
@@ -363,8 +359,8 @@ static void mct_u232_msr_to_icount(struct async_icount *icount,
363 icount->dcd++; 359 icount->dcd++;
364} /* mct_u232_msr_to_icount */ 360} /* mct_u232_msr_to_icount */
365 361
366static void mct_u232_msr_to_state(unsigned int *control_state, 362static void mct_u232_msr_to_state(struct usb_serial_port *port,
367 unsigned char msr) 363 unsigned int *control_state, unsigned char msr)
368{ 364{
369 /* Translate Control Line states */ 365 /* Translate Control Line states */
370 if (msr & MCT_U232_MSR_DSR) 366 if (msr & MCT_U232_MSR_DSR)
@@ -383,7 +379,7 @@ static void mct_u232_msr_to_state(unsigned int *control_state,
383 *control_state |= TIOCM_CD; 379 *control_state |= TIOCM_CD;
384 else 380 else
385 *control_state &= ~TIOCM_CD; 381 *control_state &= ~TIOCM_CD;
386 dbg("msr_to_state: msr=0x%x ==> state=0x%x", msr, *control_state); 382 dev_dbg(&port->dev, "msr_to_state: msr=0x%x ==> state=0x%x\n", msr, *control_state);
387} /* mct_u232_msr_to_state */ 383} /* mct_u232_msr_to_state */
388 384
389/* 385/*
@@ -465,14 +461,14 @@ static int mct_u232_open(struct tty_struct *tty, struct usb_serial_port *port)
465 control_state = priv->control_state; 461 control_state = priv->control_state;
466 last_lcr = priv->last_lcr; 462 last_lcr = priv->last_lcr;
467 spin_unlock_irqrestore(&priv->lock, flags); 463 spin_unlock_irqrestore(&priv->lock, flags);
468 mct_u232_set_modem_ctrl(serial, control_state); 464 mct_u232_set_modem_ctrl(port, control_state);
469 mct_u232_set_line_ctrl(serial, last_lcr); 465 mct_u232_set_line_ctrl(port, last_lcr);
470 466
471 /* Read modem status and update control state */ 467 /* Read modem status and update control state */
472 mct_u232_get_modem_stat(serial, &last_msr); 468 mct_u232_get_modem_stat(port, &last_msr);
473 spin_lock_irqsave(&priv->lock, flags); 469 spin_lock_irqsave(&priv->lock, flags);
474 priv->last_msr = last_msr; 470 priv->last_msr = last_msr;
475 mct_u232_msr_to_state(&priv->control_state, priv->last_msr); 471 mct_u232_msr_to_state(port, &priv->control_state, priv->last_msr);
476 spin_unlock_irqrestore(&priv->lock, flags); 472 spin_unlock_irqrestore(&priv->lock, flags);
477 473
478 retval = usb_submit_urb(port->read_urb, GFP_KERNEL); 474 retval = usb_submit_urb(port->read_urb, GFP_KERNEL);
@@ -512,7 +508,7 @@ static void mct_u232_dtr_rts(struct usb_serial_port *port, int on)
512 priv->control_state &= ~(TIOCM_DTR | TIOCM_RTS); 508 priv->control_state &= ~(TIOCM_DTR | TIOCM_RTS);
513 control_state = priv->control_state; 509 control_state = priv->control_state;
514 spin_unlock_irq(&priv->lock); 510 spin_unlock_irq(&priv->lock);
515 mct_u232_set_modem_ctrl(port->serial, control_state); 511 mct_u232_set_modem_ctrl(port, control_state);
516 } 512 }
517 mutex_unlock(&port->serial->disc_mutex); 513 mutex_unlock(&port->serial->disc_mutex);
518} 514}
@@ -532,7 +528,6 @@ static void mct_u232_read_int_callback(struct urb *urb)
532{ 528{
533 struct usb_serial_port *port = urb->context; 529 struct usb_serial_port *port = urb->context;
534 struct mct_u232_private *priv = usb_get_serial_port_data(port); 530 struct mct_u232_private *priv = usb_get_serial_port_data(port);
535 struct usb_serial *serial = port->serial;
536 struct tty_struct *tty; 531 struct tty_struct *tty;
537 unsigned char *data = urb->transfer_buffer; 532 unsigned char *data = urb->transfer_buffer;
538 int retval; 533 int retval;
@@ -547,22 +542,16 @@ static void mct_u232_read_int_callback(struct urb *urb)
547 case -ENOENT: 542 case -ENOENT:
548 case -ESHUTDOWN: 543 case -ESHUTDOWN:
549 /* this urb is terminated, clean up */ 544 /* this urb is terminated, clean up */
550 dbg("%s - urb shutting down with status: %d", 545 dev_dbg(&port->dev, "%s - urb shutting down with status: %d\n",
551 __func__, status); 546 __func__, status);
552 return; 547 return;
553 default: 548 default:
554 dbg("%s - nonzero urb status received: %d", 549 dev_dbg(&port->dev, "%s - nonzero urb status received: %d\n",
555 __func__, status); 550 __func__, status);
556 goto exit; 551 goto exit;
557 } 552 }
558 553
559 if (!serial) { 554 usb_serial_debug_data(&port->dev, __func__, urb->actual_length, data);
560 dbg("%s - bad serial pointer, exiting", __func__);
561 return;
562 }
563
564 usb_serial_debug_data(debug, &port->dev, __func__,
565 urb->actual_length, data);
566 555
567 /* 556 /*
568 * Work-a-round: handle the 'usual' bulk-in pipe here 557 * Work-a-round: handle the 'usual' bulk-in pipe here
@@ -588,7 +577,7 @@ static void mct_u232_read_int_callback(struct urb *urb)
588 priv->last_msr = data[MCT_U232_MSR_INDEX]; 577 priv->last_msr = data[MCT_U232_MSR_INDEX];
589 578
590 /* Record Control Line states */ 579 /* Record Control Line states */
591 mct_u232_msr_to_state(&priv->control_state, priv->last_msr); 580 mct_u232_msr_to_state(port, &priv->control_state, priv->last_msr);
592 581
593 mct_u232_msr_to_icount(&priv->icount, priv->last_msr); 582 mct_u232_msr_to_icount(&priv->icount, priv->last_msr);
594 583
@@ -656,18 +645,18 @@ static void mct_u232_set_termios(struct tty_struct *tty,
656 645
657 /* reassert DTR and RTS on transition from B0 */ 646 /* reassert DTR and RTS on transition from B0 */
658 if ((old_cflag & CBAUD) == B0) { 647 if ((old_cflag & CBAUD) == B0) {
659 dbg("%s: baud was B0", __func__); 648 dev_dbg(&port->dev, "%s: baud was B0\n", __func__);
660 control_state |= TIOCM_DTR | TIOCM_RTS; 649 control_state |= TIOCM_DTR | TIOCM_RTS;
661 mct_u232_set_modem_ctrl(serial, control_state); 650 mct_u232_set_modem_ctrl(port, control_state);
662 } 651 }
663 652
664 mct_u232_set_baud_rate(tty, serial, port, tty_get_baud_rate(tty)); 653 mct_u232_set_baud_rate(tty, serial, port, tty_get_baud_rate(tty));
665 654
666 if ((cflag & CBAUD) == B0) { 655 if ((cflag & CBAUD) == B0) {
667 dbg("%s: baud is B0", __func__); 656 dev_dbg(&port->dev, "%s: baud is B0\n", __func__);
668 /* Drop RTS and DTR */ 657 /* Drop RTS and DTR */
669 control_state &= ~(TIOCM_DTR | TIOCM_RTS); 658 control_state &= ~(TIOCM_DTR | TIOCM_RTS);
670 mct_u232_set_modem_ctrl(serial, control_state); 659 mct_u232_set_modem_ctrl(port, control_state);
671 } 660 }
672 661
673 /* 662 /*
@@ -704,7 +693,7 @@ static void mct_u232_set_termios(struct tty_struct *tty,
704 last_lcr |= (cflag & CSTOPB) ? 693 last_lcr |= (cflag & CSTOPB) ?
705 MCT_U232_STOP_BITS_2 : MCT_U232_STOP_BITS_1; 694 MCT_U232_STOP_BITS_2 : MCT_U232_STOP_BITS_1;
706 695
707 mct_u232_set_line_ctrl(serial, last_lcr); 696 mct_u232_set_line_ctrl(port, last_lcr);
708 697
709 /* save off the modified port settings */ 698 /* save off the modified port settings */
710 spin_lock_irqsave(&priv->lock, flags); 699 spin_lock_irqsave(&priv->lock, flags);
@@ -716,7 +705,6 @@ static void mct_u232_set_termios(struct tty_struct *tty,
716static void mct_u232_break_ctl(struct tty_struct *tty, int break_state) 705static void mct_u232_break_ctl(struct tty_struct *tty, int break_state)
717{ 706{
718 struct usb_serial_port *port = tty->driver_data; 707 struct usb_serial_port *port = tty->driver_data;
719 struct usb_serial *serial = port->serial;
720 struct mct_u232_private *priv = usb_get_serial_port_data(port); 708 struct mct_u232_private *priv = usb_get_serial_port_data(port);
721 unsigned char lcr; 709 unsigned char lcr;
722 unsigned long flags; 710 unsigned long flags;
@@ -728,7 +716,7 @@ static void mct_u232_break_ctl(struct tty_struct *tty, int break_state)
728 lcr |= MCT_U232_SET_BREAK; 716 lcr |= MCT_U232_SET_BREAK;
729 spin_unlock_irqrestore(&priv->lock, flags); 717 spin_unlock_irqrestore(&priv->lock, flags);
730 718
731 mct_u232_set_line_ctrl(serial, lcr); 719 mct_u232_set_line_ctrl(port, lcr);
732} /* mct_u232_break_ctl */ 720} /* mct_u232_break_ctl */
733 721
734 722
@@ -750,7 +738,6 @@ static int mct_u232_tiocmset(struct tty_struct *tty,
750 unsigned int set, unsigned int clear) 738 unsigned int set, unsigned int clear)
751{ 739{
752 struct usb_serial_port *port = tty->driver_data; 740 struct usb_serial_port *port = tty->driver_data;
753 struct usb_serial *serial = port->serial;
754 struct mct_u232_private *priv = usb_get_serial_port_data(port); 741 struct mct_u232_private *priv = usb_get_serial_port_data(port);
755 unsigned int control_state; 742 unsigned int control_state;
756 unsigned long flags; 743 unsigned long flags;
@@ -769,7 +756,7 @@ static int mct_u232_tiocmset(struct tty_struct *tty,
769 756
770 priv->control_state = control_state; 757 priv->control_state = control_state;
771 spin_unlock_irqrestore(&priv->lock, flags); 758 spin_unlock_irqrestore(&priv->lock, flags);
772 return mct_u232_set_modem_ctrl(serial, control_state); 759 return mct_u232_set_modem_ctrl(port, control_state);
773} 760}
774 761
775static void mct_u232_throttle(struct tty_struct *tty) 762static void mct_u232_throttle(struct tty_struct *tty)
@@ -784,7 +771,7 @@ static void mct_u232_throttle(struct tty_struct *tty)
784 priv->control_state &= ~TIOCM_RTS; 771 priv->control_state &= ~TIOCM_RTS;
785 control_state = priv->control_state; 772 control_state = priv->control_state;
786 spin_unlock_irq(&priv->lock); 773 spin_unlock_irq(&priv->lock);
787 (void) mct_u232_set_modem_ctrl(port->serial, control_state); 774 mct_u232_set_modem_ctrl(port, control_state);
788 } else { 775 } else {
789 spin_unlock_irq(&priv->lock); 776 spin_unlock_irq(&priv->lock);
790 } 777 }
@@ -802,7 +789,7 @@ static void mct_u232_unthrottle(struct tty_struct *tty)
802 priv->control_state |= TIOCM_RTS; 789 priv->control_state |= TIOCM_RTS;
803 control_state = priv->control_state; 790 control_state = priv->control_state;
804 spin_unlock_irq(&priv->lock); 791 spin_unlock_irq(&priv->lock);
805 (void) mct_u232_set_modem_ctrl(port->serial, control_state); 792 mct_u232_set_modem_ctrl(port, control_state);
806 } else { 793 } else {
807 spin_unlock_irq(&priv->lock); 794 spin_unlock_irq(&priv->lock);
808 } 795 }
@@ -817,13 +804,13 @@ static int mct_u232_ioctl(struct tty_struct *tty,
817 struct async_icount cnow, cprev; 804 struct async_icount cnow, cprev;
818 unsigned long flags; 805 unsigned long flags;
819 806
820 dbg("%s - port %d, cmd = 0x%x", __func__, port->number, cmd); 807 dev_dbg(&port->dev, "%s - cmd = 0x%x\n", __func__, cmd);
821 808
822 switch (cmd) { 809 switch (cmd) {
823 810
824 case TIOCMIWAIT: 811 case TIOCMIWAIT:
825 812
826 dbg("%s (%d) TIOCMIWAIT", __func__, port->number); 813 dev_dbg(&port->dev, "%s TIOCMIWAIT", __func__);
827 814
828 spin_lock_irqsave(&mct_u232_port->lock, flags); 815 spin_lock_irqsave(&mct_u232_port->lock, flags);
829 cprev = mct_u232_port->icount; 816 cprev = mct_u232_port->icount;
@@ -879,8 +866,8 @@ static int mct_u232_get_icount(struct tty_struct *tty,
879 866
880 spin_unlock_irqrestore(&mct_u232_port->lock, flags); 867 spin_unlock_irqrestore(&mct_u232_port->lock, flags);
881 868
882 dbg("%s (%d) TIOCGICOUNT RX=%d, TX=%d", 869 dev_dbg(&port->dev, "%s TIOCGICOUNT RX=%d, TX=%d\n",
883 __func__, port->number, icount->rx, icount->tx); 870 __func__, icount->rx, icount->tx);
884 return 0; 871 return 0;
885} 872}
886 873
@@ -889,6 +876,3 @@ module_usb_serial_driver(serial_drivers, id_table);
889MODULE_AUTHOR(DRIVER_AUTHOR); 876MODULE_AUTHOR(DRIVER_AUTHOR);
890MODULE_DESCRIPTION(DRIVER_DESC); 877MODULE_DESCRIPTION(DRIVER_DESC);
891MODULE_LICENSE("GPL"); 878MODULE_LICENSE("GPL");
892
893module_param(debug, bool, S_IRUGO | S_IWUSR);
894MODULE_PARM_DESC(debug, "Debug enabled or not");
diff --git a/drivers/usb/serial/metro-usb.c b/drivers/usb/serial/metro-usb.c
index 2b0627b5fe2c..0b257ddffbdb 100644
--- a/drivers/usb/serial/metro-usb.c
+++ b/drivers/usb/serial/metro-usb.c
@@ -52,9 +52,6 @@ static struct usb_device_id id_table[] = {
52}; 52};
53MODULE_DEVICE_TABLE(usb, id_table); 53MODULE_DEVICE_TABLE(usb, id_table);
54 54
55/* Input parameter constants. */
56static bool debug;
57
58/* UNI-Directional mode commands for device configure */ 55/* UNI-Directional mode commands for device configure */
59#define UNI_CMD_OPEN 0x80 56#define UNI_CMD_OPEN 0x80
60#define UNI_CMD_CLOSE 0xFF 57#define UNI_CMD_CLOSE 0xFF
@@ -436,7 +433,3 @@ MODULE_LICENSE("GPL");
436MODULE_AUTHOR("Philip Nicastro"); 433MODULE_AUTHOR("Philip Nicastro");
437MODULE_AUTHOR("Aleksey Babahin <tamerlan311@gmail.com>"); 434MODULE_AUTHOR("Aleksey Babahin <tamerlan311@gmail.com>");
438MODULE_DESCRIPTION(DRIVER_DESC); 435MODULE_DESCRIPTION(DRIVER_DESC);
439
440/* Module input parameters */
441module_param(debug, bool, S_IRUGO | S_IWUSR);
442MODULE_PARM_DESC(debug, "Print debug info (bool 1=on, 0=off)");
diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c
index 012f67b2e4cc..1bf1ad066666 100644
--- a/drivers/usb/serial/mos7720.c
+++ b/drivers/usb/serial/mos7720.c
@@ -71,8 +71,6 @@ struct moschip_port {
71 struct urb *write_urb_pool[NUM_URBS]; 71 struct urb *write_urb_pool[NUM_URBS];
72}; 72};
73 73
74static bool debug;
75
76static struct usb_serial_driver moschip7720_2port_driver; 74static struct usb_serial_driver moschip7720_2port_driver;
77 75
78#define USB_VENDOR_ID_MOSCHIP 0x9710 76#define USB_VENDOR_ID_MOSCHIP 0x9710
@@ -281,16 +279,19 @@ static void send_deferred_urbs(unsigned long _mos_parport)
281 int ret_val; 279 int ret_val;
282 unsigned long flags; 280 unsigned long flags;
283 struct mos7715_parport *mos_parport = (void *)_mos_parport; 281 struct mos7715_parport *mos_parport = (void *)_mos_parport;
284 struct urbtracker *urbtrack; 282 struct urbtracker *urbtrack, *tmp;
285 struct list_head *cursor, *next; 283 struct list_head *cursor, *next;
284 struct device *dev;
286 285
287 /* if release function ran, game over */ 286 /* if release function ran, game over */
288 if (unlikely(mos_parport->serial == NULL)) 287 if (unlikely(mos_parport->serial == NULL))
289 return; 288 return;
290 289
290 dev = &mos_parport->serial->dev->dev;
291
291 /* try again to get the mutex */ 292 /* try again to get the mutex */
292 if (!mutex_trylock(&mos_parport->serial->disc_mutex)) { 293 if (!mutex_trylock(&mos_parport->serial->disc_mutex)) {
293 dbg("%s: rescheduling tasklet", __func__); 294 dev_dbg(dev, "%s: rescheduling tasklet\n", __func__);
294 tasklet_schedule(&mos_parport->urb_tasklet); 295 tasklet_schedule(&mos_parport->urb_tasklet);
295 return; 296 return;
296 } 297 }
@@ -305,20 +306,19 @@ static void send_deferred_urbs(unsigned long _mos_parport)
305 if (list_empty(&mos_parport->deferred_urbs)) { 306 if (list_empty(&mos_parport->deferred_urbs)) {
306 spin_unlock_irqrestore(&mos_parport->listlock, flags); 307 spin_unlock_irqrestore(&mos_parport->listlock, flags);
307 mutex_unlock(&mos_parport->serial->disc_mutex); 308 mutex_unlock(&mos_parport->serial->disc_mutex);
308 dbg("%s: deferred_urbs list empty", __func__); 309 dev_dbg(dev, "%s: deferred_urbs list empty\n", __func__);
309 return; 310 return;
310 } 311 }
311 312
312 /* move contents of deferred_urbs list to active_urbs list and submit */ 313 /* move contents of deferred_urbs list to active_urbs list and submit */
313 list_for_each_safe(cursor, next, &mos_parport->deferred_urbs) 314 list_for_each_safe(cursor, next, &mos_parport->deferred_urbs)
314 list_move_tail(cursor, &mos_parport->active_urbs); 315 list_move_tail(cursor, &mos_parport->active_urbs);
315 list_for_each_entry(urbtrack, &mos_parport->active_urbs, 316 list_for_each_entry_safe(urbtrack, tmp, &mos_parport->active_urbs,
316 urblist_entry) { 317 urblist_entry) {
317 ret_val = usb_submit_urb(urbtrack->urb, GFP_ATOMIC); 318 ret_val = usb_submit_urb(urbtrack->urb, GFP_ATOMIC);
318 dbg("%s: urb submitted", __func__); 319 dev_dbg(dev, "%s: urb submitted\n", __func__);
319 if (ret_val) { 320 if (ret_val) {
320 dev_err(&mos_parport->serial->dev->dev, 321 dev_err(dev, "usb_submit_urb() failed: %d\n", ret_val);
321 "usb_submit_urb() failed: %d", ret_val);
322 list_del(&urbtrack->urblist_entry); 322 list_del(&urbtrack->urblist_entry);
323 kref_put(&urbtrack->ref_count, destroy_urbtracker); 323 kref_put(&urbtrack->ref_count, destroy_urbtracker);
324 } 324 }
@@ -334,7 +334,7 @@ static void async_complete(struct urb *urb)
334 int status = urb->status; 334 int status = urb->status;
335 335
336 if (unlikely(status)) 336 if (unlikely(status))
337 dbg("%s - nonzero urb status received: %d", __func__, status); 337 dev_dbg(&urb->dev->dev, "%s - nonzero urb status received: %d\n", __func__, status);
338 338
339 /* remove the urbtracker from the active_urbs list */ 339 /* remove the urbtracker from the active_urbs list */
340 spin_lock(&urbtrack->mos_parport->listlock); 340 spin_lock(&urbtrack->mos_parport->listlock);
@@ -389,7 +389,7 @@ static int write_parport_reg_nonblock(struct mos7715_parport *mos_parport,
389 &mos_parport->deferred_urbs); 389 &mos_parport->deferred_urbs);
390 spin_unlock_irqrestore(&mos_parport->listlock, flags); 390 spin_unlock_irqrestore(&mos_parport->listlock, flags);
391 tasklet_schedule(&mos_parport->urb_tasklet); 391 tasklet_schedule(&mos_parport->urb_tasklet);
392 dbg("tasklet scheduled"); 392 dev_dbg(&usbdev->dev, "tasklet scheduled");
393 return 0; 393 return 0;
394 } 394 }
395 395
@@ -690,7 +690,7 @@ static int mos7715_parport_init(struct usb_serial *serial)
690 /* allocate and initialize parallel port control struct */ 690 /* allocate and initialize parallel port control struct */
691 mos_parport = kzalloc(sizeof(struct mos7715_parport), GFP_KERNEL); 691 mos_parport = kzalloc(sizeof(struct mos7715_parport), GFP_KERNEL);
692 if (mos_parport == NULL) { 692 if (mos_parport == NULL) {
693 dbg("mos7715_parport_init: kzalloc failed"); 693 dev_dbg(&serial->dev->dev, "%s: kzalloc failed\n", __func__);
694 return -ENOMEM; 694 return -ENOMEM;
695 } 695 }
696 mos_parport->msg_pending = false; 696 mos_parport->msg_pending = false;
@@ -743,6 +743,7 @@ static void mos7720_interrupt_callback(struct urb *urb)
743 int result; 743 int result;
744 int length; 744 int length;
745 int status = urb->status; 745 int status = urb->status;
746 struct device *dev = &urb->dev->dev;
746 __u8 *data; 747 __u8 *data;
747 __u8 sp1; 748 __u8 sp1;
748 __u8 sp2; 749 __u8 sp2;
@@ -755,12 +756,10 @@ static void mos7720_interrupt_callback(struct urb *urb)
755 case -ENOENT: 756 case -ENOENT:
756 case -ESHUTDOWN: 757 case -ESHUTDOWN:
757 /* this urb is terminated, clean up */ 758 /* this urb is terminated, clean up */
758 dbg("%s - urb shutting down with status: %d", __func__, 759 dev_dbg(dev, "%s - urb shutting down with status: %d\n", __func__, status);
759 status);
760 return; 760 return;
761 default: 761 default:
762 dbg("%s - nonzero urb status received: %d", __func__, 762 dev_dbg(dev, "%s - nonzero urb status received: %d\n", __func__, status);
763 status);
764 goto exit; 763 goto exit;
765 } 764 }
766 765
@@ -777,7 +776,7 @@ static void mos7720_interrupt_callback(struct urb *urb)
777 * oneukum 2007-03-14 */ 776 * oneukum 2007-03-14 */
778 777
779 if (unlikely(length != 4)) { 778 if (unlikely(length != 4)) {
780 dbg("Wrong data !!!"); 779 dev_dbg(dev, "Wrong data !!!\n");
781 return; 780 return;
782 } 781 }
783 782
@@ -786,31 +785,29 @@ static void mos7720_interrupt_callback(struct urb *urb)
786 785
787 if ((sp1 | sp2) & 0x01) { 786 if ((sp1 | sp2) & 0x01) {
788 /* No Interrupt Pending in both the ports */ 787 /* No Interrupt Pending in both the ports */
789 dbg("No Interrupt !!!"); 788 dev_dbg(dev, "No Interrupt !!!\n");
790 } else { 789 } else {
791 switch (sp1 & 0x0f) { 790 switch (sp1 & 0x0f) {
792 case SERIAL_IIR_RLS: 791 case SERIAL_IIR_RLS:
793 dbg("Serial Port 1: Receiver status error or address " 792 dev_dbg(dev, "Serial Port 1: Receiver status error or address bit detected in 9-bit mode\n");
794 "bit detected in 9-bit mode\n");
795 break; 793 break;
796 case SERIAL_IIR_CTI: 794 case SERIAL_IIR_CTI:
797 dbg("Serial Port 1: Receiver time out"); 795 dev_dbg(dev, "Serial Port 1: Receiver time out\n");
798 break; 796 break;
799 case SERIAL_IIR_MS: 797 case SERIAL_IIR_MS:
800 /* dbg("Serial Port 1: Modem status change"); */ 798 /* dev_dbg(dev, "Serial Port 1: Modem status change\n"); */
801 break; 799 break;
802 } 800 }
803 801
804 switch (sp2 & 0x0f) { 802 switch (sp2 & 0x0f) {
805 case SERIAL_IIR_RLS: 803 case SERIAL_IIR_RLS:
806 dbg("Serial Port 2: Receiver status error or address " 804 dev_dbg(dev, "Serial Port 2: Receiver status error or address bit detected in 9-bit mode\n");
807 "bit detected in 9-bit mode");
808 break; 805 break;
809 case SERIAL_IIR_CTI: 806 case SERIAL_IIR_CTI:
810 dbg("Serial Port 2: Receiver time out"); 807 dev_dbg(dev, "Serial Port 2: Receiver time out\n");
811 break; 808 break;
812 case SERIAL_IIR_MS: 809 case SERIAL_IIR_MS:
813 /* dbg("Serial Port 2: Modem status change"); */ 810 /* dev_dbg(dev, "Serial Port 2: Modem status change\n"); */
814 break; 811 break;
815 } 812 }
816 } 813 }
@@ -818,9 +815,7 @@ static void mos7720_interrupt_callback(struct urb *urb)
818exit: 815exit:
819 result = usb_submit_urb(urb, GFP_ATOMIC); 816 result = usb_submit_urb(urb, GFP_ATOMIC);
820 if (result) 817 if (result)
821 dev_err(&urb->dev->dev, 818 dev_err(dev, "%s - Error %d submitting control urb\n", __func__, result);
822 "%s - Error %d submitting control urb\n",
823 __func__, result);
824} 819}
825 820
826/* 821/*
@@ -833,6 +828,7 @@ static void mos7715_interrupt_callback(struct urb *urb)
833 int result; 828 int result;
834 int length; 829 int length;
835 int status = urb->status; 830 int status = urb->status;
831 struct device *dev = &urb->dev->dev;
836 __u8 *data; 832 __u8 *data;
837 __u8 iir; 833 __u8 iir;
838 834
@@ -845,12 +841,10 @@ static void mos7715_interrupt_callback(struct urb *urb)
845 case -ESHUTDOWN: 841 case -ESHUTDOWN:
846 case -ENODEV: 842 case -ENODEV:
847 /* this urb is terminated, clean up */ 843 /* this urb is terminated, clean up */
848 dbg("%s - urb shutting down with status: %d", __func__, 844 dev_dbg(dev, "%s - urb shutting down with status: %d\n", __func__, status);
849 status);
850 return; 845 return;
851 default: 846 default:
852 dbg("%s - nonzero urb status received: %d", __func__, 847 dev_dbg(dev, "%s - nonzero urb status received: %d\n", __func__, status);
853 status);
854 goto exit; 848 goto exit;
855 } 849 }
856 850
@@ -864,7 +858,7 @@ static void mos7715_interrupt_callback(struct urb *urb)
864 * Byte 4: FIFO status for both */ 858 * Byte 4: FIFO status for both */
865 859
866 if (unlikely(length != 4)) { 860 if (unlikely(length != 4)) {
867 dbg("Wrong data !!!"); 861 dev_dbg(dev, "Wrong data !!!\n");
868 return; 862 return;
869 } 863 }
870 864
@@ -872,14 +866,13 @@ static void mos7715_interrupt_callback(struct urb *urb)
872 if (!(iir & 0x01)) { /* serial port interrupt pending */ 866 if (!(iir & 0x01)) { /* serial port interrupt pending */
873 switch (iir & 0x0f) { 867 switch (iir & 0x0f) {
874 case SERIAL_IIR_RLS: 868 case SERIAL_IIR_RLS:
875 dbg("Serial Port: Receiver status error or address " 869 dev_dbg(dev, "Serial Port: Receiver status error or address bit detected in 9-bit mode\n\n");
876 "bit detected in 9-bit mode\n");
877 break; 870 break;
878 case SERIAL_IIR_CTI: 871 case SERIAL_IIR_CTI:
879 dbg("Serial Port: Receiver time out"); 872 dev_dbg(dev, "Serial Port: Receiver time out\n");
880 break; 873 break;
881 case SERIAL_IIR_MS: 874 case SERIAL_IIR_MS:
882 /* dbg("Serial Port: Modem status change"); */ 875 /* dev_dbg(dev, "Serial Port: Modem status change\n"); */
883 break; 876 break;
884 } 877 }
885 } 878 }
@@ -897,9 +890,7 @@ static void mos7715_interrupt_callback(struct urb *urb)
897exit: 890exit:
898 result = usb_submit_urb(urb, GFP_ATOMIC); 891 result = usb_submit_urb(urb, GFP_ATOMIC);
899 if (result) 892 if (result)
900 dev_err(&urb->dev->dev, 893 dev_err(dev, "%s - Error %d submitting control urb\n", __func__, result);
901 "%s - Error %d submitting control urb\n",
902 __func__, result);
903} 894}
904 895
905/* 896/*
@@ -916,13 +907,13 @@ static void mos7720_bulk_in_callback(struct urb *urb)
916 int status = urb->status; 907 int status = urb->status;
917 908
918 if (status) { 909 if (status) {
919 dbg("nonzero read bulk status received: %d", status); 910 dev_dbg(&urb->dev->dev, "nonzero read bulk status received: %d\n", status);
920 return; 911 return;
921 } 912 }
922 913
923 port = urb->context; 914 port = urb->context;
924 915
925 dbg("Entering...%s", __func__); 916 dev_dbg(&port->dev, "Entering...%s\n", __func__);
926 917
927 data = urb->transfer_buffer; 918 data = urb->transfer_buffer;
928 919
@@ -936,8 +927,7 @@ static void mos7720_bulk_in_callback(struct urb *urb)
936 if (port->read_urb->status != -EINPROGRESS) { 927 if (port->read_urb->status != -EINPROGRESS) {
937 retval = usb_submit_urb(port->read_urb, GFP_ATOMIC); 928 retval = usb_submit_urb(port->read_urb, GFP_ATOMIC);
938 if (retval) 929 if (retval)
939 dbg("usb_submit_urb(read bulk) failed, retval = %d", 930 dev_dbg(&port->dev, "usb_submit_urb(read bulk) failed, retval = %d\n", retval);
940 retval);
941 } 931 }
942} 932}
943 933
@@ -953,13 +943,13 @@ static void mos7720_bulk_out_data_callback(struct urb *urb)
953 int status = urb->status; 943 int status = urb->status;
954 944
955 if (status) { 945 if (status) {
956 dbg("nonzero write bulk status received:%d", status); 946 dev_dbg(&urb->dev->dev, "nonzero write bulk status received:%d\n", status);
957 return; 947 return;
958 } 948 }
959 949
960 mos7720_port = urb->context; 950 mos7720_port = urb->context;
961 if (!mos7720_port) { 951 if (!mos7720_port) {
962 dbg("NULL mos7720_port pointer"); 952 dev_dbg(&urb->dev->dev, "NULL mos7720_port pointer\n");
963 return ; 953 return ;
964 } 954 }
965 955
@@ -1061,9 +1051,7 @@ static int mos7720_open(struct tty_struct *tty, struct usb_serial_port *port)
1061 port_number = port->number - port->serial->minor; 1051 port_number = port->number - port->serial->minor;
1062 read_mos_reg(serial, port_number, LSR, &data); 1052 read_mos_reg(serial, port_number, LSR, &data);
1063 1053
1064 dbg("SS::%p LSR:%x", mos7720_port, data); 1054 dev_dbg(&port->dev, "SS::%p LSR:%x\n", mos7720_port, data);
1065
1066 dbg("Check:Sending Command ..........");
1067 1055
1068 write_mos_reg(serial, dummy, SP1_REG, 0x02); 1056 write_mos_reg(serial, dummy, SP1_REG, 0x02);
1069 write_mos_reg(serial, dummy, SP2_REG, 0x02); 1057 write_mos_reg(serial, dummy, SP2_REG, 0x02);
@@ -1122,20 +1110,16 @@ static int mos7720_chars_in_buffer(struct tty_struct *tty)
1122 int chars = 0; 1110 int chars = 0;
1123 struct moschip_port *mos7720_port; 1111 struct moschip_port *mos7720_port;
1124 1112
1125 dbg("%s:entering ...........", __func__);
1126
1127 mos7720_port = usb_get_serial_port_data(port); 1113 mos7720_port = usb_get_serial_port_data(port);
1128 if (mos7720_port == NULL) { 1114 if (mos7720_port == NULL)
1129 dbg("%s:leaving ...........", __func__);
1130 return 0; 1115 return 0;
1131 }
1132 1116
1133 for (i = 0; i < NUM_URBS; ++i) { 1117 for (i = 0; i < NUM_URBS; ++i) {
1134 if (mos7720_port->write_urb_pool[i] && 1118 if (mos7720_port->write_urb_pool[i] &&
1135 mos7720_port->write_urb_pool[i]->status == -EINPROGRESS) 1119 mos7720_port->write_urb_pool[i]->status == -EINPROGRESS)
1136 chars += URB_TRANSFER_BUFFER_SIZE; 1120 chars += URB_TRANSFER_BUFFER_SIZE;
1137 } 1121 }
1138 dbg("%s - returns %d", __func__, chars); 1122 dev_dbg(&port->dev, "%s - returns %d\n", __func__, chars);
1139 return chars; 1123 return chars;
1140} 1124}
1141 1125
@@ -1145,8 +1129,6 @@ static void mos7720_close(struct usb_serial_port *port)
1145 struct moschip_port *mos7720_port; 1129 struct moschip_port *mos7720_port;
1146 int j; 1130 int j;
1147 1131
1148 dbg("mos7720_close:entering...");
1149
1150 serial = port->serial; 1132 serial = port->serial;
1151 1133
1152 mos7720_port = usb_get_serial_port_data(port); 1134 mos7720_port = usb_get_serial_port_data(port);
@@ -1166,9 +1148,7 @@ static void mos7720_close(struct usb_serial_port *port)
1166 1148
1167 /* While closing port, shutdown all bulk read, write * 1149 /* While closing port, shutdown all bulk read, write *
1168 * and interrupt read if they exists, otherwise nop */ 1150 * and interrupt read if they exists, otherwise nop */
1169 dbg("Shutdown bulk write");
1170 usb_kill_urb(port->write_urb); 1151 usb_kill_urb(port->write_urb);
1171 dbg("Shutdown bulk read");
1172 usb_kill_urb(port->read_urb); 1152 usb_kill_urb(port->read_urb);
1173 1153
1174 mutex_lock(&serial->disc_mutex); 1154 mutex_lock(&serial->disc_mutex);
@@ -1182,8 +1162,6 @@ static void mos7720_close(struct usb_serial_port *port)
1182 } 1162 }
1183 mutex_unlock(&serial->disc_mutex); 1163 mutex_unlock(&serial->disc_mutex);
1184 mos7720_port->open = 0; 1164 mos7720_port->open = 0;
1185
1186 dbg("Leaving %s", __func__);
1187} 1165}
1188 1166
1189static void mos7720_break(struct tty_struct *tty, int break_state) 1167static void mos7720_break(struct tty_struct *tty, int break_state)
@@ -1193,8 +1171,6 @@ static void mos7720_break(struct tty_struct *tty, int break_state)
1193 struct usb_serial *serial; 1171 struct usb_serial *serial;
1194 struct moschip_port *mos7720_port; 1172 struct moschip_port *mos7720_port;
1195 1173
1196 dbg("Entering %s", __func__);
1197
1198 serial = port->serial; 1174 serial = port->serial;
1199 1175
1200 mos7720_port = usb_get_serial_port_data(port); 1176 mos7720_port = usb_get_serial_port_data(port);
@@ -1225,13 +1201,9 @@ static int mos7720_write_room(struct tty_struct *tty)
1225 int room = 0; 1201 int room = 0;
1226 int i; 1202 int i;
1227 1203
1228 dbg("%s:entering ...........", __func__);
1229
1230 mos7720_port = usb_get_serial_port_data(port); 1204 mos7720_port = usb_get_serial_port_data(port);
1231 if (mos7720_port == NULL) { 1205 if (mos7720_port == NULL)
1232 dbg("%s:leaving ...........", __func__);
1233 return -ENODEV; 1206 return -ENODEV;
1234 }
1235 1207
1236 /* FIXME: Locking */ 1208 /* FIXME: Locking */
1237 for (i = 0; i < NUM_URBS; ++i) { 1209 for (i = 0; i < NUM_URBS; ++i) {
@@ -1240,7 +1212,7 @@ static int mos7720_write_room(struct tty_struct *tty)
1240 room += URB_TRANSFER_BUFFER_SIZE; 1212 room += URB_TRANSFER_BUFFER_SIZE;
1241 } 1213 }
1242 1214
1243 dbg("%s - returns %d", __func__, room); 1215 dev_dbg(&port->dev, "%s - returns %d\n", __func__, room);
1244 return room; 1216 return room;
1245} 1217}
1246 1218
@@ -1257,15 +1229,11 @@ static int mos7720_write(struct tty_struct *tty, struct usb_serial_port *port,
1257 struct urb *urb; 1229 struct urb *urb;
1258 const unsigned char *current_position = data; 1230 const unsigned char *current_position = data;
1259 1231
1260 dbg("%s:entering ...........", __func__);
1261
1262 serial = port->serial; 1232 serial = port->serial;
1263 1233
1264 mos7720_port = usb_get_serial_port_data(port); 1234 mos7720_port = usb_get_serial_port_data(port);
1265 if (mos7720_port == NULL) { 1235 if (mos7720_port == NULL)
1266 dbg("mos7720_port is NULL");
1267 return -ENODEV; 1236 return -ENODEV;
1268 }
1269 1237
1270 /* try to find a free urb in the list */ 1238 /* try to find a free urb in the list */
1271 urb = NULL; 1239 urb = NULL;
@@ -1274,13 +1242,13 @@ static int mos7720_write(struct tty_struct *tty, struct usb_serial_port *port,
1274 if (mos7720_port->write_urb_pool[i] && 1242 if (mos7720_port->write_urb_pool[i] &&
1275 mos7720_port->write_urb_pool[i]->status != -EINPROGRESS) { 1243 mos7720_port->write_urb_pool[i]->status != -EINPROGRESS) {
1276 urb = mos7720_port->write_urb_pool[i]; 1244 urb = mos7720_port->write_urb_pool[i];
1277 dbg("URB:%d", i); 1245 dev_dbg(&port->dev, "URB:%d\n", i);
1278 break; 1246 break;
1279 } 1247 }
1280 } 1248 }
1281 1249
1282 if (urb == NULL) { 1250 if (urb == NULL) {
1283 dbg("%s - no more free urbs", __func__); 1251 dev_dbg(&port->dev, "%s - no more free urbs\n", __func__);
1284 goto exit; 1252 goto exit;
1285 } 1253 }
1286 1254
@@ -1296,7 +1264,7 @@ static int mos7720_write(struct tty_struct *tty, struct usb_serial_port *port,
1296 transfer_size = min(count, URB_TRANSFER_BUFFER_SIZE); 1264 transfer_size = min(count, URB_TRANSFER_BUFFER_SIZE);
1297 1265
1298 memcpy(urb->transfer_buffer, current_position, transfer_size); 1266 memcpy(urb->transfer_buffer, current_position, transfer_size);
1299 usb_serial_debug_data(debug, &port->dev, __func__, transfer_size, 1267 usb_serial_debug_data(&port->dev, __func__, transfer_size,
1300 urb->transfer_buffer); 1268 urb->transfer_buffer);
1301 1269
1302 /* fill urb with data and submit */ 1270 /* fill urb with data and submit */
@@ -1326,20 +1294,16 @@ static void mos7720_throttle(struct tty_struct *tty)
1326 struct moschip_port *mos7720_port; 1294 struct moschip_port *mos7720_port;
1327 int status; 1295 int status;
1328 1296
1329 dbg("%s- port %d", __func__, port->number);
1330
1331 mos7720_port = usb_get_serial_port_data(port); 1297 mos7720_port = usb_get_serial_port_data(port);
1332 1298
1333 if (mos7720_port == NULL) 1299 if (mos7720_port == NULL)
1334 return; 1300 return;
1335 1301
1336 if (!mos7720_port->open) { 1302 if (!mos7720_port->open) {
1337 dbg("port not opened"); 1303 dev_dbg(&port->dev, "%s - port not opened\n", __func__);
1338 return; 1304 return;
1339 } 1305 }
1340 1306
1341 dbg("%s: Entering ..........", __func__);
1342
1343 /* if we are implementing XON/XOFF, send the stop character */ 1307 /* if we are implementing XON/XOFF, send the stop character */
1344 if (I_IXOFF(tty)) { 1308 if (I_IXOFF(tty)) {
1345 unsigned char stop_char = STOP_CHAR(tty); 1309 unsigned char stop_char = STOP_CHAR(tty);
@@ -1368,12 +1332,10 @@ static void mos7720_unthrottle(struct tty_struct *tty)
1368 return; 1332 return;
1369 1333
1370 if (!mos7720_port->open) { 1334 if (!mos7720_port->open) {
1371 dbg("%s - port not opened", __func__); 1335 dev_dbg(&port->dev, "%s - port not opened\n", __func__);
1372 return; 1336 return;
1373 } 1337 }
1374 1338
1375 dbg("%s: Entering ..........", __func__);
1376
1377 /* if we are implementing XON/XOFF, send the start character */ 1339 /* if we are implementing XON/XOFF, send the start character */
1378 if (I_IXOFF(tty)) { 1340 if (I_IXOFF(tty)) {
1379 unsigned char start_char = START_CHAR(tty); 1341 unsigned char start_char = START_CHAR(tty);
@@ -1409,7 +1371,7 @@ static int set_higher_rates(struct moschip_port *mos7720_port,
1409 /*********************************************** 1371 /***********************************************
1410 * Init Sequence for higher rates 1372 * Init Sequence for higher rates
1411 ***********************************************/ 1373 ***********************************************/
1412 dbg("Sending Setting Commands .........."); 1374 dev_dbg(&port->dev, "Sending Setting Commands ..........\n");
1413 port_number = port->number - port->serial->minor; 1375 port_number = port->number - port->serial->minor;
1414 1376
1415 write_mos_reg(serial, port_number, IER, 0x00); 1377 write_mos_reg(serial, port_number, IER, 0x00);
@@ -1478,7 +1440,7 @@ static struct divisor_table_entry divisor_table[] = {
1478 * this function calculates the proper baud rate divisor for the specified 1440 * this function calculates the proper baud rate divisor for the specified
1479 * baud rate. 1441 * baud rate.
1480 *****************************************************************************/ 1442 *****************************************************************************/
1481static int calc_baud_rate_divisor(int baudrate, int *divisor) 1443static int calc_baud_rate_divisor(struct usb_serial_port *port, int baudrate, int *divisor)
1482{ 1444{
1483 int i; 1445 int i;
1484 __u16 custom; 1446 __u16 custom;
@@ -1486,7 +1448,7 @@ static int calc_baud_rate_divisor(int baudrate, int *divisor)
1486 __u16 round; 1448 __u16 round;
1487 1449
1488 1450
1489 dbg("%s - %d", __func__, baudrate); 1451 dev_dbg(&port->dev, "%s - %d\n", __func__, baudrate);
1490 1452
1491 for (i = 0; i < ARRAY_SIZE(divisor_table); i++) { 1453 for (i = 0; i < ARRAY_SIZE(divisor_table); i++) {
1492 if (divisor_table[i].baudrate == baudrate) { 1454 if (divisor_table[i].baudrate == baudrate) {
@@ -1508,11 +1470,11 @@ static int calc_baud_rate_divisor(int baudrate, int *divisor)
1508 custom++; 1470 custom++;
1509 *divisor = custom; 1471 *divisor = custom;
1510 1472
1511 dbg("Baud %d = %d", baudrate, custom); 1473 dev_dbg(&port->dev, "Baud %d = %d\n", baudrate, custom);
1512 return 0; 1474 return 0;
1513 } 1475 }
1514 1476
1515 dbg("Baud calculation Failed..."); 1477 dev_dbg(&port->dev, "Baud calculation Failed...\n");
1516 return -EINVAL; 1478 return -EINVAL;
1517} 1479}
1518 1480
@@ -1536,13 +1498,11 @@ static int send_cmd_write_baud_rate(struct moschip_port *mos7720_port,
1536 port = mos7720_port->port; 1498 port = mos7720_port->port;
1537 serial = port->serial; 1499 serial = port->serial;
1538 1500
1539 dbg("%s: Entering ..........", __func__);
1540
1541 number = port->number - port->serial->minor; 1501 number = port->number - port->serial->minor;
1542 dbg("%s - port = %d, baud = %d", __func__, port->number, baudrate); 1502 dev_dbg(&port->dev, "%s - baud = %d\n", __func__, baudrate);
1543 1503
1544 /* Calculate the Divisor */ 1504 /* Calculate the Divisor */
1545 status = calc_baud_rate_divisor(baudrate, &divisor); 1505 status = calc_baud_rate_divisor(port, baudrate, &divisor);
1546 if (status) { 1506 if (status) {
1547 dev_err(&port->dev, "%s - bad baud rate\n", __func__); 1507 dev_err(&port->dev, "%s - bad baud rate\n", __func__);
1548 return status; 1508 return status;
@@ -1591,15 +1551,11 @@ static void change_port_settings(struct tty_struct *tty,
1591 serial = port->serial; 1551 serial = port->serial;
1592 port_number = port->number - port->serial->minor; 1552 port_number = port->number - port->serial->minor;
1593 1553
1594 dbg("%s - port %d", __func__, port->number);
1595
1596 if (!mos7720_port->open) { 1554 if (!mos7720_port->open) {
1597 dbg("%s - port not opened", __func__); 1555 dev_dbg(&port->dev, "%s - port not opened\n", __func__);
1598 return; 1556 return;
1599 } 1557 }
1600 1558
1601 dbg("%s: Entering ..........", __func__);
1602
1603 lData = UART_LCR_WLEN8; 1559 lData = UART_LCR_WLEN8;
1604 lStop = 0x00; /* 1 stop bit */ 1560 lStop = 0x00; /* 1 stop bit */
1605 lParity = 0x00; /* No parity */ 1561 lParity = 0x00; /* No parity */
@@ -1633,14 +1589,14 @@ static void change_port_settings(struct tty_struct *tty,
1633 if (cflag & PARENB) { 1589 if (cflag & PARENB) {
1634 if (cflag & PARODD) { 1590 if (cflag & PARODD) {
1635 lParity = UART_LCR_PARITY; 1591 lParity = UART_LCR_PARITY;
1636 dbg("%s - parity = odd", __func__); 1592 dev_dbg(&port->dev, "%s - parity = odd\n", __func__);
1637 } else { 1593 } else {
1638 lParity = (UART_LCR_EPAR | UART_LCR_PARITY); 1594 lParity = (UART_LCR_EPAR | UART_LCR_PARITY);
1639 dbg("%s - parity = even", __func__); 1595 dev_dbg(&port->dev, "%s - parity = even\n", __func__);
1640 } 1596 }
1641 1597
1642 } else { 1598 } else {
1643 dbg("%s - parity = none", __func__); 1599 dev_dbg(&port->dev, "%s - parity = none\n", __func__);
1644 } 1600 }
1645 1601
1646 if (cflag & CMSPAR) 1602 if (cflag & CMSPAR)
@@ -1649,10 +1605,10 @@ static void change_port_settings(struct tty_struct *tty,
1649 /* Change the Stop bit */ 1605 /* Change the Stop bit */
1650 if (cflag & CSTOPB) { 1606 if (cflag & CSTOPB) {
1651 lStop = UART_LCR_STOP; 1607 lStop = UART_LCR_STOP;
1652 dbg("%s - stop bits = 2", __func__); 1608 dev_dbg(&port->dev, "%s - stop bits = 2\n", __func__);
1653 } else { 1609 } else {
1654 lStop = 0x00; 1610 lStop = 0x00;
1655 dbg("%s - stop bits = 1", __func__); 1611 dev_dbg(&port->dev, "%s - stop bits = 1\n", __func__);
1656 } 1612 }
1657 1613
1658#define LCR_BITS_MASK 0x03 /* Mask for bits/char field */ 1614#define LCR_BITS_MASK 0x03 /* Mask for bits/char field */
@@ -1698,7 +1654,7 @@ static void change_port_settings(struct tty_struct *tty,
1698 baud = tty_get_baud_rate(tty); 1654 baud = tty_get_baud_rate(tty);
1699 if (!baud) { 1655 if (!baud) {
1700 /* pick a default, any default... */ 1656 /* pick a default, any default... */
1701 dbg("Picked default baud..."); 1657 dev_dbg(&port->dev, "Picked default baud...\n");
1702 baud = 9600; 1658 baud = 9600;
1703 } 1659 }
1704 1660
@@ -1709,7 +1665,7 @@ static void change_port_settings(struct tty_struct *tty,
1709 return; 1665 return;
1710 } 1666 }
1711 1667
1712 dbg("%s - baud rate = %d", __func__, baud); 1668 dev_dbg(&port->dev, "%s - baud rate = %d\n", __func__, baud);
1713 status = send_cmd_write_baud_rate(mos7720_port, baud); 1669 status = send_cmd_write_baud_rate(mos7720_port, baud);
1714 /* FIXME: needs to write actual resulting baud back not just 1670 /* FIXME: needs to write actual resulting baud back not just
1715 blindly do so */ 1671 blindly do so */
@@ -1721,8 +1677,7 @@ static void change_port_settings(struct tty_struct *tty,
1721 if (port->read_urb->status != -EINPROGRESS) { 1677 if (port->read_urb->status != -EINPROGRESS) {
1722 status = usb_submit_urb(port->read_urb, GFP_ATOMIC); 1678 status = usb_submit_urb(port->read_urb, GFP_ATOMIC);
1723 if (status) 1679 if (status)
1724 dbg("usb_submit_urb(read bulk) failed, status = %d", 1680 dev_dbg(&port->dev, "usb_submit_urb(read bulk) failed, status = %d\n", status);
1725 status);
1726 } 1681 }
1727} 1682}
1728 1683
@@ -1747,23 +1702,19 @@ static void mos7720_set_termios(struct tty_struct *tty,
1747 return; 1702 return;
1748 1703
1749 if (!mos7720_port->open) { 1704 if (!mos7720_port->open) {
1750 dbg("%s - port not opened", __func__); 1705 dev_dbg(&port->dev, "%s - port not opened\n", __func__);
1751 return; 1706 return;
1752 } 1707 }
1753 1708
1754 dbg("%s\n", "setting termios - ASPIRE"); 1709 dev_dbg(&port->dev, "setting termios - ASPIRE\n");
1755 1710
1756 cflag = tty->termios.c_cflag; 1711 cflag = tty->termios.c_cflag;
1757 1712
1758 dbg("%s - cflag %08x iflag %08x", __func__, 1713 dev_dbg(&port->dev, "%s - cflag %08x iflag %08x\n", __func__,
1759 tty->termios.c_cflag, 1714 tty->termios.c_cflag, RELEVANT_IFLAG(tty->termios.c_iflag));
1760 RELEVANT_IFLAG(tty->termios.c_iflag));
1761 1715
1762 dbg("%s - old cflag %08x old iflag %08x", __func__, 1716 dev_dbg(&port->dev, "%s - old cflag %08x old iflag %08x\n", __func__,
1763 old_termios->c_cflag, 1717 old_termios->c_cflag, RELEVANT_IFLAG(old_termios->c_iflag));
1764 RELEVANT_IFLAG(old_termios->c_iflag));
1765
1766 dbg("%s - port %d", __func__, port->number);
1767 1718
1768 /* change the port settings to the new ones specified */ 1719 /* change the port settings to the new ones specified */
1769 change_port_settings(tty, mos7720_port, old_termios); 1720 change_port_settings(tty, mos7720_port, old_termios);
@@ -1771,8 +1722,7 @@ static void mos7720_set_termios(struct tty_struct *tty,
1771 if (port->read_urb->status != -EINPROGRESS) { 1722 if (port->read_urb->status != -EINPROGRESS) {
1772 status = usb_submit_urb(port->read_urb, GFP_ATOMIC); 1723 status = usb_submit_urb(port->read_urb, GFP_ATOMIC);
1773 if (status) 1724 if (status)
1774 dbg("usb_submit_urb(read bulk) failed, status = %d", 1725 dev_dbg(&port->dev, "usb_submit_urb(read bulk) failed, status = %d\n", status);
1775 status);
1776 } 1726 }
1777} 1727}
1778 1728
@@ -1800,7 +1750,7 @@ static int get_lsr_info(struct tty_struct *tty,
1800 read_mos_reg(port->serial, port_number, LSR, &data); 1750 read_mos_reg(port->serial, port_number, LSR, &data);
1801 if ((data & (UART_LSR_TEMT | UART_LSR_THRE)) 1751 if ((data & (UART_LSR_TEMT | UART_LSR_THRE))
1802 == (UART_LSR_TEMT | UART_LSR_THRE)) { 1752 == (UART_LSR_TEMT | UART_LSR_THRE)) {
1803 dbg("%s -- Empty", __func__); 1753 dev_dbg(&port->dev, "%s -- Empty\n", __func__);
1804 result = TIOCSER_TEMT; 1754 result = TIOCSER_TEMT;
1805 } 1755 }
1806 } 1756 }
@@ -1817,8 +1767,6 @@ static int mos7720_tiocmget(struct tty_struct *tty)
1817 unsigned int mcr ; 1767 unsigned int mcr ;
1818 unsigned int msr ; 1768 unsigned int msr ;
1819 1769
1820 dbg("%s - port %d", __func__, port->number);
1821
1822 mcr = mos7720_port->shadowMCR; 1770 mcr = mos7720_port->shadowMCR;
1823 msr = mos7720_port->shadowMSR; 1771 msr = mos7720_port->shadowMSR;
1824 1772
@@ -1829,8 +1777,6 @@ static int mos7720_tiocmget(struct tty_struct *tty)
1829 | ((msr & UART_MSR_RI) ? TIOCM_RI : 0) /* 0x080 */ 1777 | ((msr & UART_MSR_RI) ? TIOCM_RI : 0) /* 0x080 */
1830 | ((msr & UART_MSR_DSR) ? TIOCM_DSR : 0); /* 0x100 */ 1778 | ((msr & UART_MSR_DSR) ? TIOCM_DSR : 0); /* 0x100 */
1831 1779
1832 dbg("%s -- %x", __func__, result);
1833
1834 return result; 1780 return result;
1835} 1781}
1836 1782
@@ -1840,8 +1786,6 @@ static int mos7720_tiocmset(struct tty_struct *tty,
1840 struct usb_serial_port *port = tty->driver_data; 1786 struct usb_serial_port *port = tty->driver_data;
1841 struct moschip_port *mos7720_port = usb_get_serial_port_data(port); 1787 struct moschip_port *mos7720_port = usb_get_serial_port_data(port);
1842 unsigned int mcr ; 1788 unsigned int mcr ;
1843 dbg("%s - port %d", __func__, port->number);
1844 dbg("he was at tiocmset");
1845 1789
1846 mcr = mos7720_port->shadowMCR; 1790 mcr = mos7720_port->shadowMCR;
1847 1791
@@ -1888,8 +1832,8 @@ static int mos7720_get_icount(struct tty_struct *tty,
1888 icount->brk = cnow.brk; 1832 icount->brk = cnow.brk;
1889 icount->buf_overrun = cnow.buf_overrun; 1833 icount->buf_overrun = cnow.buf_overrun;
1890 1834
1891 dbg("%s (%d) TIOCGICOUNT RX=%d, TX=%d", __func__, 1835 dev_dbg(&port->dev, "%s TIOCGICOUNT RX=%d, TX=%d\n", __func__,
1892 port->number, icount->rx, icount->tx); 1836 icount->rx, icount->tx);
1893 return 0; 1837 return 0;
1894} 1838}
1895 1839
@@ -1975,29 +1919,28 @@ static int mos7720_ioctl(struct tty_struct *tty,
1975 if (mos7720_port == NULL) 1919 if (mos7720_port == NULL)
1976 return -ENODEV; 1920 return -ENODEV;
1977 1921
1978 dbg("%s - port %d, cmd = 0x%x", __func__, port->number, cmd); 1922 dev_dbg(&port->dev, "%s - cmd = 0x%x", __func__, cmd);
1979 1923
1980 switch (cmd) { 1924 switch (cmd) {
1981 case TIOCSERGETLSR: 1925 case TIOCSERGETLSR:
1982 dbg("%s (%d) TIOCSERGETLSR", __func__, port->number); 1926 dev_dbg(&port->dev, "%s TIOCSERGETLSR\n", __func__);
1983 return get_lsr_info(tty, mos7720_port, 1927 return get_lsr_info(tty, mos7720_port,
1984 (unsigned int __user *)arg); 1928 (unsigned int __user *)arg);
1985 1929
1986 /* FIXME: These should be using the mode methods */ 1930 /* FIXME: These should be using the mode methods */
1987 case TIOCMBIS: 1931 case TIOCMBIS:
1988 case TIOCMBIC: 1932 case TIOCMBIC:
1989 dbg("%s (%d) TIOCMSET/TIOCMBIC/TIOCMSET", 1933 dev_dbg(&port->dev, "%s TIOCMSET/TIOCMBIC/TIOCMSET\n", __func__);
1990 __func__, port->number);
1991 return set_modem_info(mos7720_port, cmd, 1934 return set_modem_info(mos7720_port, cmd,
1992 (unsigned int __user *)arg); 1935 (unsigned int __user *)arg);
1993 1936
1994 case TIOCGSERIAL: 1937 case TIOCGSERIAL:
1995 dbg("%s (%d) TIOCGSERIAL", __func__, port->number); 1938 dev_dbg(&port->dev, "%s TIOCGSERIAL\n", __func__);
1996 return get_serial_info(mos7720_port, 1939 return get_serial_info(mos7720_port,
1997 (struct serial_struct __user *)arg); 1940 (struct serial_struct __user *)arg);
1998 1941
1999 case TIOCMIWAIT: 1942 case TIOCMIWAIT:
2000 dbg("%s (%d) TIOCMIWAIT", __func__, port->number); 1943 dev_dbg(&port->dev, "%s TIOCMIWAIT\n", __func__);
2001 cprev = mos7720_port->icount; 1944 cprev = mos7720_port->icount;
2002 while (1) { 1945 while (1) {
2003 if (signal_pending(current)) 1946 if (signal_pending(current))
@@ -2030,13 +1973,6 @@ static int mos7720_startup(struct usb_serial *serial)
2030 u16 product; 1973 u16 product;
2031 int ret_val; 1974 int ret_val;
2032 1975
2033 dbg("%s: Entering ..........", __func__);
2034
2035 if (!serial) {
2036 dbg("Invalid Handler");
2037 return -ENODEV;
2038 }
2039
2040 product = le16_to_cpu(serial->dev->descriptor.idProduct); 1976 product = le16_to_cpu(serial->dev->descriptor.idProduct);
2041 dev = serial->dev; 1977 dev = serial->dev;
2042 1978
@@ -2081,8 +2017,8 @@ static int mos7720_startup(struct usb_serial *serial)
2081 mos7720_port->port = serial->port[i]; 2017 mos7720_port->port = serial->port[i];
2082 usb_set_serial_port_data(serial->port[i], mos7720_port); 2018 usb_set_serial_port_data(serial->port[i], mos7720_port);
2083 2019
2084 dbg("port number is %d", serial->port[i]->number); 2020 dev_dbg(&dev->dev, "port number is %d\n", serial->port[i]->number);
2085 dbg("serial number is %d", serial->minor); 2021 dev_dbg(&dev->dev, "serial number is %d\n", serial->minor);
2086 } 2022 }
2087 2023
2088 2024
@@ -2106,7 +2042,7 @@ static int mos7720_startup(struct usb_serial *serial)
2106#endif 2042#endif
2107 /* LSR For Port 1 */ 2043 /* LSR For Port 1 */
2108 read_mos_reg(serial, 0, LSR, &data); 2044 read_mos_reg(serial, 0, LSR, &data);
2109 dbg("LSR:%x", data); 2045 dev_dbg(&dev->dev, "LSR:%x\n", data);
2110 2046
2111 return 0; 2047 return 0;
2112} 2048}
@@ -2195,6 +2131,3 @@ module_usb_serial_driver(serial_drivers, id_table);
2195MODULE_AUTHOR(DRIVER_AUTHOR); 2131MODULE_AUTHOR(DRIVER_AUTHOR);
2196MODULE_DESCRIPTION(DRIVER_DESC); 2132MODULE_DESCRIPTION(DRIVER_DESC);
2197MODULE_LICENSE("GPL"); 2133MODULE_LICENSE("GPL");
2198
2199module_param(debug, bool, S_IRUGO | S_IWUSR);
2200MODULE_PARM_DESC(debug, "Debug enabled or not");
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
index 402c32d7accb..d6d4eeca8c68 100644
--- a/drivers/usb/serial/mos7840.c
+++ b/drivers/usb/serial/mos7840.c
@@ -252,8 +252,6 @@ struct moschip_port {
252 struct timer_list led_timer2; /* Timer for LED off */ 252 struct timer_list led_timer2; /* Timer for LED off */
253}; 253};
254 254
255static bool debug;
256
257/* 255/*
258 * mos7840_set_reg_sync 256 * mos7840_set_reg_sync
259 * To set the Control register by calling usb_fill_control_urb function 257 * To set the Control register by calling usb_fill_control_urb function
@@ -265,7 +263,7 @@ static int mos7840_set_reg_sync(struct usb_serial_port *port, __u16 reg,
265{ 263{
266 struct usb_device *dev = port->serial->dev; 264 struct usb_device *dev = port->serial->dev;
267 val = val & 0x00ff; 265 val = val & 0x00ff;
268 dbg("mos7840_set_reg_sync offset is %x, value %x", reg, val); 266 dev_dbg(&port->dev, "mos7840_set_reg_sync offset is %x, value %x\n", reg, val);
269 267
270 return usb_control_msg(dev, usb_sndctrlpipe(dev, 0), MCS_WRREQ, 268 return usb_control_msg(dev, usb_sndctrlpipe(dev, 0), MCS_WRREQ,
271 MCS_WR_RTYPE, val, reg, NULL, 0, 269 MCS_WR_RTYPE, val, reg, NULL, 0,
@@ -293,7 +291,7 @@ static int mos7840_get_reg_sync(struct usb_serial_port *port, __u16 reg,
293 MCS_RD_RTYPE, 0, reg, buf, VENDOR_READ_LENGTH, 291 MCS_RD_RTYPE, 0, reg, buf, VENDOR_READ_LENGTH,
294 MOS_WDR_TIMEOUT); 292 MOS_WDR_TIMEOUT);
295 *val = buf[0]; 293 *val = buf[0];
296 dbg("mos7840_get_reg_sync offset is %x, return val %x", reg, *val); 294 dev_dbg(&port->dev, "%s offset is %x, return val %x\n", __func__, reg, *val);
297 295
298 kfree(buf); 296 kfree(buf);
299 return ret; 297 return ret;
@@ -316,21 +314,16 @@ static int mos7840_set_uart_reg(struct usb_serial_port *port, __u16 reg,
316 if (port->serial->num_ports == 4) { 314 if (port->serial->num_ports == 4) {
317 val |= (((__u16) port->number - 315 val |= (((__u16) port->number -
318 (__u16) (port->serial->minor)) + 1) << 8; 316 (__u16) (port->serial->minor)) + 1) << 8;
319 dbg("mos7840_set_uart_reg application number is %x", val);
320 } else { 317 } else {
321 if (((__u16) port->number - (__u16) (port->serial->minor)) == 0) { 318 if (((__u16) port->number - (__u16) (port->serial->minor)) == 0) {
322 val |= (((__u16) port->number - 319 val |= (((__u16) port->number -
323 (__u16) (port->serial->minor)) + 1) << 8; 320 (__u16) (port->serial->minor)) + 1) << 8;
324 dbg("mos7840_set_uart_reg application number is %x",
325 val);
326 } else { 321 } else {
327 val |= 322 val |= (((__u16) port->number -
328 (((__u16) port->number -
329 (__u16) (port->serial->minor)) + 2) << 8; 323 (__u16) (port->serial->minor)) + 2) << 8;
330 dbg("mos7840_set_uart_reg application number is %x",
331 val);
332 } 324 }
333 } 325 }
326 dev_dbg(&port->dev, "%s application number is %x\n", __func__, val);
334 return usb_control_msg(dev, usb_sndctrlpipe(dev, 0), MCS_WRREQ, 327 return usb_control_msg(dev, usb_sndctrlpipe(dev, 0), MCS_WRREQ,
335 MCS_WR_RTYPE, val, reg, NULL, 0, 328 MCS_WR_RTYPE, val, reg, NULL, 0,
336 MOS_WDR_TIMEOUT); 329 MOS_WDR_TIMEOUT);
@@ -354,27 +347,21 @@ static int mos7840_get_uart_reg(struct usb_serial_port *port, __u16 reg,
354 if (!buf) 347 if (!buf)
355 return -ENOMEM; 348 return -ENOMEM;
356 349
357 /* dbg("application number is %4x",
358 (((__u16)port->number - (__u16)(port->serial->minor))+1)<<8); */
359 /* Wval is same as application number */ 350 /* Wval is same as application number */
360 if (port->serial->num_ports == 4) { 351 if (port->serial->num_ports == 4) {
361 Wval = 352 Wval =
362 (((__u16) port->number - (__u16) (port->serial->minor)) + 353 (((__u16) port->number - (__u16) (port->serial->minor)) +
363 1) << 8; 354 1) << 8;
364 dbg("mos7840_get_uart_reg application number is %x", Wval);
365 } else { 355 } else {
366 if (((__u16) port->number - (__u16) (port->serial->minor)) == 0) { 356 if (((__u16) port->number - (__u16) (port->serial->minor)) == 0) {
367 Wval = (((__u16) port->number - 357 Wval = (((__u16) port->number -
368 (__u16) (port->serial->minor)) + 1) << 8; 358 (__u16) (port->serial->minor)) + 1) << 8;
369 dbg("mos7840_get_uart_reg application number is %x",
370 Wval);
371 } else { 359 } else {
372 Wval = (((__u16) port->number - 360 Wval = (((__u16) port->number -
373 (__u16) (port->serial->minor)) + 2) << 8; 361 (__u16) (port->serial->minor)) + 2) << 8;
374 dbg("mos7840_get_uart_reg application number is %x",
375 Wval);
376 } 362 }
377 } 363 }
364 dev_dbg(&port->dev, "%s application number is %x\n", __func__, Wval);
378 ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), MCS_RDREQ, 365 ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), MCS_RDREQ,
379 MCS_RD_RTYPE, Wval, reg, buf, VENDOR_READ_LENGTH, 366 MCS_RD_RTYPE, Wval, reg, buf, VENDOR_READ_LENGTH,
380 MOS_WDR_TIMEOUT); 367 MOS_WDR_TIMEOUT);
@@ -384,14 +371,13 @@ static int mos7840_get_uart_reg(struct usb_serial_port *port, __u16 reg,
384 return ret; 371 return ret;
385} 372}
386 373
387static void mos7840_dump_serial_port(struct moschip_port *mos7840_port) 374static void mos7840_dump_serial_port(struct usb_serial_port *port,
375 struct moschip_port *mos7840_port)
388{ 376{
389 377
390 dbg("***************************************"); 378 dev_dbg(&port->dev, "SpRegOffset is %2x\n", mos7840_port->SpRegOffset);
391 dbg("SpRegOffset is %2x", mos7840_port->SpRegOffset); 379 dev_dbg(&port->dev, "ControlRegOffset is %2x\n", mos7840_port->ControlRegOffset);
392 dbg("ControlRegOffset is %2x", mos7840_port->ControlRegOffset); 380 dev_dbg(&port->dev, "DCRRegOffset is %2x\n", mos7840_port->DcrRegOffset);
393 dbg("DCRRegOffset is %2x", mos7840_port->DcrRegOffset);
394 dbg("***************************************");
395 381
396} 382}
397 383
@@ -450,8 +436,6 @@ static void mos7840_handle_new_lsr(struct moschip_port *port, __u8 new_lsr)
450{ 436{
451 struct async_icount *icount; 437 struct async_icount *icount;
452 438
453 dbg("%s - %02x", __func__, new_lsr);
454
455 if (new_lsr & SERIAL_LSR_BI) { 439 if (new_lsr & SERIAL_LSR_BI) {
456 /* 440 /*
457 * Parity and Framing errors only count if they 441 * Parity and Framing errors only count if they
@@ -492,6 +476,7 @@ static void mos7840_control_callback(struct urb *urb)
492{ 476{
493 unsigned char *data; 477 unsigned char *data;
494 struct moschip_port *mos7840_port; 478 struct moschip_port *mos7840_port;
479 struct device *dev = &urb->dev->dev;
495 __u8 regval = 0x0; 480 __u8 regval = 0x0;
496 int result = 0; 481 int result = 0;
497 int status = urb->status; 482 int status = urb->status;
@@ -506,21 +491,19 @@ static void mos7840_control_callback(struct urb *urb)
506 case -ENOENT: 491 case -ENOENT:
507 case -ESHUTDOWN: 492 case -ESHUTDOWN:
508 /* this urb is terminated, clean up */ 493 /* this urb is terminated, clean up */
509 dbg("%s - urb shutting down with status: %d", __func__, 494 dev_dbg(dev, "%s - urb shutting down with status: %d\n", __func__, status);
510 status);
511 return; 495 return;
512 default: 496 default:
513 dbg("%s - nonzero urb status received: %d", __func__, 497 dev_dbg(dev, "%s - nonzero urb status received: %d\n", __func__, status);
514 status);
515 goto exit; 498 goto exit;
516 } 499 }
517 500
518 dbg("%s urb buffer size is %d", __func__, urb->actual_length); 501 dev_dbg(dev, "%s urb buffer size is %d\n", __func__, urb->actual_length);
519 dbg("%s mos7840_port->MsrLsr is %d port %d", __func__, 502 dev_dbg(dev, "%s mos7840_port->MsrLsr is %d port %d\n", __func__,
520 mos7840_port->MsrLsr, mos7840_port->port_num); 503 mos7840_port->MsrLsr, mos7840_port->port_num);
521 data = urb->transfer_buffer; 504 data = urb->transfer_buffer;
522 regval = (__u8) data[0]; 505 regval = (__u8) data[0];
523 dbg("%s data is %x", __func__, regval); 506 dev_dbg(dev, "%s data is %x\n", __func__, regval);
524 if (mos7840_port->MsrLsr == 0) 507 if (mos7840_port->MsrLsr == 0)
525 mos7840_handle_new_msr(mos7840_port, regval); 508 mos7840_handle_new_msr(mos7840_port, regval);
526 else if (mos7840_port->MsrLsr == 1) 509 else if (mos7840_port->MsrLsr == 1)
@@ -532,8 +515,7 @@ exit:
532 result = usb_submit_urb(mos7840_port->int_urb, GFP_ATOMIC); 515 result = usb_submit_urb(mos7840_port->int_urb, GFP_ATOMIC);
533 spin_unlock(&mos7840_port->pool_lock); 516 spin_unlock(&mos7840_port->pool_lock);
534 if (result) { 517 if (result) {
535 dev_err(&urb->dev->dev, 518 dev_err(dev, "%s - Error %d submitting interrupt urb\n",
536 "%s - Error %d submitting interrupt urb\n",
537 __func__, result); 519 __func__, result);
538 } 520 }
539} 521}
@@ -570,12 +552,12 @@ static void mos7840_set_led_callback(struct urb *urb)
570 case -ENOENT: 552 case -ENOENT:
571 case -ESHUTDOWN: 553 case -ESHUTDOWN:
572 /* This urb is terminated, clean up */ 554 /* This urb is terminated, clean up */
573 dbg("%s - urb shutting down with status: %d", __func__, 555 dev_dbg(&urb->dev->dev, "%s - urb shutting down with status: %d",
574 urb->status); 556 __func__, urb->status);
575 break; 557 break;
576 default: 558 default:
577 dbg("%s - nonzero urb status received: %d", __func__, 559 dev_dbg(&urb->dev->dev, "%s - nonzero urb status received: %d",
578 urb->status); 560 __func__, urb->status);
579 } 561 }
580} 562}
581 563
@@ -650,12 +632,12 @@ static void mos7840_interrupt_callback(struct urb *urb)
650 case -ENOENT: 632 case -ENOENT:
651 case -ESHUTDOWN: 633 case -ESHUTDOWN:
652 /* this urb is terminated, clean up */ 634 /* this urb is terminated, clean up */
653 dbg("%s - urb shutting down with status: %d", __func__, 635 dev_dbg(&urb->dev->dev, "%s - urb shutting down with status: %d\n",
654 status); 636 __func__, status);
655 return; 637 return;
656 default: 638 default:
657 dbg("%s - nonzero urb status received: %d", __func__, 639 dev_dbg(&urb->dev->dev, "%s - nonzero urb status received: %d\n",
658 status); 640 __func__, status);
659 goto exit; 641 goto exit;
660 } 642 }
661 643
@@ -672,7 +654,7 @@ static void mos7840_interrupt_callback(struct urb *urb)
672 * Byte 5 FIFO status for both */ 654 * Byte 5 FIFO status for both */
673 655
674 if (length && length > 5) { 656 if (length && length > 5) {
675 dbg("%s", "Wrong data !!!"); 657 dev_dbg(&urb->dev->dev, "%s", "Wrong data !!!\n");
676 return; 658 return;
677 } 659 }
678 660
@@ -689,17 +671,17 @@ static void mos7840_interrupt_callback(struct urb *urb)
689 (__u16) (serial->minor)) + 1) << 8; 671 (__u16) (serial->minor)) + 1) << 8;
690 if (mos7840_port->open) { 672 if (mos7840_port->open) {
691 if (sp[i] & 0x01) { 673 if (sp[i] & 0x01) {
692 dbg("SP%d No Interrupt !!!", i); 674 dev_dbg(&urb->dev->dev, "SP%d No Interrupt !!!\n", i);
693 } else { 675 } else {
694 switch (sp[i] & 0x0f) { 676 switch (sp[i] & 0x0f) {
695 case SERIAL_IIR_RLS: 677 case SERIAL_IIR_RLS:
696 dbg("Serial Port %d: Receiver status error or ", i); 678 dev_dbg(&urb->dev->dev, "Serial Port %d: Receiver status error or \n", i);
697 dbg("address bit detected in 9-bit mode"); 679 dev_dbg(&urb->dev->dev, "address bit detected in 9-bit mode\n");
698 mos7840_port->MsrLsr = 1; 680 mos7840_port->MsrLsr = 1;
699 wreg = LINE_STATUS_REGISTER; 681 wreg = LINE_STATUS_REGISTER;
700 break; 682 break;
701 case SERIAL_IIR_MS: 683 case SERIAL_IIR_MS:
702 dbg("Serial Port %d: Modem status change", i); 684 dev_dbg(&urb->dev->dev, "Serial Port %d: Modem status change\n", i);
703 mos7840_port->MsrLsr = 0; 685 mos7840_port->MsrLsr = 0;
704 wreg = MODEM_STATUS_REGISTER; 686 wreg = MODEM_STATUS_REGISTER;
705 break; 687 break;
@@ -731,11 +713,11 @@ static int mos7840_port_paranoia_check(struct usb_serial_port *port,
731 const char *function) 713 const char *function)
732{ 714{
733 if (!port) { 715 if (!port) {
734 dbg("%s - port == NULL", function); 716 pr_debug("%s - port == NULL\n", function);
735 return -1; 717 return -1;
736 } 718 }
737 if (!port->serial) { 719 if (!port->serial) {
738 dbg("%s - port->serial == NULL", function); 720 pr_debug("%s - port->serial == NULL\n", function);
739 return -1; 721 return -1;
740 } 722 }
741 723
@@ -747,11 +729,11 @@ static int mos7840_serial_paranoia_check(struct usb_serial *serial,
747 const char *function) 729 const char *function)
748{ 730{
749 if (!serial) { 731 if (!serial) {
750 dbg("%s - serial == NULL", function); 732 pr_debug("%s - serial == NULL\n", function);
751 return -1; 733 return -1;
752 } 734 }
753 if (!serial->type) { 735 if (!serial->type) {
754 dbg("%s - serial->type == NULL!", function); 736 pr_debug("%s - serial->type == NULL!\n", function);
755 return -1; 737 return -1;
756 } 738 }
757 739
@@ -790,49 +772,44 @@ static void mos7840_bulk_in_callback(struct urb *urb)
790 int status = urb->status; 772 int status = urb->status;
791 773
792 mos7840_port = urb->context; 774 mos7840_port = urb->context;
793 if (!mos7840_port) { 775 if (!mos7840_port)
794 dbg("%s", "NULL mos7840_port pointer");
795 return; 776 return;
796 }
797 777
798 if (status) { 778 if (status) {
799 dbg("nonzero read bulk status received: %d", status); 779 dev_dbg(&urb->dev->dev, "nonzero read bulk status received: %d\n", status);
800 mos7840_port->read_urb_busy = false; 780 mos7840_port->read_urb_busy = false;
801 return; 781 return;
802 } 782 }
803 783
804 port = (struct usb_serial_port *)mos7840_port->port; 784 port = mos7840_port->port;
805 if (mos7840_port_paranoia_check(port, __func__)) { 785 if (mos7840_port_paranoia_check(port, __func__)) {
806 dbg("%s", "Port Paranoia failed");
807 mos7840_port->read_urb_busy = false; 786 mos7840_port->read_urb_busy = false;
808 return; 787 return;
809 } 788 }
810 789
811 serial = mos7840_get_usb_serial(port, __func__); 790 serial = mos7840_get_usb_serial(port, __func__);
812 if (!serial) { 791 if (!serial) {
813 dbg("%s", "Bad serial pointer");
814 mos7840_port->read_urb_busy = false; 792 mos7840_port->read_urb_busy = false;
815 return; 793 return;
816 } 794 }
817 795
818 data = urb->transfer_buffer; 796 data = urb->transfer_buffer;
797 usb_serial_debug_data(&port->dev, __func__, urb->actual_length, data);
819 798
820 if (urb->actual_length) { 799 if (urb->actual_length) {
821 tty = tty_port_tty_get(&mos7840_port->port->port); 800 tty = tty_port_tty_get(&mos7840_port->port->port);
822 if (tty) { 801 if (tty) {
823 tty_insert_flip_string(tty, data, urb->actual_length); 802 tty_insert_flip_string(tty, data, urb->actual_length);
824 dbg(" %s ", data);
825 tty_flip_buffer_push(tty); 803 tty_flip_buffer_push(tty);
826 tty_kref_put(tty); 804 tty_kref_put(tty);
827 } 805 }
828 mos7840_port->icount.rx += urb->actual_length; 806 mos7840_port->icount.rx += urb->actual_length;
829 smp_wmb(); 807 smp_wmb();
830 dbg("mos7840_port->icount.rx is %d:", 808 dev_dbg(&port->dev, "mos7840_port->icount.rx is %d:\n", mos7840_port->icount.rx);
831 mos7840_port->icount.rx);
832 } 809 }
833 810
834 if (!mos7840_port->read_urb) { 811 if (!mos7840_port->read_urb) {
835 dbg("%s", "URB KILLED !!!"); 812 dev_dbg(&port->dev, "%s", "URB KILLED !!!\n");
836 mos7840_port->read_urb_busy = false; 813 mos7840_port->read_urb_busy = false;
837 return; 814 return;
838 } 815 }
@@ -850,7 +827,7 @@ static void mos7840_bulk_in_callback(struct urb *urb)
850 retval = usb_submit_urb(mos7840_port->read_urb, GFP_ATOMIC); 827 retval = usb_submit_urb(mos7840_port->read_urb, GFP_ATOMIC);
851 828
852 if (retval) { 829 if (retval) {
853 dbg("usb_submit_urb(read bulk) failed, retval = %d", retval); 830 dev_dbg(&port->dev, "usb_submit_urb(read bulk) failed, retval = %d\n", retval);
854 mos7840_port->read_urb_busy = false; 831 mos7840_port->read_urb_busy = false;
855 } 832 }
856} 833}
@@ -864,11 +841,13 @@ static void mos7840_bulk_in_callback(struct urb *urb)
864static void mos7840_bulk_out_data_callback(struct urb *urb) 841static void mos7840_bulk_out_data_callback(struct urb *urb)
865{ 842{
866 struct moschip_port *mos7840_port; 843 struct moschip_port *mos7840_port;
844 struct usb_serial_port *port;
867 struct tty_struct *tty; 845 struct tty_struct *tty;
868 int status = urb->status; 846 int status = urb->status;
869 int i; 847 int i;
870 848
871 mos7840_port = urb->context; 849 mos7840_port = urb->context;
850 port = mos7840_port->port;
872 spin_lock(&mos7840_port->pool_lock); 851 spin_lock(&mos7840_port->pool_lock);
873 for (i = 0; i < NUM_URBS; i++) { 852 for (i = 0; i < NUM_URBS; i++) {
874 if (urb == mos7840_port->write_urb_pool[i]) { 853 if (urb == mos7840_port->write_urb_pool[i]) {
@@ -879,16 +858,14 @@ static void mos7840_bulk_out_data_callback(struct urb *urb)
879 spin_unlock(&mos7840_port->pool_lock); 858 spin_unlock(&mos7840_port->pool_lock);
880 859
881 if (status) { 860 if (status) {
882 dbg("nonzero write bulk status received:%d", status); 861 dev_dbg(&port->dev, "nonzero write bulk status received:%d\n", status);
883 return; 862 return;
884 } 863 }
885 864
886 if (mos7840_port_paranoia_check(mos7840_port->port, __func__)) { 865 if (mos7840_port_paranoia_check(port, __func__))
887 dbg("%s", "Port Paranoia failed");
888 return; 866 return;
889 }
890 867
891 tty = tty_port_tty_get(&mos7840_port->port->port); 868 tty = tty_port_tty_get(&port->port);
892 if (tty && mos7840_port->open) 869 if (tty && mos7840_port->open)
893 tty_wakeup(tty); 870 tty_wakeup(tty);
894 tty_kref_put(tty); 871 tty_kref_put(tty);
@@ -929,17 +906,13 @@ static int mos7840_open(struct tty_struct *tty, struct usb_serial_port *port)
929 struct moschip_port *mos7840_port; 906 struct moschip_port *mos7840_port;
930 struct moschip_port *port0; 907 struct moschip_port *port0;
931 908
932 if (mos7840_port_paranoia_check(port, __func__)) { 909 if (mos7840_port_paranoia_check(port, __func__))
933 dbg("%s", "Port Paranoia failed");
934 return -ENODEV; 910 return -ENODEV;
935 }
936 911
937 serial = port->serial; 912 serial = port->serial;
938 913
939 if (mos7840_serial_paranoia_check(serial, __func__)) { 914 if (mos7840_serial_paranoia_check(serial, __func__))
940 dbg("%s", "Serial Paranoia failed");
941 return -ENODEV; 915 return -ENODEV;
942 }
943 916
944 mos7840_port = mos7840_get_port_private(port); 917 mos7840_port = mos7840_get_port_private(port);
945 port0 = mos7840_get_port_private(serial->port[0]); 918 port0 = mos7840_get_port_private(serial->port[0]);
@@ -990,20 +963,20 @@ static int mos7840_open(struct tty_struct *tty, struct usb_serial_port *port)
990 Data = 0x0; 963 Data = 0x0;
991 status = mos7840_get_reg_sync(port, mos7840_port->SpRegOffset, &Data); 964 status = mos7840_get_reg_sync(port, mos7840_port->SpRegOffset, &Data);
992 if (status < 0) { 965 if (status < 0) {
993 dbg("Reading Spreg failed"); 966 dev_dbg(&port->dev, "Reading Spreg failed\n");
994 return -1; 967 return -1;
995 } 968 }
996 Data |= 0x80; 969 Data |= 0x80;
997 status = mos7840_set_reg_sync(port, mos7840_port->SpRegOffset, Data); 970 status = mos7840_set_reg_sync(port, mos7840_port->SpRegOffset, Data);
998 if (status < 0) { 971 if (status < 0) {
999 dbg("writing Spreg failed"); 972 dev_dbg(&port->dev, "writing Spreg failed\n");
1000 return -1; 973 return -1;
1001 } 974 }
1002 975
1003 Data &= ~0x80; 976 Data &= ~0x80;
1004 status = mos7840_set_reg_sync(port, mos7840_port->SpRegOffset, Data); 977 status = mos7840_set_reg_sync(port, mos7840_port->SpRegOffset, Data);
1005 if (status < 0) { 978 if (status < 0) {
1006 dbg("writing Spreg failed"); 979 dev_dbg(&port->dev, "writing Spreg failed\n");
1007 return -1; 980 return -1;
1008 } 981 }
1009 /* End of block to be checked */ 982 /* End of block to be checked */
@@ -1012,7 +985,7 @@ static int mos7840_open(struct tty_struct *tty, struct usb_serial_port *port)
1012 status = mos7840_get_reg_sync(port, mos7840_port->ControlRegOffset, 985 status = mos7840_get_reg_sync(port, mos7840_port->ControlRegOffset,
1013 &Data); 986 &Data);
1014 if (status < 0) { 987 if (status < 0) {
1015 dbg("Reading Controlreg failed"); 988 dev_dbg(&port->dev, "Reading Controlreg failed\n");
1016 return -1; 989 return -1;
1017 } 990 }
1018 Data |= 0x08; /* Driver done bit */ 991 Data |= 0x08; /* Driver done bit */
@@ -1020,7 +993,7 @@ static int mos7840_open(struct tty_struct *tty, struct usb_serial_port *port)
1020 status = mos7840_set_reg_sync(port, 993 status = mos7840_set_reg_sync(port,
1021 mos7840_port->ControlRegOffset, Data); 994 mos7840_port->ControlRegOffset, Data);
1022 if (status < 0) { 995 if (status < 0) {
1023 dbg("writing Controlreg failed"); 996 dev_dbg(&port->dev, "writing Controlreg failed\n");
1024 return -1; 997 return -1;
1025 } 998 }
1026 /* do register settings here */ 999 /* do register settings here */
@@ -1031,21 +1004,21 @@ static int mos7840_open(struct tty_struct *tty, struct usb_serial_port *port)
1031 Data = 0x00; 1004 Data = 0x00;
1032 status = mos7840_set_uart_reg(port, INTERRUPT_ENABLE_REGISTER, Data); 1005 status = mos7840_set_uart_reg(port, INTERRUPT_ENABLE_REGISTER, Data);
1033 if (status < 0) { 1006 if (status < 0) {
1034 dbg("disabling interrupts failed"); 1007 dev_dbg(&port->dev, "disabling interrupts failed\n");
1035 return -1; 1008 return -1;
1036 } 1009 }
1037 /* Set FIFO_CONTROL_REGISTER to the default value */ 1010 /* Set FIFO_CONTROL_REGISTER to the default value */
1038 Data = 0x00; 1011 Data = 0x00;
1039 status = mos7840_set_uart_reg(port, FIFO_CONTROL_REGISTER, Data); 1012 status = mos7840_set_uart_reg(port, FIFO_CONTROL_REGISTER, Data);
1040 if (status < 0) { 1013 if (status < 0) {
1041 dbg("Writing FIFO_CONTROL_REGISTER failed"); 1014 dev_dbg(&port->dev, "Writing FIFO_CONTROL_REGISTER failed\n");
1042 return -1; 1015 return -1;
1043 } 1016 }
1044 1017
1045 Data = 0xcf; 1018 Data = 0xcf;
1046 status = mos7840_set_uart_reg(port, FIFO_CONTROL_REGISTER, Data); 1019 status = mos7840_set_uart_reg(port, FIFO_CONTROL_REGISTER, Data);
1047 if (status < 0) { 1020 if (status < 0) {
1048 dbg("Writing FIFO_CONTROL_REGISTER failed"); 1021 dev_dbg(&port->dev, "Writing FIFO_CONTROL_REGISTER failed\n");
1049 return -1; 1022 return -1;
1050 } 1023 }
1051 1024
@@ -1142,12 +1115,12 @@ static int mos7840_open(struct tty_struct *tty, struct usb_serial_port *port)
1142 * (can't set it up in mos7840_startup as the * 1115 * (can't set it up in mos7840_startup as the *
1143 * structures were not set up at that time.) */ 1116 * structures were not set up at that time.) */
1144 1117
1145 dbg("port number is %d", port->number); 1118 dev_dbg(&port->dev, "port number is %d\n", port->number);
1146 dbg("serial number is %d", port->serial->minor); 1119 dev_dbg(&port->dev, "serial number is %d\n", port->serial->minor);
1147 dbg("Bulkin endpoint is %d", port->bulk_in_endpointAddress); 1120 dev_dbg(&port->dev, "Bulkin endpoint is %d\n", port->bulk_in_endpointAddress);
1148 dbg("BulkOut endpoint is %d", port->bulk_out_endpointAddress); 1121 dev_dbg(&port->dev, "BulkOut endpoint is %d\n", port->bulk_out_endpointAddress);
1149 dbg("Interrupt endpoint is %d", port->interrupt_in_endpointAddress); 1122 dev_dbg(&port->dev, "Interrupt endpoint is %d\n", port->interrupt_in_endpointAddress);
1150 dbg("port's number in the device is %d", mos7840_port->port_num); 1123 dev_dbg(&port->dev, "port's number in the device is %d\n", mos7840_port->port_num);
1151 mos7840_port->read_urb = port->read_urb; 1124 mos7840_port->read_urb = port->read_urb;
1152 1125
1153 /* set up our bulk in urb */ 1126 /* set up our bulk in urb */
@@ -1171,8 +1144,7 @@ static int mos7840_open(struct tty_struct *tty, struct usb_serial_port *port)
1171 mos7840_bulk_in_callback, mos7840_port); 1144 mos7840_bulk_in_callback, mos7840_port);
1172 } 1145 }
1173 1146
1174 dbg("mos7840_open: bulkin endpoint is %d", 1147 dev_dbg(&port->dev, "%s: bulkin endpoint is %d\n", __func__, port->bulk_in_endpointAddress);
1175 port->bulk_in_endpointAddress);
1176 mos7840_port->read_urb_busy = true; 1148 mos7840_port->read_urb_busy = true;
1177 response = usb_submit_urb(mos7840_port->read_urb, GFP_KERNEL); 1149 response = usb_submit_urb(mos7840_port->read_urb, GFP_KERNEL);
1178 if (response) { 1150 if (response) {
@@ -1197,9 +1169,6 @@ static int mos7840_open(struct tty_struct *tty, struct usb_serial_port *port)
1197 mos7840_port->icount.tx = 0; 1169 mos7840_port->icount.tx = 0;
1198 mos7840_port->icount.rx = 0; 1170 mos7840_port->icount.rx = 0;
1199 1171
1200 dbg("usb_serial serial:%p mos7840_port:%p\n usb_serial_port port:%p",
1201 serial, mos7840_port, port);
1202
1203 return 0; 1172 return 0;
1204} 1173}
1205 1174
@@ -1221,10 +1190,8 @@ static int mos7840_chars_in_buffer(struct tty_struct *tty)
1221 unsigned long flags; 1190 unsigned long flags;
1222 struct moschip_port *mos7840_port; 1191 struct moschip_port *mos7840_port;
1223 1192
1224 if (mos7840_port_paranoia_check(port, __func__)) { 1193 if (mos7840_port_paranoia_check(port, __func__))
1225 dbg("%s", "Invalid port");
1226 return 0; 1194 return 0;
1227 }
1228 1195
1229 mos7840_port = mos7840_get_port_private(port); 1196 mos7840_port = mos7840_get_port_private(port);
1230 if (mos7840_port == NULL) 1197 if (mos7840_port == NULL)
@@ -1238,7 +1205,7 @@ static int mos7840_chars_in_buffer(struct tty_struct *tty)
1238 } 1205 }
1239 } 1206 }
1240 spin_unlock_irqrestore(&mos7840_port->pool_lock, flags); 1207 spin_unlock_irqrestore(&mos7840_port->pool_lock, flags);
1241 dbg("%s - returns %d", __func__, chars); 1208 dev_dbg(&port->dev, "%s - returns %d\n", __func__, chars);
1242 return chars; 1209 return chars;
1243 1210
1244} 1211}
@@ -1256,16 +1223,12 @@ static void mos7840_close(struct usb_serial_port *port)
1256 int j; 1223 int j;
1257 __u16 Data; 1224 __u16 Data;
1258 1225
1259 if (mos7840_port_paranoia_check(port, __func__)) { 1226 if (mos7840_port_paranoia_check(port, __func__))
1260 dbg("%s", "Port Paranoia failed");
1261 return; 1227 return;
1262 }
1263 1228
1264 serial = mos7840_get_usb_serial(port, __func__); 1229 serial = mos7840_get_usb_serial(port, __func__);
1265 if (!serial) { 1230 if (!serial)
1266 dbg("%s", "Serial Paranoia failed");
1267 return; 1231 return;
1268 }
1269 1232
1270 mos7840_port = mos7840_get_port_private(port); 1233 mos7840_port = mos7840_get_port_private(port);
1271 port0 = mos7840_get_port_private(serial->port[0]); 1234 port0 = mos7840_get_port_private(serial->port[0]);
@@ -1291,27 +1254,26 @@ static void mos7840_close(struct usb_serial_port *port)
1291 * and interrupt read if they exists */ 1254 * and interrupt read if they exists */
1292 if (serial->dev) { 1255 if (serial->dev) {
1293 if (mos7840_port->write_urb) { 1256 if (mos7840_port->write_urb) {
1294 dbg("%s", "Shutdown bulk write"); 1257 dev_dbg(&port->dev, "%s", "Shutdown bulk write\n");
1295 usb_kill_urb(mos7840_port->write_urb); 1258 usb_kill_urb(mos7840_port->write_urb);
1296 } 1259 }
1297 if (mos7840_port->read_urb) { 1260 if (mos7840_port->read_urb) {
1298 dbg("%s", "Shutdown bulk read"); 1261 dev_dbg(&port->dev, "%s", "Shutdown bulk read\n");
1299 usb_kill_urb(mos7840_port->read_urb); 1262 usb_kill_urb(mos7840_port->read_urb);
1300 mos7840_port->read_urb_busy = false; 1263 mos7840_port->read_urb_busy = false;
1301 } 1264 }
1302 if ((&mos7840_port->control_urb)) { 1265 if ((&mos7840_port->control_urb)) {
1303 dbg("%s", "Shutdown control read"); 1266 dev_dbg(&port->dev, "%s", "Shutdown control read\n");
1304 /*/ usb_kill_urb (mos7840_port->control_urb); */ 1267 /*/ usb_kill_urb (mos7840_port->control_urb); */
1305 } 1268 }
1306 } 1269 }
1307/* if(mos7840_port->ctrl_buf != NULL) */ 1270/* if(mos7840_port->ctrl_buf != NULL) */
1308/* kfree(mos7840_port->ctrl_buf); */ 1271/* kfree(mos7840_port->ctrl_buf); */
1309 port0->open_ports--; 1272 port0->open_ports--;
1310 dbg("mos7840_num_open_ports in close%d:in port%d", 1273 dev_dbg(&port->dev, "%s in close%d:in port%d\n", __func__, port0->open_ports, port->number);
1311 port0->open_ports, port->number);
1312 if (port0->open_ports == 0) { 1274 if (port0->open_ports == 0) {
1313 if (serial->port[0]->interrupt_in_urb) { 1275 if (serial->port[0]->interrupt_in_urb) {
1314 dbg("%s", "Shutdown interrupt_in_urb"); 1276 dev_dbg(&port->dev, "Shutdown interrupt_in_urb\n");
1315 usb_kill_urb(serial->port[0]->interrupt_in_urb); 1277 usb_kill_urb(serial->port[0]->interrupt_in_urb);
1316 } 1278 }
1317 } 1279 }
@@ -1363,7 +1325,7 @@ static void mos7840_block_until_chase_response(struct tty_struct *tty,
1363 /* No activity.. count down section */ 1325 /* No activity.. count down section */
1364 wait--; 1326 wait--;
1365 if (wait == 0) { 1327 if (wait == 0) {
1366 dbg("%s - TIMEOUT", __func__); 1328 dev_dbg(&mos7840_port->port->dev, "%s - TIMEOUT\n", __func__);
1367 return; 1329 return;
1368 } else { 1330 } else {
1369 /* Reset timeout value back to seconds */ 1331 /* Reset timeout value back to seconds */
@@ -1384,16 +1346,12 @@ static void mos7840_break(struct tty_struct *tty, int break_state)
1384 struct usb_serial *serial; 1346 struct usb_serial *serial;
1385 struct moschip_port *mos7840_port; 1347 struct moschip_port *mos7840_port;
1386 1348
1387 if (mos7840_port_paranoia_check(port, __func__)) { 1349 if (mos7840_port_paranoia_check(port, __func__))
1388 dbg("%s", "Port Paranoia failed");
1389 return; 1350 return;
1390 }
1391 1351
1392 serial = mos7840_get_usb_serial(port, __func__); 1352 serial = mos7840_get_usb_serial(port, __func__);
1393 if (!serial) { 1353 if (!serial)
1394 dbg("%s", "Serial Paranoia failed");
1395 return; 1354 return;
1396 }
1397 1355
1398 mos7840_port = mos7840_get_port_private(port); 1356 mos7840_port = mos7840_get_port_private(port);
1399 1357
@@ -1411,8 +1369,7 @@ static void mos7840_break(struct tty_struct *tty, int break_state)
1411 1369
1412 /* FIXME: no locking on shadowLCR anywhere in driver */ 1370 /* FIXME: no locking on shadowLCR anywhere in driver */
1413 mos7840_port->shadowLCR = data; 1371 mos7840_port->shadowLCR = data;
1414 dbg("mcs7840_break mos7840_port->shadowLCR is %x", 1372 dev_dbg(&port->dev, "%s mos7840_port->shadowLCR is %x\n", __func__, mos7840_port->shadowLCR);
1415 mos7840_port->shadowLCR);
1416 mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER, 1373 mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER,
1417 mos7840_port->shadowLCR); 1374 mos7840_port->shadowLCR);
1418} 1375}
@@ -1433,17 +1390,12 @@ static int mos7840_write_room(struct tty_struct *tty)
1433 unsigned long flags; 1390 unsigned long flags;
1434 struct moschip_port *mos7840_port; 1391 struct moschip_port *mos7840_port;
1435 1392
1436 if (mos7840_port_paranoia_check(port, __func__)) { 1393 if (mos7840_port_paranoia_check(port, __func__))
1437 dbg("%s", "Invalid port");
1438 dbg("%s", " mos7840_write_room:leaving ...........");
1439 return -1; 1394 return -1;
1440 }
1441 1395
1442 mos7840_port = mos7840_get_port_private(port); 1396 mos7840_port = mos7840_get_port_private(port);
1443 if (mos7840_port == NULL) { 1397 if (mos7840_port == NULL)
1444 dbg("%s", "mos7840_break:leaving ...........");
1445 return -1; 1398 return -1;
1446 }
1447 1399
1448 spin_lock_irqsave(&mos7840_port->pool_lock, flags); 1400 spin_lock_irqsave(&mos7840_port->pool_lock, flags);
1449 for (i = 0; i < NUM_URBS; ++i) { 1401 for (i = 0; i < NUM_URBS; ++i) {
@@ -1453,7 +1405,7 @@ static int mos7840_write_room(struct tty_struct *tty)
1453 spin_unlock_irqrestore(&mos7840_port->pool_lock, flags); 1405 spin_unlock_irqrestore(&mos7840_port->pool_lock, flags);
1454 1406
1455 room = (room == 0) ? 0 : room - URB_TRANSFER_BUFFER_SIZE + 1; 1407 room = (room == 0) ? 0 : room - URB_TRANSFER_BUFFER_SIZE + 1;
1456 dbg("%s - returns %d", __func__, room); 1408 dev_dbg(&mos7840_port->port->dev, "%s - returns %d\n", __func__, room);
1457 return room; 1409 return room;
1458 1410
1459} 1411}
@@ -1486,9 +1438,8 @@ static int mos7840_write(struct tty_struct *tty, struct usb_serial_port *port,
1486 Data = 0x00; 1438 Data = 0x00;
1487 status = mos7840_get_uart_reg(port, LINE_CONTROL_REGISTER, &Data); 1439 status = mos7840_get_uart_reg(port, LINE_CONTROL_REGISTER, &Data);
1488 mos7840_port->shadowLCR = Data; 1440 mos7840_port->shadowLCR = Data;
1489 dbg("mos7840_write: LINE_CONTROL_REGISTER is %x", Data); 1441 dev_dbg(&port->dev, "%s: LINE_CONTROL_REGISTER is %x\n", __func__, Data);
1490 dbg("mos7840_write: mos7840_port->shadowLCR is %x", 1442 dev_dbg(&port->dev, "%s: mos7840_port->shadowLCR is %x\n", __func__, mos7840_port->shadowLCR);
1491 mos7840_port->shadowLCR);
1492 1443
1493 /* Data = 0x03; */ 1444 /* Data = 0x03; */
1494 /* status = mos7840_set_uart_reg(port,LINE_CONTROL_REGISTER,Data); */ 1445 /* status = mos7840_set_uart_reg(port,LINE_CONTROL_REGISTER,Data); */
@@ -1501,34 +1452,27 @@ static int mos7840_write(struct tty_struct *tty, struct usb_serial_port *port,
1501 /* status = mos7840_set_uart_reg(port,DIVISOR_LATCH_LSB,Data); */ 1452 /* status = mos7840_set_uart_reg(port,DIVISOR_LATCH_LSB,Data); */
1502 Data = 0x00; 1453 Data = 0x00;
1503 status = mos7840_get_uart_reg(port, DIVISOR_LATCH_LSB, &Data); 1454 status = mos7840_get_uart_reg(port, DIVISOR_LATCH_LSB, &Data);
1504 dbg("mos7840_write:DLL value is %x", Data); 1455 dev_dbg(&port->dev, "%s: DLL value is %x\n", __func__, Data);
1505 1456
1506 Data = 0x0; 1457 Data = 0x0;
1507 status = mos7840_get_uart_reg(port, DIVISOR_LATCH_MSB, &Data); 1458 status = mos7840_get_uart_reg(port, DIVISOR_LATCH_MSB, &Data);
1508 dbg("mos7840_write:DLM value is %x", Data); 1459 dev_dbg(&port->dev, "%s: DLM value is %x\n", __func__, Data);
1509 1460
1510 Data = Data & ~SERIAL_LCR_DLAB; 1461 Data = Data & ~SERIAL_LCR_DLAB;
1511 dbg("mos7840_write: mos7840_port->shadowLCR is %x", 1462 dev_dbg(&port->dev, "%s: mos7840_port->shadowLCR is %x\n", __func__, mos7840_port->shadowLCR);
1512 mos7840_port->shadowLCR);
1513 status = mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER, Data); 1463 status = mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER, Data);
1514#endif 1464#endif
1515 1465
1516 if (mos7840_port_paranoia_check(port, __func__)) { 1466 if (mos7840_port_paranoia_check(port, __func__))
1517 dbg("%s", "Port Paranoia failed");
1518 return -1; 1467 return -1;
1519 }
1520 1468
1521 serial = port->serial; 1469 serial = port->serial;
1522 if (mos7840_serial_paranoia_check(serial, __func__)) { 1470 if (mos7840_serial_paranoia_check(serial, __func__))
1523 dbg("%s", "Serial Paranoia failed");
1524 return -1; 1471 return -1;
1525 }
1526 1472
1527 mos7840_port = mos7840_get_port_private(port); 1473 mos7840_port = mos7840_get_port_private(port);
1528 if (mos7840_port == NULL) { 1474 if (mos7840_port == NULL)
1529 dbg("%s", "mos7840_port is NULL");
1530 return -1; 1475 return -1;
1531 }
1532 1476
1533 /* try to find a free urb in the list */ 1477 /* try to find a free urb in the list */
1534 urb = NULL; 1478 urb = NULL;
@@ -1538,14 +1482,14 @@ static int mos7840_write(struct tty_struct *tty, struct usb_serial_port *port,
1538 if (!mos7840_port->busy[i]) { 1482 if (!mos7840_port->busy[i]) {
1539 mos7840_port->busy[i] = 1; 1483 mos7840_port->busy[i] = 1;
1540 urb = mos7840_port->write_urb_pool[i]; 1484 urb = mos7840_port->write_urb_pool[i];
1541 dbg("URB:%d", i); 1485 dev_dbg(&port->dev, "URB:%d\n", i);
1542 break; 1486 break;
1543 } 1487 }
1544 } 1488 }
1545 spin_unlock_irqrestore(&mos7840_port->pool_lock, flags); 1489 spin_unlock_irqrestore(&mos7840_port->pool_lock, flags);
1546 1490
1547 if (urb == NULL) { 1491 if (urb == NULL) {
1548 dbg("%s - no more free urbs", __func__); 1492 dev_dbg(&port->dev, "%s - no more free urbs\n", __func__);
1549 goto exit; 1493 goto exit;
1550 } 1494 }
1551 1495
@@ -1585,7 +1529,7 @@ static int mos7840_write(struct tty_struct *tty, struct usb_serial_port *port,
1585 } 1529 }
1586 1530
1587 data1 = urb->transfer_buffer; 1531 data1 = urb->transfer_buffer;
1588 dbg("bulkout endpoint is %d", port->bulk_out_endpointAddress); 1532 dev_dbg(&port->dev, "bulkout endpoint is %d\n", port->bulk_out_endpointAddress);
1589 1533
1590 /* Turn on LED */ 1534 /* Turn on LED */
1591 if (mos7840_port->has_led && !mos7840_port->led_flag) { 1535 if (mos7840_port->has_led && !mos7840_port->led_flag) {
@@ -1608,7 +1552,7 @@ static int mos7840_write(struct tty_struct *tty, struct usb_serial_port *port,
1608 bytes_sent = transfer_size; 1552 bytes_sent = transfer_size;
1609 mos7840_port->icount.tx += transfer_size; 1553 mos7840_port->icount.tx += transfer_size;
1610 smp_wmb(); 1554 smp_wmb();
1611 dbg("mos7840_port->icount.tx is %d:", mos7840_port->icount.tx); 1555 dev_dbg(&port->dev, "mos7840_port->icount.tx is %d:\n", mos7840_port->icount.tx);
1612exit: 1556exit:
1613 return bytes_sent; 1557 return bytes_sent;
1614 1558
@@ -1626,12 +1570,8 @@ static void mos7840_throttle(struct tty_struct *tty)
1626 struct moschip_port *mos7840_port; 1570 struct moschip_port *mos7840_port;
1627 int status; 1571 int status;
1628 1572
1629 if (mos7840_port_paranoia_check(port, __func__)) { 1573 if (mos7840_port_paranoia_check(port, __func__))
1630 dbg("%s", "Invalid port");
1631 return; 1574 return;
1632 }
1633
1634 dbg("- port %d", port->number);
1635 1575
1636 mos7840_port = mos7840_get_port_private(port); 1576 mos7840_port = mos7840_get_port_private(port);
1637 1577
@@ -1639,7 +1579,7 @@ static void mos7840_throttle(struct tty_struct *tty)
1639 return; 1579 return;
1640 1580
1641 if (!mos7840_port->open) { 1581 if (!mos7840_port->open) {
1642 dbg("%s", "port not opened"); 1582 dev_dbg(&port->dev, "%s", "port not opened\n");
1643 return; 1583 return;
1644 } 1584 }
1645 1585
@@ -1672,16 +1612,14 @@ static void mos7840_unthrottle(struct tty_struct *tty)
1672 int status; 1612 int status;
1673 struct moschip_port *mos7840_port = mos7840_get_port_private(port); 1613 struct moschip_port *mos7840_port = mos7840_get_port_private(port);
1674 1614
1675 if (mos7840_port_paranoia_check(port, __func__)) { 1615 if (mos7840_port_paranoia_check(port, __func__))
1676 dbg("%s", "Invalid port");
1677 return; 1616 return;
1678 }
1679 1617
1680 if (mos7840_port == NULL) 1618 if (mos7840_port == NULL)
1681 return; 1619 return;
1682 1620
1683 if (!mos7840_port->open) { 1621 if (!mos7840_port->open) {
1684 dbg("%s - port not opened", __func__); 1622 dev_dbg(&port->dev, "%s - port not opened\n", __func__);
1685 return; 1623 return;
1686 } 1624 }
1687 1625
@@ -1726,7 +1664,7 @@ static int mos7840_tiocmget(struct tty_struct *tty)
1726 | ((msr & MOS7840_MSR_RI) ? TIOCM_RI : 0) 1664 | ((msr & MOS7840_MSR_RI) ? TIOCM_RI : 0)
1727 | ((msr & MOS7840_MSR_DSR) ? TIOCM_DSR : 0); 1665 | ((msr & MOS7840_MSR_DSR) ? TIOCM_DSR : 0);
1728 1666
1729 dbg("%s - 0x%04X", __func__, result); 1667 dev_dbg(&port->dev, "%s - 0x%04X\n", __func__, result);
1730 1668
1731 return result; 1669 return result;
1732} 1670}
@@ -1764,7 +1702,7 @@ static int mos7840_tiocmset(struct tty_struct *tty,
1764 1702
1765 status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, mcr); 1703 status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, mcr);
1766 if (status < 0) { 1704 if (status < 0) {
1767 dbg("setting MODEM_CONTROL_REGISTER Failed"); 1705 dev_dbg(&port->dev, "setting MODEM_CONTROL_REGISTER Failed\n");
1768 return status; 1706 return status;
1769 } 1707 }
1770 1708
@@ -1776,10 +1714,11 @@ static int mos7840_tiocmset(struct tty_struct *tty,
1776 * this function calculates the proper baud rate divisor for the specified 1714 * this function calculates the proper baud rate divisor for the specified
1777 * baud rate. 1715 * baud rate.
1778 *****************************************************************************/ 1716 *****************************************************************************/
1779static int mos7840_calc_baud_rate_divisor(int baudRate, int *divisor, 1717static int mos7840_calc_baud_rate_divisor(struct usb_serial_port *port,
1718 int baudRate, int *divisor,
1780 __u16 *clk_sel_val) 1719 __u16 *clk_sel_val)
1781{ 1720{
1782 dbg("%s - %d", __func__, baudRate); 1721 dev_dbg(&port->dev, "%s - %d\n", __func__, baudRate);
1783 1722
1784 if (baudRate <= 115200) { 1723 if (baudRate <= 115200) {
1785 *divisor = 115200 / baudRate; 1724 *divisor = 115200 / baudRate;
@@ -1832,11 +1771,11 @@ static int mos7840_calc_baud_rate_divisor(int baudRate, int *divisor,
1832 custom++; 1771 custom++;
1833 *divisor = custom; 1772 *divisor = custom;
1834 1773
1835 dbg(" Baud %d = %d", baudrate, custom); 1774 dev_dbg(&port->dev, " Baud %d = %d\n", baudrate, custom);
1836 return 0; 1775 return 0;
1837 } 1776 }
1838 1777
1839 dbg("%s", " Baud calculation Failed..."); 1778 dev_dbg(&port->dev, "%s", " Baud calculation Failed...\n");
1840 return -1; 1779 return -1;
1841#endif 1780#endif
1842} 1781}
@@ -1860,21 +1799,17 @@ static int mos7840_send_cmd_write_baud_rate(struct moschip_port *mos7840_port,
1860 if (mos7840_port == NULL) 1799 if (mos7840_port == NULL)
1861 return -1; 1800 return -1;
1862 1801
1863 port = (struct usb_serial_port *)mos7840_port->port; 1802 port = mos7840_port->port;
1864 if (mos7840_port_paranoia_check(port, __func__)) { 1803 if (mos7840_port_paranoia_check(port, __func__))
1865 dbg("%s", "Invalid port");
1866 return -1; 1804 return -1;
1867 }
1868 1805
1869 if (mos7840_serial_paranoia_check(port->serial, __func__)) { 1806 if (mos7840_serial_paranoia_check(port->serial, __func__))
1870 dbg("%s", "Invalid Serial");
1871 return -1; 1807 return -1;
1872 }
1873 1808
1874 number = mos7840_port->port->number - mos7840_port->port->serial->minor; 1809 number = mos7840_port->port->number - mos7840_port->port->serial->minor;
1875 1810
1876 dbg("%s - port = %d, baud = %d", __func__, 1811 dev_dbg(&port->dev, "%s - port = %d, baud = %d\n", __func__,
1877 mos7840_port->port->number, baudRate); 1812 mos7840_port->port->number, baudRate);
1878 /* reset clk_uart_sel in spregOffset */ 1813 /* reset clk_uart_sel in spregOffset */
1879 if (baudRate > 115200) { 1814 if (baudRate > 115200) {
1880#ifdef HW_flow_control 1815#ifdef HW_flow_control
@@ -1885,7 +1820,7 @@ static int mos7840_send_cmd_write_baud_rate(struct moschip_port *mos7840_port,
1885 status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, 1820 status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER,
1886 Data); 1821 Data);
1887 if (status < 0) { 1822 if (status < 0) {
1888 dbg("Writing spreg failed in set_serial_baud"); 1823 dev_dbg(&port->dev, "Writing spreg failed in set_serial_baud\n");
1889 return -1; 1824 return -1;
1890 } 1825 }
1891#endif 1826#endif
@@ -1898,7 +1833,7 @@ static int mos7840_send_cmd_write_baud_rate(struct moschip_port *mos7840_port,
1898 status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, 1833 status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER,
1899 Data); 1834 Data);
1900 if (status < 0) { 1835 if (status < 0) {
1901 dbg("Writing spreg failed in set_serial_baud"); 1836 dev_dbg(&port->dev, "Writing spreg failed in set_serial_baud\n");
1902 return -1; 1837 return -1;
1903 } 1838 }
1904#endif 1839#endif
@@ -1908,19 +1843,19 @@ static int mos7840_send_cmd_write_baud_rate(struct moschip_port *mos7840_port,
1908 if (1) { /* baudRate <= 115200) */ 1843 if (1) { /* baudRate <= 115200) */
1909 clk_sel_val = 0x0; 1844 clk_sel_val = 0x0;
1910 Data = 0x0; 1845 Data = 0x0;
1911 status = mos7840_calc_baud_rate_divisor(baudRate, &divisor, 1846 status = mos7840_calc_baud_rate_divisor(port, baudRate, &divisor,
1912 &clk_sel_val); 1847 &clk_sel_val);
1913 status = mos7840_get_reg_sync(port, mos7840_port->SpRegOffset, 1848 status = mos7840_get_reg_sync(port, mos7840_port->SpRegOffset,
1914 &Data); 1849 &Data);
1915 if (status < 0) { 1850 if (status < 0) {
1916 dbg("reading spreg failed in set_serial_baud"); 1851 dev_dbg(&port->dev, "reading spreg failed in set_serial_baud\n");
1917 return -1; 1852 return -1;
1918 } 1853 }
1919 Data = (Data & 0x8f) | clk_sel_val; 1854 Data = (Data & 0x8f) | clk_sel_val;
1920 status = mos7840_set_reg_sync(port, mos7840_port->SpRegOffset, 1855 status = mos7840_set_reg_sync(port, mos7840_port->SpRegOffset,
1921 Data); 1856 Data);
1922 if (status < 0) { 1857 if (status < 0) {
1923 dbg("Writing spreg failed in set_serial_baud"); 1858 dev_dbg(&port->dev, "Writing spreg failed in set_serial_baud\n");
1924 return -1; 1859 return -1;
1925 } 1860 }
1926 /* Calculate the Divisor */ 1861 /* Calculate the Divisor */
@@ -1936,11 +1871,11 @@ static int mos7840_send_cmd_write_baud_rate(struct moschip_port *mos7840_port,
1936 1871
1937 /* Write the divisor */ 1872 /* Write the divisor */
1938 Data = (unsigned char)(divisor & 0xff); 1873 Data = (unsigned char)(divisor & 0xff);
1939 dbg("set_serial_baud Value to write DLL is %x", Data); 1874 dev_dbg(&port->dev, "set_serial_baud Value to write DLL is %x\n", Data);
1940 mos7840_set_uart_reg(port, DIVISOR_LATCH_LSB, Data); 1875 mos7840_set_uart_reg(port, DIVISOR_LATCH_LSB, Data);
1941 1876
1942 Data = (unsigned char)((divisor & 0xff00) >> 8); 1877 Data = (unsigned char)((divisor & 0xff00) >> 8);
1943 dbg("set_serial_baud Value to write DLM is %x", Data); 1878 dev_dbg(&port->dev, "set_serial_baud Value to write DLM is %x\n", Data);
1944 mos7840_set_uart_reg(port, DIVISOR_LATCH_MSB, Data); 1879 mos7840_set_uart_reg(port, DIVISOR_LATCH_MSB, Data);
1945 1880
1946 /* Disable access to divisor latch */ 1881 /* Disable access to divisor latch */
@@ -1975,24 +1910,18 @@ static void mos7840_change_port_settings(struct tty_struct *tty,
1975 if (mos7840_port == NULL) 1910 if (mos7840_port == NULL)
1976 return; 1911 return;
1977 1912
1978 port = (struct usb_serial_port *)mos7840_port->port; 1913 port = mos7840_port->port;
1979 1914
1980 if (mos7840_port_paranoia_check(port, __func__)) { 1915 if (mos7840_port_paranoia_check(port, __func__))
1981 dbg("%s", "Invalid port");
1982 return; 1916 return;
1983 }
1984 1917
1985 if (mos7840_serial_paranoia_check(port->serial, __func__)) { 1918 if (mos7840_serial_paranoia_check(port->serial, __func__))
1986 dbg("%s", "Invalid Serial");
1987 return; 1919 return;
1988 }
1989 1920
1990 serial = port->serial; 1921 serial = port->serial;
1991 1922
1992 dbg("%s - port %d", __func__, mos7840_port->port->number);
1993
1994 if (!mos7840_port->open) { 1923 if (!mos7840_port->open) {
1995 dbg("%s - port not opened", __func__); 1924 dev_dbg(&port->dev, "%s - port not opened\n", __func__);
1996 return; 1925 return;
1997 } 1926 }
1998 1927
@@ -2027,14 +1956,14 @@ static void mos7840_change_port_settings(struct tty_struct *tty,
2027 if (cflag & PARENB) { 1956 if (cflag & PARENB) {
2028 if (cflag & PARODD) { 1957 if (cflag & PARODD) {
2029 lParity = LCR_PAR_ODD; 1958 lParity = LCR_PAR_ODD;
2030 dbg("%s - parity = odd", __func__); 1959 dev_dbg(&port->dev, "%s - parity = odd\n", __func__);
2031 } else { 1960 } else {
2032 lParity = LCR_PAR_EVEN; 1961 lParity = LCR_PAR_EVEN;
2033 dbg("%s - parity = even", __func__); 1962 dev_dbg(&port->dev, "%s - parity = even\n", __func__);
2034 } 1963 }
2035 1964
2036 } else { 1965 } else {
2037 dbg("%s - parity = none", __func__); 1966 dev_dbg(&port->dev, "%s - parity = none\n", __func__);
2038 } 1967 }
2039 1968
2040 if (cflag & CMSPAR) 1969 if (cflag & CMSPAR)
@@ -2043,10 +1972,10 @@ static void mos7840_change_port_settings(struct tty_struct *tty,
2043 /* Change the Stop bit */ 1972 /* Change the Stop bit */
2044 if (cflag & CSTOPB) { 1973 if (cflag & CSTOPB) {
2045 lStop = LCR_STOP_2; 1974 lStop = LCR_STOP_2;
2046 dbg("%s - stop bits = 2", __func__); 1975 dev_dbg(&port->dev, "%s - stop bits = 2\n", __func__);
2047 } else { 1976 } else {
2048 lStop = LCR_STOP_1; 1977 lStop = LCR_STOP_1;
2049 dbg("%s - stop bits = 1", __func__); 1978 dev_dbg(&port->dev, "%s - stop bits = 1\n", __func__);
2050 } 1979 }
2051 1980
2052 /* Update the LCR with the correct value */ 1981 /* Update the LCR with the correct value */
@@ -2054,8 +1983,8 @@ static void mos7840_change_port_settings(struct tty_struct *tty,
2054 ~(LCR_BITS_MASK | LCR_STOP_MASK | LCR_PAR_MASK); 1983 ~(LCR_BITS_MASK | LCR_STOP_MASK | LCR_PAR_MASK);
2055 mos7840_port->shadowLCR |= (lData | lParity | lStop); 1984 mos7840_port->shadowLCR |= (lData | lParity | lStop);
2056 1985
2057 dbg("mos7840_change_port_settings mos7840_port->shadowLCR is %x", 1986 dev_dbg(&port->dev, "%s - mos7840_port->shadowLCR is %x\n", __func__,
2058 mos7840_port->shadowLCR); 1987 mos7840_port->shadowLCR);
2059 /* Disable Interrupts */ 1988 /* Disable Interrupts */
2060 Data = 0x00; 1989 Data = 0x00;
2061 mos7840_set_uart_reg(port, INTERRUPT_ENABLE_REGISTER, Data); 1990 mos7840_set_uart_reg(port, INTERRUPT_ENABLE_REGISTER, Data);
@@ -2096,11 +2025,11 @@ static void mos7840_change_port_settings(struct tty_struct *tty,
2096 2025
2097 if (!baud) { 2026 if (!baud) {
2098 /* pick a default, any default... */ 2027 /* pick a default, any default... */
2099 dbg("%s", "Picked default baud..."); 2028 dev_dbg(&port->dev, "%s", "Picked default baud...\n");
2100 baud = 9600; 2029 baud = 9600;
2101 } 2030 }
2102 2031
2103 dbg("%s - baud rate = %d", __func__, baud); 2032 dev_dbg(&port->dev, "%s - baud rate = %d\n", __func__, baud);
2104 status = mos7840_send_cmd_write_baud_rate(mos7840_port, baud); 2033 status = mos7840_send_cmd_write_baud_rate(mos7840_port, baud);
2105 2034
2106 /* Enable Interrupts */ 2035 /* Enable Interrupts */
@@ -2111,15 +2040,15 @@ static void mos7840_change_port_settings(struct tty_struct *tty,
2111 mos7840_port->read_urb_busy = true; 2040 mos7840_port->read_urb_busy = true;
2112 status = usb_submit_urb(mos7840_port->read_urb, GFP_ATOMIC); 2041 status = usb_submit_urb(mos7840_port->read_urb, GFP_ATOMIC);
2113 if (status) { 2042 if (status) {
2114 dbg("usb_submit_urb(read bulk) failed, status = %d", 2043 dev_dbg(&port->dev, "usb_submit_urb(read bulk) failed, status = %d\n",
2115 status); 2044 status);
2116 mos7840_port->read_urb_busy = false; 2045 mos7840_port->read_urb_busy = false;
2117 } 2046 }
2118 } 2047 }
2119 wake_up(&mos7840_port->delta_msr_wait); 2048 wake_up(&mos7840_port->delta_msr_wait);
2120 mos7840_port->delta_msr_cond = 1; 2049 mos7840_port->delta_msr_cond = 1;
2121 dbg("mos7840_change_port_settings mos7840_port->shadowLCR is End %x", 2050 dev_dbg(&port->dev, "%s - mos7840_port->shadowLCR is End %x\n", __func__,
2122 mos7840_port->shadowLCR); 2051 mos7840_port->shadowLCR);
2123} 2052}
2124 2053
2125/***************************************************************************** 2054/*****************************************************************************
@@ -2137,17 +2066,13 @@ static void mos7840_set_termios(struct tty_struct *tty,
2137 struct usb_serial *serial; 2066 struct usb_serial *serial;
2138 struct moschip_port *mos7840_port; 2067 struct moschip_port *mos7840_port;
2139 2068
2140 if (mos7840_port_paranoia_check(port, __func__)) { 2069 if (mos7840_port_paranoia_check(port, __func__))
2141 dbg("%s", "Invalid port");
2142 return; 2070 return;
2143 }
2144 2071
2145 serial = port->serial; 2072 serial = port->serial;
2146 2073
2147 if (mos7840_serial_paranoia_check(serial, __func__)) { 2074 if (mos7840_serial_paranoia_check(serial, __func__))
2148 dbg("%s", "Invalid Serial");
2149 return; 2075 return;
2150 }
2151 2076
2152 mos7840_port = mos7840_get_port_private(port); 2077 mos7840_port = mos7840_get_port_private(port);
2153 2078
@@ -2155,26 +2080,26 @@ static void mos7840_set_termios(struct tty_struct *tty,
2155 return; 2080 return;
2156 2081
2157 if (!mos7840_port->open) { 2082 if (!mos7840_port->open) {
2158 dbg("%s - port not opened", __func__); 2083 dev_dbg(&port->dev, "%s - port not opened\n", __func__);
2159 return; 2084 return;
2160 } 2085 }
2161 2086
2162 dbg("%s", "setting termios - "); 2087 dev_dbg(&port->dev, "%s", "setting termios - \n");
2163 2088
2164 cflag = tty->termios.c_cflag; 2089 cflag = tty->termios.c_cflag;
2165 2090
2166 dbg("%s - clfag %08x iflag %08x", __func__, 2091 dev_dbg(&port->dev, "%s - clfag %08x iflag %08x\n", __func__,
2167 tty->termios.c_cflag, RELEVANT_IFLAG(tty->termios.c_iflag)); 2092 tty->termios.c_cflag, RELEVANT_IFLAG(tty->termios.c_iflag));
2168 dbg("%s - old clfag %08x old iflag %08x", __func__, 2093 dev_dbg(&port->dev, "%s - old clfag %08x old iflag %08x\n", __func__,
2169 old_termios->c_cflag, RELEVANT_IFLAG(old_termios->c_iflag)); 2094 old_termios->c_cflag, RELEVANT_IFLAG(old_termios->c_iflag));
2170 dbg("%s - port %d", __func__, port->number); 2095 dev_dbg(&port->dev, "%s - port %d\n", __func__, port->number);
2171 2096
2172 /* change the port settings to the new ones specified */ 2097 /* change the port settings to the new ones specified */
2173 2098
2174 mos7840_change_port_settings(tty, mos7840_port, old_termios); 2099 mos7840_change_port_settings(tty, mos7840_port, old_termios);
2175 2100
2176 if (!mos7840_port->read_urb) { 2101 if (!mos7840_port->read_urb) {
2177 dbg("%s", "URB KILLED !!!!!"); 2102 dev_dbg(&port->dev, "%s", "URB KILLED !!!!!\n");
2178 return; 2103 return;
2179 } 2104 }
2180 2105
@@ -2182,7 +2107,7 @@ static void mos7840_set_termios(struct tty_struct *tty,
2182 mos7840_port->read_urb_busy = true; 2107 mos7840_port->read_urb_busy = true;
2183 status = usb_submit_urb(mos7840_port->read_urb, GFP_ATOMIC); 2108 status = usb_submit_urb(mos7840_port->read_urb, GFP_ATOMIC);
2184 if (status) { 2109 if (status) {
2185 dbg("usb_submit_urb(read bulk) failed, status = %d", 2110 dev_dbg(&port->dev, "usb_submit_urb(read bulk) failed, status = %d\n",
2186 status); 2111 status);
2187 mos7840_port->read_urb_busy = false; 2112 mos7840_port->read_urb_busy = false;
2188 } 2113 }
@@ -2207,10 +2132,8 @@ static int mos7840_get_lsr_info(struct tty_struct *tty,
2207 unsigned int result = 0; 2132 unsigned int result = 0;
2208 2133
2209 count = mos7840_chars_in_buffer(tty); 2134 count = mos7840_chars_in_buffer(tty);
2210 if (count == 0) { 2135 if (count == 0)
2211 dbg("%s -- Empty", __func__);
2212 result = TIOCSER_TEMT; 2136 result = TIOCSER_TEMT;
2213 }
2214 2137
2215 if (copy_to_user(value, &result, sizeof(int))) 2138 if (copy_to_user(value, &result, sizeof(int)))
2216 return -EFAULT; 2139 return -EFAULT;
@@ -2273,8 +2196,8 @@ static int mos7840_get_icount(struct tty_struct *tty,
2273 icount->brk = cnow.brk; 2196 icount->brk = cnow.brk;
2274 icount->buf_overrun = cnow.buf_overrun; 2197 icount->buf_overrun = cnow.buf_overrun;
2275 2198
2276 dbg("%s (%d) TIOCGICOUNT RX=%d, TX=%d", __func__, 2199 dev_dbg(&port->dev, "%s TIOCGICOUNT RX=%d, TX=%d\n", __func__,
2277 port->number, icount->rx, icount->tx); 2200 icount->rx, icount->tx);
2278 return 0; 2201 return 0;
2279} 2202}
2280 2203
@@ -2293,35 +2216,33 @@ static int mos7840_ioctl(struct tty_struct *tty,
2293 struct async_icount cnow; 2216 struct async_icount cnow;
2294 struct async_icount cprev; 2217 struct async_icount cprev;
2295 2218
2296 if (mos7840_port_paranoia_check(port, __func__)) { 2219 if (mos7840_port_paranoia_check(port, __func__))
2297 dbg("%s", "Invalid port");
2298 return -1; 2220 return -1;
2299 }
2300 2221
2301 mos7840_port = mos7840_get_port_private(port); 2222 mos7840_port = mos7840_get_port_private(port);
2302 2223
2303 if (mos7840_port == NULL) 2224 if (mos7840_port == NULL)
2304 return -1; 2225 return -1;
2305 2226
2306 dbg("%s - port %d, cmd = 0x%x", __func__, port->number, cmd); 2227 dev_dbg(&port->dev, "%s - cmd = 0x%x\n", __func__, cmd);
2307 2228
2308 switch (cmd) { 2229 switch (cmd) {
2309 /* return number of bytes available */ 2230 /* return number of bytes available */
2310 2231
2311 case TIOCSERGETLSR: 2232 case TIOCSERGETLSR:
2312 dbg("%s (%d) TIOCSERGETLSR", __func__, port->number); 2233 dev_dbg(&port->dev, "%s TIOCSERGETLSR\n", __func__);
2313 return mos7840_get_lsr_info(tty, argp); 2234 return mos7840_get_lsr_info(tty, argp);
2314 2235
2315 case TIOCGSERIAL: 2236 case TIOCGSERIAL:
2316 dbg("%s (%d) TIOCGSERIAL", __func__, port->number); 2237 dev_dbg(&port->dev, "%s TIOCGSERIAL\n", __func__);
2317 return mos7840_get_serial_info(mos7840_port, argp); 2238 return mos7840_get_serial_info(mos7840_port, argp);
2318 2239
2319 case TIOCSSERIAL: 2240 case TIOCSSERIAL:
2320 dbg("%s (%d) TIOCSSERIAL", __func__, port->number); 2241 dev_dbg(&port->dev, "%s TIOCSSERIAL\n", __func__);
2321 break; 2242 break;
2322 2243
2323 case TIOCMIWAIT: 2244 case TIOCMIWAIT:
2324 dbg("%s (%d) TIOCMIWAIT", __func__, port->number); 2245 dev_dbg(&port->dev, "%s TIOCMIWAIT\n", __func__);
2325 cprev = mos7840_port->icount; 2246 cprev = mos7840_port->icount;
2326 while (1) { 2247 while (1) {
2327 /* interruptible_sleep_on(&mos7840_port->delta_msr_wait); */ 2248 /* interruptible_sleep_on(&mos7840_port->delta_msr_wait); */
@@ -2437,11 +2358,6 @@ static int mos7840_startup(struct usb_serial *serial)
2437 int i, status; 2358 int i, status;
2438 __u16 Data; 2359 __u16 Data;
2439 2360
2440 if (!serial) {
2441 dbg("%s", "Invalid Handler");
2442 return -1;
2443 }
2444
2445 dev = serial->dev; 2361 dev = serial->dev;
2446 2362
2447 /* we set up the pointers to the endpoints in the mos7840_open * 2363 /* we set up the pointers to the endpoints in the mos7840_open *
@@ -2449,7 +2365,7 @@ static int mos7840_startup(struct usb_serial *serial)
2449 2365
2450 /* set up port private structures */ 2366 /* set up port private structures */
2451 for (i = 0; i < serial->num_ports; ++i) { 2367 for (i = 0; i < serial->num_ports; ++i) {
2452 dbg ("mos7840_startup: configuring port %d............", i); 2368 dev_dbg(&dev->dev, "mos7840_startup: configuring port %d............\n", i);
2453 mos7840_port = kzalloc(sizeof(struct moschip_port), GFP_KERNEL); 2369 mos7840_port = kzalloc(sizeof(struct moschip_port), GFP_KERNEL);
2454 if (mos7840_port == NULL) { 2370 if (mos7840_port == NULL) {
2455 dev_err(&dev->dev, "%s - Out of memory\n", __func__); 2371 dev_err(&dev->dev, "%s - Out of memory\n", __func__);
@@ -2470,10 +2386,10 @@ static int mos7840_startup(struct usb_serial *serial)
2470 * usb-serial.c:get_free_serial() and cannot therefore be used 2386 * usb-serial.c:get_free_serial() and cannot therefore be used
2471 * to index device instances */ 2387 * to index device instances */
2472 mos7840_port->port_num = i + 1; 2388 mos7840_port->port_num = i + 1;
2473 dbg ("serial->port[i]->number = %d", serial->port[i]->number); 2389 dev_dbg(&dev->dev, "serial->port[i]->number = %d\n", serial->port[i]->number);
2474 dbg ("serial->port[i]->serial->minor = %d", serial->port[i]->serial->minor); 2390 dev_dbg(&dev->dev, "serial->port[i]->serial->minor = %d\n", serial->port[i]->serial->minor);
2475 dbg ("mos7840_port->port_num = %d", mos7840_port->port_num); 2391 dev_dbg(&dev->dev, "mos7840_port->port_num = %d\n", mos7840_port->port_num);
2476 dbg ("serial->minor = %d", serial->minor); 2392 dev_dbg(&dev->dev, "serial->minor = %d\n", serial->minor);
2477 2393
2478 if (mos7840_port->port_num == 1) { 2394 if (mos7840_port->port_num == 1) {
2479 mos7840_port->SpRegOffset = 0x0; 2395 mos7840_port->SpRegOffset = 0x0;
@@ -2500,18 +2416,17 @@ static int mos7840_startup(struct usb_serial *serial)
2500 mos7840_port->ControlRegOffset = 0xd; 2416 mos7840_port->ControlRegOffset = 0xd;
2501 mos7840_port->DcrRegOffset = 0x1c; 2417 mos7840_port->DcrRegOffset = 0x1c;
2502 } 2418 }
2503 mos7840_dump_serial_port(mos7840_port); 2419 mos7840_dump_serial_port(serial->port[i], mos7840_port);
2504 mos7840_set_port_private(serial->port[i], mos7840_port); 2420 mos7840_set_port_private(serial->port[i], mos7840_port);
2505 2421
2506 /* enable rx_disable bit in control register */ 2422 /* enable rx_disable bit in control register */
2507 status = mos7840_get_reg_sync(serial->port[i], 2423 status = mos7840_get_reg_sync(serial->port[i],
2508 mos7840_port->ControlRegOffset, &Data); 2424 mos7840_port->ControlRegOffset, &Data);
2509 if (status < 0) { 2425 if (status < 0) {
2510 dbg("Reading ControlReg failed status-0x%x", status); 2426 dev_dbg(&dev->dev, "Reading ControlReg failed status-0x%x\n", status);
2511 break; 2427 break;
2512 } else 2428 } else
2513 dbg("ControlReg Reading success val is %x, status%d", 2429 dev_dbg(&dev->dev, "ControlReg Reading success val is %x, status%d\n", Data, status);
2514 Data, status);
2515 Data |= 0x08; /* setting driver done bit */ 2430 Data |= 0x08; /* setting driver done bit */
2516 Data |= 0x04; /* sp1_bit to have cts change reflect in 2431 Data |= 0x04; /* sp1_bit to have cts change reflect in
2517 modem status reg */ 2432 modem status reg */
@@ -2520,11 +2435,10 @@ static int mos7840_startup(struct usb_serial *serial)
2520 status = mos7840_set_reg_sync(serial->port[i], 2435 status = mos7840_set_reg_sync(serial->port[i],
2521 mos7840_port->ControlRegOffset, Data); 2436 mos7840_port->ControlRegOffset, Data);
2522 if (status < 0) { 2437 if (status < 0) {
2523 dbg("Writing ControlReg failed(rx_disable) status-0x%x", status); 2438 dev_dbg(&dev->dev, "Writing ControlReg failed(rx_disable) status-0x%x\n", status);
2524 break; 2439 break;
2525 } else 2440 } else
2526 dbg("ControlReg Writing success(rx_disable) status%d", 2441 dev_dbg(&dev->dev, "ControlReg Writing success(rx_disable) status%d\n", status);
2527 status);
2528 2442
2529 /* Write default values in DCR (i.e 0x01 in DCR0, 0x05 in DCR2 2443 /* Write default values in DCR (i.e 0x01 in DCR0, 0x05 in DCR2
2530 and 0x24 in DCR3 */ 2444 and 0x24 in DCR3 */
@@ -2532,61 +2446,57 @@ static int mos7840_startup(struct usb_serial *serial)
2532 status = mos7840_set_reg_sync(serial->port[i], 2446 status = mos7840_set_reg_sync(serial->port[i],
2533 (__u16) (mos7840_port->DcrRegOffset + 0), Data); 2447 (__u16) (mos7840_port->DcrRegOffset + 0), Data);
2534 if (status < 0) { 2448 if (status < 0) {
2535 dbg("Writing DCR0 failed status-0x%x", status); 2449 dev_dbg(&dev->dev, "Writing DCR0 failed status-0x%x\n", status);
2536 break; 2450 break;
2537 } else 2451 } else
2538 dbg("DCR0 Writing success status%d", status); 2452 dev_dbg(&dev->dev, "DCR0 Writing success status%d\n", status);
2539 2453
2540 Data = 0x05; 2454 Data = 0x05;
2541 status = mos7840_set_reg_sync(serial->port[i], 2455 status = mos7840_set_reg_sync(serial->port[i],
2542 (__u16) (mos7840_port->DcrRegOffset + 1), Data); 2456 (__u16) (mos7840_port->DcrRegOffset + 1), Data);
2543 if (status < 0) { 2457 if (status < 0) {
2544 dbg("Writing DCR1 failed status-0x%x", status); 2458 dev_dbg(&dev->dev, "Writing DCR1 failed status-0x%x\n", status);
2545 break; 2459 break;
2546 } else 2460 } else
2547 dbg("DCR1 Writing success status%d", status); 2461 dev_dbg(&dev->dev, "DCR1 Writing success status%d\n", status);
2548 2462
2549 Data = 0x24; 2463 Data = 0x24;
2550 status = mos7840_set_reg_sync(serial->port[i], 2464 status = mos7840_set_reg_sync(serial->port[i],
2551 (__u16) (mos7840_port->DcrRegOffset + 2), Data); 2465 (__u16) (mos7840_port->DcrRegOffset + 2), Data);
2552 if (status < 0) { 2466 if (status < 0) {
2553 dbg("Writing DCR2 failed status-0x%x", status); 2467 dev_dbg(&dev->dev, "Writing DCR2 failed status-0x%x\n", status);
2554 break; 2468 break;
2555 } else 2469 } else
2556 dbg("DCR2 Writing success status%d", status); 2470 dev_dbg(&dev->dev, "DCR2 Writing success status%d\n", status);
2557 2471
2558 /* write values in clkstart0x0 and clkmulti 0x20 */ 2472 /* write values in clkstart0x0 and clkmulti 0x20 */
2559 Data = 0x0; 2473 Data = 0x0;
2560 status = mos7840_set_reg_sync(serial->port[i], 2474 status = mos7840_set_reg_sync(serial->port[i],
2561 CLK_START_VALUE_REGISTER, Data); 2475 CLK_START_VALUE_REGISTER, Data);
2562 if (status < 0) { 2476 if (status < 0) {
2563 dbg("Writing CLK_START_VALUE_REGISTER failed status-0x%x", status); 2477 dev_dbg(&dev->dev, "Writing CLK_START_VALUE_REGISTER failed status-0x%x\n", status);
2564 break; 2478 break;
2565 } else 2479 } else
2566 dbg("CLK_START_VALUE_REGISTER Writing success status%d", status); 2480 dev_dbg(&dev->dev, "CLK_START_VALUE_REGISTER Writing success status%d\n", status);
2567 2481
2568 Data = 0x20; 2482 Data = 0x20;
2569 status = mos7840_set_reg_sync(serial->port[i], 2483 status = mos7840_set_reg_sync(serial->port[i],
2570 CLK_MULTI_REGISTER, Data); 2484 CLK_MULTI_REGISTER, Data);
2571 if (status < 0) { 2485 if (status < 0) {
2572 dbg("Writing CLK_MULTI_REGISTER failed status-0x%x", 2486 dev_dbg(&dev->dev, "Writing CLK_MULTI_REGISTER failed status-0x%x\n", status);
2573 status);
2574 goto error; 2487 goto error;
2575 } else 2488 } else
2576 dbg("CLK_MULTI_REGISTER Writing success status%d", 2489 dev_dbg(&dev->dev, "CLK_MULTI_REGISTER Writing success status%d\n", status);
2577 status);
2578 2490
2579 /* write value 0x0 to scratchpad register */ 2491 /* write value 0x0 to scratchpad register */
2580 Data = 0x00; 2492 Data = 0x00;
2581 status = mos7840_set_uart_reg(serial->port[i], 2493 status = mos7840_set_uart_reg(serial->port[i],
2582 SCRATCH_PAD_REGISTER, Data); 2494 SCRATCH_PAD_REGISTER, Data);
2583 if (status < 0) { 2495 if (status < 0) {
2584 dbg("Writing SCRATCH_PAD_REGISTER failed status-0x%x", 2496 dev_dbg(&dev->dev, "Writing SCRATCH_PAD_REGISTER failed status-0x%x\n", status);
2585 status);
2586 break; 2497 break;
2587 } else 2498 } else
2588 dbg("SCRATCH_PAD_REGISTER Writing success status%d", 2499 dev_dbg(&dev->dev, "SCRATCH_PAD_REGISTER Writing success status%d\n", status);
2589 status);
2590 2500
2591 /* Zero Length flag register */ 2501 /* Zero Length flag register */
2592 if ((mos7840_port->port_num != 1) 2502 if ((mos7840_port->port_num != 1)
@@ -2596,31 +2506,25 @@ static int mos7840_startup(struct usb_serial *serial)
2596 status = mos7840_set_reg_sync(serial->port[i], 2506 status = mos7840_set_reg_sync(serial->port[i],
2597 (__u16) (ZLP_REG1 + 2507 (__u16) (ZLP_REG1 +
2598 ((__u16)mos7840_port->port_num)), Data); 2508 ((__u16)mos7840_port->port_num)), Data);
2599 dbg("ZLIP offset %x", 2509 dev_dbg(&dev->dev, "ZLIP offset %x\n",
2600 (__u16) (ZLP_REG1 + 2510 (__u16)(ZLP_REG1 + ((__u16) mos7840_port->port_num)));
2601 ((__u16) mos7840_port->port_num)));
2602 if (status < 0) { 2511 if (status < 0) {
2603 dbg("Writing ZLP_REG%d failed status-0x%x", 2512 dev_dbg(&dev->dev, "Writing ZLP_REG%d failed status-0x%x\n", i + 2, status);
2604 i + 2, status);
2605 break; 2513 break;
2606 } else 2514 } else
2607 dbg("ZLP_REG%d Writing success status%d", 2515 dev_dbg(&dev->dev, "ZLP_REG%d Writing success status%d\n", i + 2, status);
2608 i + 2, status);
2609 } else { 2516 } else {
2610 Data = 0xff; 2517 Data = 0xff;
2611 status = mos7840_set_reg_sync(serial->port[i], 2518 status = mos7840_set_reg_sync(serial->port[i],
2612 (__u16) (ZLP_REG1 + 2519 (__u16) (ZLP_REG1 +
2613 ((__u16)mos7840_port->port_num) - 0x1), Data); 2520 ((__u16)mos7840_port->port_num) - 0x1), Data);
2614 dbg("ZLIP offset %x", 2521 dev_dbg(&dev->dev, "ZLIP offset %x\n",
2615 (__u16) (ZLP_REG1 + 2522 (__u16)(ZLP_REG1 + ((__u16) mos7840_port->port_num) - 0x1));
2616 ((__u16) mos7840_port->port_num) - 0x1));
2617 if (status < 0) { 2523 if (status < 0) {
2618 dbg("Writing ZLP_REG%d failed status-0x%x", 2524 dev_dbg(&dev->dev, "Writing ZLP_REG%d failed status-0x%x\n", i + 1, status);
2619 i + 1, status);
2620 break; 2525 break;
2621 } else 2526 } else
2622 dbg("ZLP_REG%d Writing success status%d", 2527 dev_dbg(&dev->dev, "ZLP_REG%d Writing success status%d\n", i + 1, status);
2623 i + 1, status);
2624 2528
2625 } 2529 }
2626 mos7840_port->control_urb = usb_alloc_urb(0, GFP_KERNEL); 2530 mos7840_port->control_urb = usb_alloc_urb(0, GFP_KERNEL);
@@ -2661,16 +2565,15 @@ static int mos7840_startup(struct usb_serial *serial)
2661 MODEM_CONTROL_REGISTER, 0x0300); 2565 MODEM_CONTROL_REGISTER, 0x0300);
2662 } 2566 }
2663 } 2567 }
2664 dbg ("mos7840_startup: all ports configured...........");
2665 2568
2666 /* Zero Length flag enable */ 2569 /* Zero Length flag enable */
2667 Data = 0x0f; 2570 Data = 0x0f;
2668 status = mos7840_set_reg_sync(serial->port[0], ZLP_REG5, Data); 2571 status = mos7840_set_reg_sync(serial->port[0], ZLP_REG5, Data);
2669 if (status < 0) { 2572 if (status < 0) {
2670 dbg("Writing ZLP_REG5 failed status-0x%x", status); 2573 dev_dbg(&dev->dev, "Writing ZLP_REG5 failed status-0x%x\n", status);
2671 goto error; 2574 goto error;
2672 } else 2575 } else
2673 dbg("ZLP_REG5 Writing success status%d", status); 2576 dev_dbg(&dev->dev, "ZLP_REG5 Writing success status%d\n", status);
2674 2577
2675 /* setting configuration feature to one */ 2578 /* setting configuration feature to one */
2676 usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), 2579 usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
@@ -2700,11 +2603,6 @@ static void mos7840_disconnect(struct usb_serial *serial)
2700 unsigned long flags; 2603 unsigned long flags;
2701 struct moschip_port *mos7840_port; 2604 struct moschip_port *mos7840_port;
2702 2605
2703 if (!serial) {
2704 dbg("%s", "Invalid Handler");
2705 return;
2706 }
2707
2708 /* check for the ports to be closed,close the ports and disconnect */ 2606 /* check for the ports to be closed,close the ports and disconnect */
2709 2607
2710 /* free private structure allocated for serial port * 2608 /* free private structure allocated for serial port *
@@ -2712,7 +2610,6 @@ static void mos7840_disconnect(struct usb_serial *serial)
2712 2610
2713 for (i = 0; i < serial->num_ports; ++i) { 2611 for (i = 0; i < serial->num_ports; ++i) {
2714 mos7840_port = mos7840_get_port_private(serial->port[i]); 2612 mos7840_port = mos7840_get_port_private(serial->port[i]);
2715 dbg ("mos7840_port %d = %p", i, mos7840_port);
2716 if (mos7840_port) { 2613 if (mos7840_port) {
2717 spin_lock_irqsave(&mos7840_port->pool_lock, flags); 2614 spin_lock_irqsave(&mos7840_port->pool_lock, flags);
2718 mos7840_port->zombie = 1; 2615 mos7840_port->zombie = 1;
@@ -2732,11 +2629,6 @@ static void mos7840_release(struct usb_serial *serial)
2732 int i; 2629 int i;
2733 struct moschip_port *mos7840_port; 2630 struct moschip_port *mos7840_port;
2734 2631
2735 if (!serial) {
2736 dbg("%s", "Invalid Handler");
2737 return;
2738 }
2739
2740 /* check for the ports to be closed,close the ports and disconnect */ 2632 /* check for the ports to be closed,close the ports and disconnect */
2741 2633
2742 /* free private structure allocated for serial port * 2634 /* free private structure allocated for serial port *
@@ -2744,7 +2636,6 @@ static void mos7840_release(struct usb_serial *serial)
2744 2636
2745 for (i = 0; i < serial->num_ports; ++i) { 2637 for (i = 0; i < serial->num_ports; ++i) {
2746 mos7840_port = mos7840_get_port_private(serial->port[i]); 2638 mos7840_port = mos7840_get_port_private(serial->port[i]);
2747 dbg("mos7840_port %d = %p", i, mos7840_port);
2748 if (mos7840_port) { 2639 if (mos7840_port) {
2749 if (mos7840_port->has_led) { 2640 if (mos7840_port->has_led) {
2750 /* Turn off LED */ 2641 /* Turn off LED */
@@ -2801,6 +2692,3 @@ module_usb_serial_driver(serial_drivers, id_table);
2801 2692
2802MODULE_DESCRIPTION(DRIVER_DESC); 2693MODULE_DESCRIPTION(DRIVER_DESC);
2803MODULE_LICENSE("GPL"); 2694MODULE_LICENSE("GPL");
2804
2805module_param(debug, bool, S_IRUGO | S_IWUSR);
2806MODULE_PARM_DESC(debug, "Debug enabled or not");
diff --git a/drivers/usb/serial/navman.c b/drivers/usb/serial/navman.c
index d95452cc076d..1566f8f500ae 100644
--- a/drivers/usb/serial/navman.c
+++ b/drivers/usb/serial/navman.c
@@ -21,8 +21,6 @@
21#include <linux/usb.h> 21#include <linux/usb.h>
22#include <linux/usb/serial.h> 22#include <linux/usb/serial.h>
23 23
24static bool debug;
25
26static const struct usb_device_id id_table[] = { 24static const struct usb_device_id id_table[] = {
27 { USB_DEVICE(0x0a99, 0x0001) }, /* Talon Technology device */ 25 { USB_DEVICE(0x0a99, 0x0001) }, /* Talon Technology device */
28 { USB_DEVICE(0x0df7, 0x0900) }, /* Mobile Action i-gotU */ 26 { USB_DEVICE(0x0df7, 0x0900) }, /* Mobile Action i-gotU */
@@ -55,8 +53,7 @@ static void navman_read_int_callback(struct urb *urb)
55 goto exit; 53 goto exit;
56 } 54 }
57 55
58 usb_serial_debug_data(debug, &port->dev, __func__, 56 usb_serial_debug_data(&port->dev, __func__, urb->actual_length, data);
59 urb->actual_length, data);
60 57
61 tty = tty_port_tty_get(&port->port); 58 tty = tty_port_tty_get(&port->port);
62 if (tty && urb->actual_length) { 59 if (tty && urb->actual_length) {
@@ -123,6 +120,3 @@ static struct usb_serial_driver * const serial_drivers[] = {
123module_usb_serial_driver(serial_drivers, id_table); 120module_usb_serial_driver(serial_drivers, id_table);
124 121
125MODULE_LICENSE("GPL"); 122MODULE_LICENSE("GPL");
126
127module_param(debug, bool, S_IRUGO | S_IWUSR);
128MODULE_PARM_DESC(debug, "Debug enabled or not");
diff --git a/drivers/usb/serial/omninet.c b/drivers/usb/serial/omninet.c
index 6f3d7051c7f4..6def58b79382 100644
--- a/drivers/usb/serial/omninet.c
+++ b/drivers/usb/serial/omninet.c
@@ -23,8 +23,6 @@
23#include <linux/usb.h> 23#include <linux/usb.h>
24#include <linux/usb/serial.h> 24#include <linux/usb/serial.h>
25 25
26static bool debug;
27
28/* 26/*
29 * Version Information 27 * Version Information
30 */ 28 */
@@ -164,31 +162,21 @@ static void omninet_read_bulk_callback(struct urb *urb)
164 struct omninet_header *header = (struct omninet_header *) &data[0]; 162 struct omninet_header *header = (struct omninet_header *) &data[0];
165 int status = urb->status; 163 int status = urb->status;
166 int result; 164 int result;
167 int i;
168 165
169 if (status) { 166 if (status) {
170 dbg("%s - nonzero read bulk status received: %d", 167 dev_dbg(&port->dev, "%s - nonzero read bulk status received: %d\n",
171 __func__, status); 168 __func__, status);
172 return; 169 return;
173 } 170 }
174 171
175 if (debug && header->oh_xxx != 0x30) {
176 if (urb->actual_length) {
177 printk(KERN_DEBUG "%s: omninet_read %d: ",
178 __FILE__, header->oh_len);
179 for (i = 0; i < (header->oh_len +
180 OMNINET_HEADERLEN); i++)
181 printk("%.2x ", data[i]);
182 printk("\n");
183 }
184 }
185
186 if (urb->actual_length && header->oh_len) { 172 if (urb->actual_length && header->oh_len) {
187 struct tty_struct *tty = tty_port_tty_get(&port->port); 173 struct tty_struct *tty = tty_port_tty_get(&port->port);
188 tty_insert_flip_string(tty, data + OMNINET_DATAOFFSET, 174 if (tty) {
175 tty_insert_flip_string(tty, data + OMNINET_DATAOFFSET,
189 header->oh_len); 176 header->oh_len);
190 tty_flip_buffer_push(tty); 177 tty_flip_buffer_push(tty);
191 tty_kref_put(tty); 178 tty_kref_put(tty);
179 }
192 } 180 }
193 181
194 /* Continue trying to always read */ 182 /* Continue trying to always read */
@@ -212,12 +200,12 @@ static int omninet_write(struct tty_struct *tty, struct usb_serial_port *port,
212 int result; 200 int result;
213 201
214 if (count == 0) { 202 if (count == 0) {
215 dbg("%s - write request of 0 bytes", __func__); 203 dev_dbg(&port->dev, "%s - write request of 0 bytes\n", __func__);
216 return 0; 204 return 0;
217 } 205 }
218 206
219 if (!test_and_clear_bit(0, &port->write_urbs_free)) { 207 if (!test_and_clear_bit(0, &port->write_urbs_free)) {
220 dbg("%s - already writing", __func__); 208 dev_dbg(&port->dev, "%s - already writing\n", __func__);
221 return 0; 209 return 0;
222 } 210 }
223 211
@@ -226,8 +214,8 @@ static int omninet_write(struct tty_struct *tty, struct usb_serial_port *port,
226 memcpy(wport->write_urb->transfer_buffer + OMNINET_DATAOFFSET, 214 memcpy(wport->write_urb->transfer_buffer + OMNINET_DATAOFFSET,
227 buf, count); 215 buf, count);
228 216
229 usb_serial_debug_data(debug, &port->dev, __func__, count, 217 usb_serial_debug_data(&port->dev, __func__, count,
230 wport->write_urb->transfer_buffer); 218 wport->write_urb->transfer_buffer);
231 219
232 header->oh_seq = od->od_outseq++; 220 header->oh_seq = od->od_outseq++;
233 header->oh_len = count; 221 header->oh_len = count;
@@ -261,7 +249,7 @@ static int omninet_write_room(struct tty_struct *tty)
261 if (test_bit(0, &wport->write_urbs_free)) 249 if (test_bit(0, &wport->write_urbs_free))
262 room = wport->bulk_out_size - OMNINET_HEADERLEN; 250 room = wport->bulk_out_size - OMNINET_HEADERLEN;
263 251
264 dbg("%s - returns %d", __func__, room); 252 dev_dbg(&port->dev, "%s - returns %d\n", __func__, room);
265 253
266 return room; 254 return room;
267} 255}
@@ -275,8 +263,8 @@ static void omninet_write_bulk_callback(struct urb *urb)
275 263
276 set_bit(0, &port->write_urbs_free); 264 set_bit(0, &port->write_urbs_free);
277 if (status) { 265 if (status) {
278 dbg("%s - nonzero write bulk status received: %d", 266 dev_dbg(&port->dev, "%s - nonzero write bulk status received: %d\n",
279 __func__, status); 267 __func__, status);
280 return; 268 return;
281 } 269 }
282 270
@@ -304,6 +292,3 @@ module_usb_serial_driver(serial_drivers, id_table);
304MODULE_AUTHOR(DRIVER_AUTHOR); 292MODULE_AUTHOR(DRIVER_AUTHOR);
305MODULE_DESCRIPTION(DRIVER_DESC); 293MODULE_DESCRIPTION(DRIVER_DESC);
306MODULE_LICENSE("GPL"); 294MODULE_LICENSE("GPL");
307
308module_param(debug, bool, S_IRUGO | S_IWUSR);
309MODULE_PARM_DESC(debug, "Debug enabled or not");
diff --git a/drivers/usb/serial/opticon.c b/drivers/usb/serial/opticon.c
index 02cb1b7f6559..41b1647306eb 100644
--- a/drivers/usb/serial/opticon.c
+++ b/drivers/usb/serial/opticon.c
@@ -32,8 +32,6 @@
32 * an examples of 1D barcode types are EAN, UPC, Code39, IATA etc.. */ 32 * an examples of 1D barcode types are EAN, UPC, Code39, IATA etc.. */
33#define DRIVER_DESC "Opticon USB barcode to serial driver (1D)" 33#define DRIVER_DESC "Opticon USB barcode to serial driver (1D)"
34 34
35static bool debug;
36
37static const struct usb_device_id id_table[] = { 35static const struct usb_device_id id_table[] = {
38 { USB_DEVICE(0x065a, 0x0009) }, 36 { USB_DEVICE(0x065a, 0x0009) },
39 { }, 37 { },
@@ -78,17 +76,16 @@ static void opticon_read_bulk_callback(struct urb *urb)
78 case -ENOENT: 76 case -ENOENT:
79 case -ESHUTDOWN: 77 case -ESHUTDOWN:
80 /* this urb is terminated, clean up */ 78 /* this urb is terminated, clean up */
81 dbg("%s - urb shutting down with status: %d", 79 dev_dbg(&priv->udev->dev, "%s - urb shutting down with status: %d\n",
82 __func__, status); 80 __func__, status);
83 return; 81 return;
84 default: 82 default:
85 dbg("%s - nonzero urb status received: %d", 83 dev_dbg(&priv->udev->dev, "%s - nonzero urb status received: %d\n",
86 __func__, status); 84 __func__, status);
87 goto exit; 85 goto exit;
88 } 86 }
89 87
90 usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, 88 usb_serial_debug_data(&port->dev, __func__, urb->actual_length, data);
91 data);
92 89
93 if (urb->actual_length > 2) { 90 if (urb->actual_length > 2) {
94 data_length = urb->actual_length - 2; 91 data_length = urb->actual_length - 2;
@@ -229,8 +226,8 @@ static void opticon_write_control_callback(struct urb *urb)
229 kfree(urb->setup_packet); 226 kfree(urb->setup_packet);
230 227
231 if (status) 228 if (status)
232 dbg("%s - nonzero write bulk status received: %d", 229 dev_dbg(&priv->udev->dev, "%s - nonzero write bulk status received: %d\n",
233 __func__, status); 230 __func__, status);
234 231
235 spin_lock_irqsave(&priv->lock, flags); 232 spin_lock_irqsave(&priv->lock, flags);
236 --priv->outstanding_urbs; 233 --priv->outstanding_urbs;
@@ -253,7 +250,7 @@ static int opticon_write(struct tty_struct *tty, struct usb_serial_port *port,
253 spin_lock_irqsave(&priv->lock, flags); 250 spin_lock_irqsave(&priv->lock, flags);
254 if (priv->outstanding_urbs > URB_UPPER_LIMIT) { 251 if (priv->outstanding_urbs > URB_UPPER_LIMIT) {
255 spin_unlock_irqrestore(&priv->lock, flags); 252 spin_unlock_irqrestore(&priv->lock, flags);
256 dbg("%s - write limit hit", __func__); 253 dev_dbg(&port->dev, "%s - write limit hit\n", __func__);
257 return 0; 254 return 0;
258 } 255 }
259 priv->outstanding_urbs++; 256 priv->outstanding_urbs++;
@@ -276,7 +273,7 @@ static int opticon_write(struct tty_struct *tty, struct usb_serial_port *port,
276 273
277 memcpy(buffer, buf, count); 274 memcpy(buffer, buf, count);
278 275
279 usb_serial_debug_data(debug, &port->dev, __func__, count, buffer); 276 usb_serial_debug_data(&port->dev, __func__, count, buffer);
280 277
281 /* The conncected devices do not have a bulk write endpoint, 278 /* The conncected devices do not have a bulk write endpoint,
282 * to transmit data to de barcode device the control endpoint is used */ 279 * to transmit data to de barcode device the control endpoint is used */
@@ -338,7 +335,7 @@ static int opticon_write_room(struct tty_struct *tty)
338 spin_lock_irqsave(&priv->lock, flags); 335 spin_lock_irqsave(&priv->lock, flags);
339 if (priv->outstanding_urbs > URB_UPPER_LIMIT * 2 / 3) { 336 if (priv->outstanding_urbs > URB_UPPER_LIMIT * 2 / 3) {
340 spin_unlock_irqrestore(&priv->lock, flags); 337 spin_unlock_irqrestore(&priv->lock, flags);
341 dbg("%s - write limit hit", __func__); 338 dev_dbg(&port->dev, "%s - write limit hit\n", __func__);
342 return 0; 339 return 0;
343 } 340 }
344 spin_unlock_irqrestore(&priv->lock, flags); 341 spin_unlock_irqrestore(&priv->lock, flags);
@@ -394,7 +391,7 @@ static int opticon_tiocmget(struct tty_struct *tty)
394 result |= TIOCM_CTS; 391 result |= TIOCM_CTS;
395 spin_unlock_irqrestore(&priv->lock, flags); 392 spin_unlock_irqrestore(&priv->lock, flags);
396 393
397 dbg("%s - %x", __func__, result); 394 dev_dbg(&port->dev, "%s - %x\n", __func__, result);
398 return result; 395 return result;
399} 396}
400 397
@@ -466,7 +463,7 @@ static int opticon_ioctl(struct tty_struct *tty,
466 struct usb_serial_port *port = tty->driver_data; 463 struct usb_serial_port *port = tty->driver_data;
467 struct opticon_private *priv = usb_get_serial_data(port->serial); 464 struct opticon_private *priv = usb_get_serial_data(port->serial);
468 465
469 dbg("%s - port %d, cmd = 0x%x", __func__, port->number, cmd); 466 dev_dbg(&port->dev, "%s - port %d, cmd = 0x%x\n", __func__, port->number, cmd);
470 467
471 switch (cmd) { 468 switch (cmd) {
472 case TIOCGSERIAL: 469 case TIOCGSERIAL:
@@ -612,6 +609,3 @@ module_usb_serial_driver(serial_drivers, id_table);
612 609
613MODULE_DESCRIPTION(DRIVER_DESC); 610MODULE_DESCRIPTION(DRIVER_DESC);
614MODULE_LICENSE("GPL"); 611MODULE_LICENSE("GPL");
615
616module_param(debug, bool, S_IRUGO | S_IWUSR);
617MODULE_PARM_DESC(debug, "Debug enabled or not");
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index 5ce88d1bc6f1..30cff03e9f01 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -870,7 +870,8 @@ static const struct usb_device_id option_ids[] = {
870 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0153, 0xff, 0xff, 0xff) }, 870 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0153, 0xff, 0xff, 0xff) },
871 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0155, 0xff, 0xff, 0xff) }, 871 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0155, 0xff, 0xff, 0xff) },
872 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0156, 0xff, 0xff, 0xff) }, 872 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0156, 0xff, 0xff, 0xff) },
873 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0157, 0xff, 0xff, 0xff) }, 873 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0157, 0xff, 0xff, 0xff),
874 .driver_info = (kernel_ulong_t)&net_intf5_blacklist },
874 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0158, 0xff, 0xff, 0xff) }, 875 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0158, 0xff, 0xff, 0xff) },
875 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0159, 0xff, 0xff, 0xff) }, 876 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0159, 0xff, 0xff, 0xff) },
876 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0161, 0xff, 0xff, 0xff) }, 877 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0161, 0xff, 0xff, 0xff) },
@@ -1257,8 +1258,6 @@ static struct usb_serial_driver * const serial_drivers[] = {
1257 &option_1port_device, NULL 1258 &option_1port_device, NULL
1258}; 1259};
1259 1260
1260static bool debug;
1261
1262struct option_private { 1261struct option_private {
1263 u8 bInterfaceNumber; 1262 u8 bInterfaceNumber;
1264}; 1263};
@@ -1369,18 +1368,19 @@ static void option_instat_callback(struct urb *urb)
1369{ 1368{
1370 int err; 1369 int err;
1371 int status = urb->status; 1370 int status = urb->status;
1372 struct usb_serial_port *port = urb->context; 1371 struct usb_serial_port *port = urb->context;
1372 struct device *dev = &port->dev;
1373 struct usb_wwan_port_private *portdata = 1373 struct usb_wwan_port_private *portdata =
1374 usb_get_serial_port_data(port); 1374 usb_get_serial_port_data(port);
1375 1375
1376 dbg("%s: urb %p port %p has data %p", __func__, urb, port, portdata); 1376 dev_dbg(dev, "%s: urb %p port %p has data %p\n", __func__, urb, port, portdata);
1377 1377
1378 if (status == 0) { 1378 if (status == 0) {
1379 struct usb_ctrlrequest *req_pkt = 1379 struct usb_ctrlrequest *req_pkt =
1380 (struct usb_ctrlrequest *)urb->transfer_buffer; 1380 (struct usb_ctrlrequest *)urb->transfer_buffer;
1381 1381
1382 if (!req_pkt) { 1382 if (!req_pkt) {
1383 dbg("%s: NULL req_pkt", __func__); 1383 dev_dbg(dev, "%s: NULL req_pkt\n", __func__);
1384 return; 1384 return;
1385 } 1385 }
1386 if ((req_pkt->bRequestType == 0xA1) && 1386 if ((req_pkt->bRequestType == 0xA1) &&
@@ -1390,7 +1390,7 @@ static void option_instat_callback(struct urb *urb)
1390 urb->transfer_buffer + 1390 urb->transfer_buffer +
1391 sizeof(struct usb_ctrlrequest)); 1391 sizeof(struct usb_ctrlrequest));
1392 1392
1393 dbg("%s: signal x%x", __func__, signals); 1393 dev_dbg(dev, "%s: signal x%x\n", __func__, signals);
1394 1394
1395 old_dcd_state = portdata->dcd_state; 1395 old_dcd_state = portdata->dcd_state;
1396 portdata->cts_state = 1; 1396 portdata->cts_state = 1;
@@ -1406,17 +1406,17 @@ static void option_instat_callback(struct urb *urb)
1406 tty_kref_put(tty); 1406 tty_kref_put(tty);
1407 } 1407 }
1408 } else { 1408 } else {
1409 dbg("%s: type %x req %x", __func__, 1409 dev_dbg(dev, "%s: type %x req %x\n", __func__,
1410 req_pkt->bRequestType, req_pkt->bRequest); 1410 req_pkt->bRequestType, req_pkt->bRequest);
1411 } 1411 }
1412 } else 1412 } else
1413 dev_err(&port->dev, "%s: error %d\n", __func__, status); 1413 dev_err(dev, "%s: error %d\n", __func__, status);
1414 1414
1415 /* Resubmit urb so we continue receiving IRQ data */ 1415 /* Resubmit urb so we continue receiving IRQ data */
1416 if (status != -ESHUTDOWN && status != -ENOENT) { 1416 if (status != -ESHUTDOWN && status != -ENOENT) {
1417 err = usb_submit_urb(urb, GFP_ATOMIC); 1417 err = usb_submit_urb(urb, GFP_ATOMIC);
1418 if (err) 1418 if (err)
1419 dbg("%s: resubmit intr urb failed. (%d)", 1419 dev_dbg(dev, "%s: resubmit intr urb failed. (%d)\n",
1420 __func__, err); 1420 __func__, err);
1421 } 1421 }
1422} 1422}
@@ -1450,6 +1450,3 @@ MODULE_AUTHOR(DRIVER_AUTHOR);
1450MODULE_DESCRIPTION(DRIVER_DESC); 1450MODULE_DESCRIPTION(DRIVER_DESC);
1451MODULE_VERSION(DRIVER_VERSION); 1451MODULE_VERSION(DRIVER_VERSION);
1452MODULE_LICENSE("GPL"); 1452MODULE_LICENSE("GPL");
1453
1454module_param(debug, bool, S_IRUGO | S_IWUSR);
1455MODULE_PARM_DESC(debug, "Debug messages");
diff --git a/drivers/usb/serial/oti6858.c b/drivers/usb/serial/oti6858.c
index 9f555560bfbf..933241f03fd8 100644
--- a/drivers/usb/serial/oti6858.c
+++ b/drivers/usb/serial/oti6858.c
@@ -66,8 +66,6 @@ static const struct usb_device_id id_table[] = {
66 66
67MODULE_DEVICE_TABLE(usb, id_table); 67MODULE_DEVICE_TABLE(usb, id_table);
68 68
69static bool debug;
70
71/* requests */ 69/* requests */
72#define OTI6858_REQ_GET_STATUS (USB_DIR_IN | USB_TYPE_VENDOR | 0x00) 70#define OTI6858_REQ_GET_STATUS (USB_DIR_IN | USB_TYPE_VENDOR | 0x00)
73#define OTI6858_REQ_T_GET_STATUS 0x01 71#define OTI6858_REQ_T_GET_STATUS 0x01
@@ -256,11 +254,11 @@ static void setup_line(struct work_struct *work)
256 priv->setup_done = 1; 254 priv->setup_done = 1;
257 spin_unlock_irqrestore(&priv->lock, flags); 255 spin_unlock_irqrestore(&priv->lock, flags);
258 256
259 dbg("%s(): submitting interrupt urb", __func__); 257 dev_dbg(&port->dev, "%s(): submitting interrupt urb\n", __func__);
260 result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); 258 result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
261 if (result != 0) { 259 if (result != 0) {
262 dev_err(&port->dev, "%s(): usb_submit_urb() failed" 260 dev_err(&port->dev, "%s(): usb_submit_urb() failed with error %d\n",
263 " with error %d\n", __func__, result); 261 __func__, result);
264 } 262 }
265} 263}
266 264
@@ -310,11 +308,11 @@ static void send_data(struct work_struct *work)
310 if (count == 0) { 308 if (count == 0) {
311 priv->flags.write_urb_in_use = 0; 309 priv->flags.write_urb_in_use = 0;
312 310
313 dbg("%s(): submitting interrupt urb", __func__); 311 dev_dbg(&port->dev, "%s(): submitting interrupt urb\n", __func__);
314 result = usb_submit_urb(port->interrupt_in_urb, GFP_NOIO); 312 result = usb_submit_urb(port->interrupt_in_urb, GFP_NOIO);
315 if (result != 0) { 313 if (result != 0) {
316 dev_err(&port->dev, "%s(): usb_submit_urb() failed" 314 dev_err(&port->dev, "%s(): usb_submit_urb() failed with error %d\n",
317 " with error %d\n", __func__, result); 315 __func__, result);
318 } 316 }
319 return; 317 return;
320 } 318 }
@@ -325,8 +323,8 @@ static void send_data(struct work_struct *work)
325 port->write_urb->transfer_buffer_length = count; 323 port->write_urb->transfer_buffer_length = count;
326 result = usb_submit_urb(port->write_urb, GFP_NOIO); 324 result = usb_submit_urb(port->write_urb, GFP_NOIO);
327 if (result != 0) { 325 if (result != 0) {
328 dev_err_console(port, "%s(): usb_submit_urb() failed" 326 dev_err_console(port, "%s(): usb_submit_urb() failed with error %d\n",
329 " with error %d\n", __func__, result); 327 __func__, result);
330 priv->flags.write_urb_in_use = 0; 328 priv->flags.write_urb_in_use = 0;
331 } 329 }
332 330
@@ -420,10 +418,8 @@ static void oti6858_set_termios(struct tty_struct *tty,
420 __le16 divisor; 418 __le16 divisor;
421 int br; 419 int br;
422 420
423 if (!tty) { 421 if (!tty)
424 dbg("%s(): no tty structures", __func__);
425 return; 422 return;
426 }
427 423
428 cflag = tty->termios.c_cflag; 424 cflag = tty->termios.c_cflag;
429 425
@@ -560,11 +556,11 @@ static int oti6858_open(struct tty_struct *tty, struct usb_serial_port *port)
560 spin_unlock_irqrestore(&priv->lock, flags); 556 spin_unlock_irqrestore(&priv->lock, flags);
561 kfree(buf); 557 kfree(buf);
562 558
563 dbg("%s(): submitting interrupt urb", __func__); 559 dev_dbg(&port->dev, "%s(): submitting interrupt urb\n", __func__);
564 result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); 560 result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
565 if (result != 0) { 561 if (result != 0) {
566 dev_err(&port->dev, "%s(): usb_submit_urb() failed" 562 dev_err(&port->dev, "%s(): usb_submit_urb() failed with error %d\n",
567 " with error %d\n", __func__, result); 563 __func__, result);
568 oti6858_close(port); 564 oti6858_close(port);
569 return result; 565 return result;
570 } 566 }
@@ -586,14 +582,14 @@ static void oti6858_close(struct usb_serial_port *port)
586 kfifo_reset_out(&port->write_fifo); 582 kfifo_reset_out(&port->write_fifo);
587 spin_unlock_irqrestore(&port->lock, flags); 583 spin_unlock_irqrestore(&port->lock, flags);
588 584
589 dbg("%s(): after buf_clear()", __func__); 585 dev_dbg(&port->dev, "%s(): after buf_clear()\n", __func__);
590 586
591 /* cancel scheduled setup */ 587 /* cancel scheduled setup */
592 cancel_delayed_work_sync(&priv->delayed_setup_work); 588 cancel_delayed_work_sync(&priv->delayed_setup_work);
593 cancel_delayed_work_sync(&priv->delayed_write_work); 589 cancel_delayed_work_sync(&priv->delayed_write_work);
594 590
595 /* shutdown our urbs */ 591 /* shutdown our urbs */
596 dbg("%s(): shutting down urbs", __func__); 592 dev_dbg(&port->dev, "%s(): shutting down urbs\n", __func__);
597 usb_kill_urb(port->write_urb); 593 usb_kill_urb(port->write_urb);
598 usb_kill_urb(port->read_urb); 594 usb_kill_urb(port->read_urb);
599 usb_kill_urb(port->interrupt_in_urb); 595 usb_kill_urb(port->interrupt_in_urb);
@@ -607,8 +603,8 @@ static int oti6858_tiocmset(struct tty_struct *tty,
607 unsigned long flags; 603 unsigned long flags;
608 u8 control; 604 u8 control;
609 605
610 dbg("%s(port = %d, set = 0x%08x, clear = 0x%08x)", 606 dev_dbg(&port->dev, "%s(set = 0x%08x, clear = 0x%08x)\n",
611 __func__, port->number, set, clear); 607 __func__, set, clear);
612 608
613 /* FIXME: check if this is correct (active high/low) */ 609 /* FIXME: check if this is correct (active high/low) */
614 spin_lock_irqsave(&priv->lock, flags); 610 spin_lock_irqsave(&priv->lock, flags);
@@ -655,7 +651,7 @@ static int oti6858_tiocmget(struct tty_struct *tty)
655 if ((pin_state & PIN_DCD) != 0) 651 if ((pin_state & PIN_DCD) != 0)
656 result |= TIOCM_CD; 652 result |= TIOCM_CD;
657 653
658 dbg("%s() = 0x%08x", __func__, result); 654 dev_dbg(&port->dev, "%s() = 0x%08x\n", __func__, result);
659 655
660 return result; 656 return result;
661} 657}
@@ -700,15 +696,14 @@ static int oti6858_ioctl(struct tty_struct *tty,
700{ 696{
701 struct usb_serial_port *port = tty->driver_data; 697 struct usb_serial_port *port = tty->driver_data;
702 698
703 dbg("%s(port = %d, cmd = 0x%04x, arg = 0x%08lx)", 699 dev_dbg(&port->dev, "%s(cmd = 0x%04x, arg = 0x%08lx)\n", __func__, cmd, arg);
704 __func__, port->number, cmd, arg);
705 700
706 switch (cmd) { 701 switch (cmd) {
707 case TIOCMIWAIT: 702 case TIOCMIWAIT:
708 dbg("%s(): TIOCMIWAIT", __func__); 703 dev_dbg(&port->dev, "%s(): TIOCMIWAIT\n", __func__);
709 return wait_modem_info(port, arg); 704 return wait_modem_info(port, arg);
710 default: 705 default:
711 dbg("%s(): 0x%04x not supported", __func__, cmd); 706 dev_dbg(&port->dev, "%s(): 0x%04x not supported\n", __func__, cmd);
712 break; 707 break;
713 } 708 }
714 return -ENOIOCTLCMD; 709 return -ENOIOCTLCMD;
@@ -738,12 +733,12 @@ static void oti6858_read_int_callback(struct urb *urb)
738 case -ENOENT: 733 case -ENOENT:
739 case -ESHUTDOWN: 734 case -ESHUTDOWN:
740 /* this urb is terminated, clean up */ 735 /* this urb is terminated, clean up */
741 dbg("%s(): urb shutting down with status: %d", 736 dev_dbg(&urb->dev->dev, "%s(): urb shutting down with status: %d\n",
742 __func__, status); 737 __func__, status);
743 return; 738 return;
744 default: 739 default:
745 dbg("%s(): nonzero urb status received: %d", 740 dev_dbg(&urb->dev->dev, "%s(): nonzero urb status received: %d\n",
746 __func__, status); 741 __func__, status);
747 break; 742 break;
748 } 743 }
749 744
@@ -759,8 +754,7 @@ static void oti6858_read_int_callback(struct urb *urb)
759 priv->transient = 4; 754 priv->transient = 4;
760 priv->setup_done = 0; 755 priv->setup_done = 0;
761 resubmit = 0; 756 resubmit = 0;
762 dbg("%s(): scheduling setup_line()", 757 dev_dbg(&port->dev, "%s(): scheduling setup_line()\n", __func__);
763 __func__);
764 schedule_delayed_work(&priv->delayed_setup_work, 0); 758 schedule_delayed_work(&priv->delayed_setup_work, 0);
765 } 759 }
766 } 760 }
@@ -774,8 +768,7 @@ static void oti6858_read_int_callback(struct urb *urb)
774 priv->transient = 4; 768 priv->transient = 4;
775 priv->setup_done = 0; 769 priv->setup_done = 0;
776 resubmit = 0; 770 resubmit = 0;
777 dbg("%s(): scheduling setup_line()", 771 dev_dbg(&port->dev, "%s(): scheduling setup_line()\n", __func__);
778 __func__);
779 schedule_delayed_work(&priv->delayed_setup_work, 0); 772 schedule_delayed_work(&priv->delayed_setup_work, 0);
780 } 773 }
781 } 774 }
@@ -826,7 +819,7 @@ static void oti6858_read_int_callback(struct urb *urb)
826 if (resubmit) { 819 if (resubmit) {
827 int result; 820 int result;
828 821
829/* dbg("%s(): submitting interrupt urb", __func__); */ 822/* dev_dbg(&urb->dev->dev, "%s(): submitting interrupt urb\n", __func__); */
830 result = usb_submit_urb(urb, GFP_ATOMIC); 823 result = usb_submit_urb(urb, GFP_ATOMIC);
831 if (result != 0) { 824 if (result != 0) {
832 dev_err(&urb->dev->dev, 825 dev_err(&urb->dev->dev,
@@ -851,7 +844,7 @@ static void oti6858_read_bulk_callback(struct urb *urb)
851 spin_unlock_irqrestore(&priv->lock, flags); 844 spin_unlock_irqrestore(&priv->lock, flags);
852 845
853 if (status != 0) { 846 if (status != 0) {
854 dbg("%s(): unable to handle the error, exiting", __func__); 847 dev_dbg(&urb->dev->dev, "%s(): unable to handle the error, exiting\n", __func__);
855 return; 848 return;
856 } 849 }
857 850
@@ -885,15 +878,13 @@ static void oti6858_write_bulk_callback(struct urb *urb)
885 case -ENOENT: 878 case -ENOENT:
886 case -ESHUTDOWN: 879 case -ESHUTDOWN:
887 /* this urb is terminated, clean up */ 880 /* this urb is terminated, clean up */
888 dbg("%s(): urb shutting down with status: %d", 881 dev_dbg(&urb->dev->dev, "%s(): urb shutting down with status: %d\n", __func__, status);
889 __func__, status);
890 priv->flags.write_urb_in_use = 0; 882 priv->flags.write_urb_in_use = 0;
891 return; 883 return;
892 default: 884 default:
893 /* error in the urb, so we have to resubmit it */ 885 /* error in the urb, so we have to resubmit it */
894 dbg("%s(): nonzero write bulk status received: %d", 886 dev_dbg(&urb->dev->dev, "%s(): nonzero write bulk status received: %d\n", __func__, status);
895 __func__, status); 887 dev_dbg(&urb->dev->dev, "%s(): overflow in write\n", __func__);
896 dbg("%s(): overflow in write", __func__);
897 888
898 port->write_urb->transfer_buffer_length = 1; 889 port->write_urb->transfer_buffer_length = 1;
899 result = usb_submit_urb(port->write_urb, GFP_ATOMIC); 890 result = usb_submit_urb(port->write_urb, GFP_ATOMIC);
@@ -908,7 +899,7 @@ static void oti6858_write_bulk_callback(struct urb *urb)
908 priv->flags.write_urb_in_use = 0; 899 priv->flags.write_urb_in_use = 0;
909 900
910 /* schedule the interrupt urb if we are still open */ 901 /* schedule the interrupt urb if we are still open */
911 dbg("%s(): submitting interrupt urb", __func__); 902 dev_dbg(&port->dev, "%s(): submitting interrupt urb\n", __func__);
912 result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); 903 result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC);
913 if (result != 0) { 904 if (result != 0) {
914 dev_err(&port->dev, "%s(): failed submitting int urb," 905 dev_err(&port->dev, "%s(): failed submitting int urb,"
@@ -922,7 +913,3 @@ MODULE_DESCRIPTION(OTI6858_DESCRIPTION);
922MODULE_AUTHOR(OTI6858_AUTHOR); 913MODULE_AUTHOR(OTI6858_AUTHOR);
923MODULE_VERSION(OTI6858_VERSION); 914MODULE_VERSION(OTI6858_VERSION);
924MODULE_LICENSE("GPL"); 915MODULE_LICENSE("GPL");
925
926module_param(debug, bool, S_IRUGO | S_IWUSR);
927MODULE_PARM_DESC(debug, "enable debug output");
928
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index 2b9108a8ea64..892ebdc7a364 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -36,8 +36,6 @@
36 */ 36 */
37#define DRIVER_DESC "Prolific PL2303 USB to serial adaptor driver" 37#define DRIVER_DESC "Prolific PL2303 USB to serial adaptor driver"
38 38
39static bool debug;
40
41static const struct usb_device_id id_table[] = { 39static const struct usb_device_id id_table[] = {
42 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID) }, 40 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID) },
43 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_RSAQ2) }, 41 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_RSAQ2) },
@@ -741,7 +739,7 @@ static void pl2303_read_int_callback(struct urb *urb)
741 goto exit; 739 goto exit;
742 } 740 }
743 741
744 usb_serial_debug_data(debug, &port->dev, __func__, 742 usb_serial_debug_data(&port->dev, __func__,
745 urb->actual_length, urb->transfer_buffer); 743 urb->actual_length, urb->transfer_buffer);
746 744
747 pl2303_update_line_status(port, data, actual_length); 745 pl2303_update_line_status(port, data, actual_length);
@@ -839,7 +837,3 @@ module_usb_serial_driver(serial_drivers, id_table);
839 837
840MODULE_DESCRIPTION(DRIVER_DESC); 838MODULE_DESCRIPTION(DRIVER_DESC);
841MODULE_LICENSE("GPL"); 839MODULE_LICENSE("GPL");
842
843module_param(debug, bool, S_IRUGO | S_IWUSR);
844MODULE_PARM_DESC(debug, "Debug enabled or not");
845
diff --git a/drivers/usb/serial/qcaux.c b/drivers/usb/serial/qcaux.c
index a4edc7ee9c8a..9b1b96f2d095 100644
--- a/drivers/usb/serial/qcaux.c
+++ b/drivers/usb/serial/qcaux.c
@@ -36,8 +36,6 @@
36#define UTSTARCOM_PRODUCT_UM175_V1 0x3712 36#define UTSTARCOM_PRODUCT_UM175_V1 0x3712
37#define UTSTARCOM_PRODUCT_UM175_V2 0x3714 37#define UTSTARCOM_PRODUCT_UM175_V2 0x3714
38#define UTSTARCOM_PRODUCT_UM175_ALLTEL 0x3715 38#define UTSTARCOM_PRODUCT_UM175_ALLTEL 0x3715
39#define PANTECH_PRODUCT_UML190_VZW 0x3716
40#define PANTECH_PRODUCT_UML290_VZW 0x3718
41 39
42/* CMOTECH devices */ 40/* CMOTECH devices */
43#define CMOTECH_VENDOR_ID 0x16d8 41#define CMOTECH_VENDOR_ID 0x16d8
@@ -68,11 +66,9 @@ static struct usb_device_id id_table[] = {
68 { USB_DEVICE_AND_INTERFACE_INFO(LG_VENDOR_ID, LG_PRODUCT_VX4400_6000, 0xff, 0xff, 0x00) }, 66 { USB_DEVICE_AND_INTERFACE_INFO(LG_VENDOR_ID, LG_PRODUCT_VX4400_6000, 0xff, 0xff, 0x00) },
69 { USB_DEVICE_AND_INTERFACE_INFO(SANYO_VENDOR_ID, SANYO_PRODUCT_KATANA_LX, 0xff, 0xff, 0x00) }, 67 { USB_DEVICE_AND_INTERFACE_INFO(SANYO_VENDOR_ID, SANYO_PRODUCT_KATANA_LX, 0xff, 0xff, 0x00) },
70 { USB_DEVICE_AND_INTERFACE_INFO(SAMSUNG_VENDOR_ID, SAMSUNG_PRODUCT_U520, 0xff, 0x00, 0x00) }, 68 { USB_DEVICE_AND_INTERFACE_INFO(SAMSUNG_VENDOR_ID, SAMSUNG_PRODUCT_U520, 0xff, 0x00, 0x00) },
71 { USB_DEVICE_AND_INTERFACE_INFO(UTSTARCOM_VENDOR_ID, PANTECH_PRODUCT_UML190_VZW, 0xff, 0xff, 0xff) }, 69 { USB_VENDOR_AND_INTERFACE_INFO(UTSTARCOM_VENDOR_ID, 0xff, 0xfd, 0xff) }, /* NMEA */
72 { USB_DEVICE_AND_INTERFACE_INFO(UTSTARCOM_VENDOR_ID, PANTECH_PRODUCT_UML190_VZW, 0xff, 0xfe, 0xff) }, 70 { USB_VENDOR_AND_INTERFACE_INFO(UTSTARCOM_VENDOR_ID, 0xff, 0xfe, 0xff) }, /* WMC */
73 { USB_DEVICE_AND_INTERFACE_INFO(UTSTARCOM_VENDOR_ID, PANTECH_PRODUCT_UML290_VZW, 0xff, 0xfd, 0xff) }, /* NMEA */ 71 { USB_VENDOR_AND_INTERFACE_INFO(UTSTARCOM_VENDOR_ID, 0xff, 0xff, 0xff) }, /* DIAG */
74 { USB_DEVICE_AND_INTERFACE_INFO(UTSTARCOM_VENDOR_ID, PANTECH_PRODUCT_UML290_VZW, 0xff, 0xfe, 0xff) }, /* WMC */
75 { USB_DEVICE_AND_INTERFACE_INFO(UTSTARCOM_VENDOR_ID, PANTECH_PRODUCT_UML290_VZW, 0xff, 0xff, 0xff) }, /* DIAG */
76 { }, 72 { },
77}; 73};
78MODULE_DEVICE_TABLE(usb, id_table); 74MODULE_DEVICE_TABLE(usb, id_table);
diff --git a/drivers/usb/serial/qcserial.c b/drivers/usb/serial/qcserial.c
index bfd50779f0c9..c3ddb65c05f2 100644
--- a/drivers/usb/serial/qcserial.c
+++ b/drivers/usb/serial/qcserial.c
@@ -22,8 +22,6 @@
22#define DRIVER_AUTHOR "Qualcomm Inc" 22#define DRIVER_AUTHOR "Qualcomm Inc"
23#define DRIVER_DESC "Qualcomm USB Serial driver" 23#define DRIVER_DESC "Qualcomm USB Serial driver"
24 24
25static bool debug;
26
27#define DEVICE_G1K(v, p) \ 25#define DEVICE_G1K(v, p) \
28 USB_DEVICE(v, p), .driver_info = 1 26 USB_DEVICE(v, p), .driver_info = 1
29 27
@@ -305,6 +303,3 @@ module_usb_serial_driver(serial_drivers, id_table);
305MODULE_AUTHOR(DRIVER_AUTHOR); 303MODULE_AUTHOR(DRIVER_AUTHOR);
306MODULE_DESCRIPTION(DRIVER_DESC); 304MODULE_DESCRIPTION(DRIVER_DESC);
307MODULE_LICENSE("GPL v2"); 305MODULE_LICENSE("GPL v2");
308
309module_param(debug, bool, S_IRUGO | S_IWUSR);
310MODULE_PARM_DESC(debug, "Debug enabled or not");
diff --git a/drivers/usb/serial/quatech2.c b/drivers/usb/serial/quatech2.c
index 7df9cdb053ed..2cdfdcc90b37 100644
--- a/drivers/usb/serial/quatech2.c
+++ b/drivers/usb/serial/quatech2.c
@@ -27,8 +27,6 @@
27#include <linux/serial_reg.h> 27#include <linux/serial_reg.h>
28#include <linux/uaccess.h> 28#include <linux/uaccess.h>
29 29
30static bool debug;
31
32/* default urb timeout for usb operations */ 30/* default urb timeout for usb operations */
33#define QT2_USB_TIMEOUT USB_CTRL_SET_TIMEOUT 31#define QT2_USB_TIMEOUT USB_CTRL_SET_TIMEOUT
34 32
@@ -1089,7 +1087,7 @@ static int qt2_write(struct tty_struct *tty,
1089 data = write_urb->transfer_buffer; 1087 data = write_urb->transfer_buffer;
1090 spin_lock_irqsave(&port_priv->urb_lock, flags); 1088 spin_lock_irqsave(&port_priv->urb_lock, flags);
1091 if (port_priv->urb_in_use == true) { 1089 if (port_priv->urb_in_use == true) {
1092 printk(KERN_INFO "qt2_write - urb is in use\n"); 1090 dev_err(&port->dev, "qt2_write - urb is in use\n");
1093 goto write_out; 1091 goto write_out;
1094 } 1092 }
1095 1093
@@ -1146,6 +1144,3 @@ module_usb_serial_driver(serial_drivers, id_table);
1146 1144
1147MODULE_DESCRIPTION(DRIVER_DESC); 1145MODULE_DESCRIPTION(DRIVER_DESC);
1148MODULE_LICENSE("GPL"); 1146MODULE_LICENSE("GPL");
1149
1150module_param(debug, bool, S_IRUGO | S_IWUSR);
1151MODULE_PARM_DESC(debug, "Debug enabled or not");
diff --git a/drivers/usb/serial/safe_serial.c b/drivers/usb/serial/safe_serial.c
index 36e9d9fc0618..c949ce6ef0c6 100644
--- a/drivers/usb/serial/safe_serial.c
+++ b/drivers/usb/serial/safe_serial.c
@@ -62,6 +62,7 @@
62 * 62 *
63 */ 63 */
64 64
65#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
65 66
66#include <linux/kernel.h> 67#include <linux/kernel.h>
67#include <linux/errno.h> 68#include <linux/errno.h>
@@ -81,11 +82,9 @@
81#define CONFIG_USB_SERIAL_SAFE_PADDED 0 82#define CONFIG_USB_SERIAL_SAFE_PADDED 0
82#endif 83#endif
83 84
84static bool debug;
85static bool safe = 1; 85static bool safe = 1;
86static bool padded = CONFIG_USB_SERIAL_SAFE_PADDED; 86static bool padded = CONFIG_USB_SERIAL_SAFE_PADDED;
87 87
88#define DRIVER_VERSION "v0.1"
89#define DRIVER_AUTHOR "sl@lineo.com, tbr@lineo.com, Johan Hovold <jhovold@gmail.com>" 88#define DRIVER_AUTHOR "sl@lineo.com, tbr@lineo.com, Johan Hovold <jhovold@gmail.com>"
90#define DRIVER_DESC "USB Safe Encapsulated Serial" 89#define DRIVER_DESC "USB Safe Encapsulated Serial"
91 90
@@ -100,9 +99,6 @@ MODULE_PARM_DESC(vendor, "User specified USB idVendor (required)");
100module_param(product, ushort, 0); 99module_param(product, ushort, 0);
101MODULE_PARM_DESC(product, "User specified USB idProduct (required)"); 100MODULE_PARM_DESC(product, "User specified USB idProduct (required)");
102 101
103module_param(debug, bool, S_IRUGO | S_IWUSR);
104MODULE_PARM_DESC(debug, "Debug enabled or not");
105
106module_param(safe, bool, 0); 102module_param(safe, bool, 0);
107MODULE_PARM_DESC(safe, "Turn Safe Encapsulation On/Off"); 103MODULE_PARM_DESC(safe, "Turn Safe Encapsulation On/Off");
108 104
@@ -315,13 +311,9 @@ static int __init safe_init(void)
315{ 311{
316 int i; 312 int i;
317 313
318 printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":"
319 DRIVER_DESC "\n");
320
321 /* if we have vendor / product parameters patch them into id list */ 314 /* if we have vendor / product parameters patch them into id list */
322 if (vendor || product) { 315 if (vendor || product) {
323 printk(KERN_INFO KBUILD_MODNAME ": vendor: %x product: %x\n", 316 pr_info("vendor: %x product: %x\n", vendor, product);
324 vendor, product);
325 317
326 for (i = 0; i < ARRAY_SIZE(id_table); i++) { 318 for (i = 0; i < ARRAY_SIZE(id_table); i++) {
327 if (!id_table[i].idVendor && !id_table[i].idProduct) { 319 if (!id_table[i].idVendor && !id_table[i].idProduct) {
diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c
index b14ebbd73567..01d882cf3775 100644
--- a/drivers/usb/serial/sierra.c
+++ b/drivers/usb/serial/sierra.c
@@ -46,7 +46,6 @@
46 allocations > PAGE_SIZE and the number of packets in a page 46 allocations > PAGE_SIZE and the number of packets in a page
47 is an integer 512 is the largest possible packet on EHCI */ 47 is an integer 512 is the largest possible packet on EHCI */
48 48
49static bool debug;
50static bool nmea; 49static bool nmea;
51 50
52/* Used in interface blacklisting */ 51/* Used in interface blacklisting */
@@ -518,7 +517,7 @@ static int sierra_write(struct tty_struct *tty, struct usb_serial_port *port,
518 517
519 memcpy(buffer, buf, writesize); 518 memcpy(buffer, buf, writesize);
520 519
521 usb_serial_debug_data(debug, &port->dev, __func__, writesize, buffer); 520 usb_serial_debug_data(&port->dev, __func__, writesize, buffer);
522 521
523 usb_fill_bulk_urb(urb, serial->dev, 522 usb_fill_bulk_urb(urb, serial->dev,
524 usb_sndbulkpipe(serial->dev, 523 usb_sndbulkpipe(serial->dev,
@@ -595,8 +594,8 @@ static void sierra_indat_callback(struct urb *urb)
595 tty_flip_buffer_push(tty); 594 tty_flip_buffer_push(tty);
596 595
597 tty_kref_put(tty); 596 tty_kref_put(tty);
598 usb_serial_debug_data(debug, &port->dev, 597 usb_serial_debug_data(&port->dev, __func__,
599 __func__, urb->actual_length, data); 598 urb->actual_length, data);
600 } 599 }
601 } else { 600 } else {
602 dev_dbg(&port->dev, "%s: empty read urb" 601 dev_dbg(&port->dev, "%s: empty read urb"
@@ -765,7 +764,6 @@ static struct urb *sierra_setup_urb(struct usb_serial *serial, int endpoint,
765 usb_sndbulkpipe(serial->dev, endpoint) | dir, 764 usb_sndbulkpipe(serial->dev, endpoint) | dir,
766 buf, len, callback, ctx); 765 buf, len, callback, ctx);
767 766
768 /* debug */
769 dev_dbg(&serial->dev->dev, "%s %c u : %p d:%p\n", __func__, 767 dev_dbg(&serial->dev->dev, "%s %c u : %p d:%p\n", __func__,
770 dir == USB_DIR_IN ? 'i' : 'o', urb, buf); 768 dir == USB_DIR_IN ? 'i' : 'o', urb, buf);
771 } else { 769 } else {
@@ -1082,6 +1080,3 @@ MODULE_LICENSE("GPL");
1082 1080
1083module_param(nmea, bool, S_IRUGO | S_IWUSR); 1081module_param(nmea, bool, S_IRUGO | S_IWUSR);
1084MODULE_PARM_DESC(nmea, "NMEA streaming"); 1082MODULE_PARM_DESC(nmea, "NMEA streaming");
1085
1086module_param(debug, bool, S_IRUGO | S_IWUSR);
1087MODULE_PARM_DESC(debug, "Debug messages");
diff --git a/drivers/usb/serial/spcp8x5.c b/drivers/usb/serial/spcp8x5.c
index ab68a4d74d61..9716efe92955 100644
--- a/drivers/usb/serial/spcp8x5.c
+++ b/drivers/usb/serial/spcp8x5.c
@@ -33,8 +33,6 @@
33#define DRIVER_VERSION "v0.10" 33#define DRIVER_VERSION "v0.10"
34#define DRIVER_DESC "SPCP8x5 USB to serial adaptor driver" 34#define DRIVER_DESC "SPCP8x5 USB to serial adaptor driver"
35 35
36static bool debug;
37
38#define SPCP8x5_007_VID 0x04FC 36#define SPCP8x5_007_VID 0x04FC
39#define SPCP8x5_007_PID 0x0201 37#define SPCP8x5_007_PID 0x0201
40#define SPCP8x5_008_VID 0x04fc 38#define SPCP8x5_008_VID 0x04fc
@@ -665,6 +663,3 @@ module_usb_serial_driver(serial_drivers, id_table);
665MODULE_DESCRIPTION(DRIVER_DESC); 663MODULE_DESCRIPTION(DRIVER_DESC);
666MODULE_VERSION(DRIVER_VERSION); 664MODULE_VERSION(DRIVER_VERSION);
667MODULE_LICENSE("GPL"); 665MODULE_LICENSE("GPL");
668
669module_param(debug, bool, S_IRUGO | S_IWUSR);
670MODULE_PARM_DESC(debug, "Debug enabled or not");
diff --git a/drivers/usb/serial/ssu100.c b/drivers/usb/serial/ssu100.c
index cf2d30cf7588..015810b3785b 100644
--- a/drivers/usb/serial/ssu100.c
+++ b/drivers/usb/serial/ssu100.c
@@ -46,8 +46,6 @@
46#define FULLPWRBIT 0x00000080 46#define FULLPWRBIT 0x00000080
47#define NEXT_BOARD_POWER_BIT 0x00000004 47#define NEXT_BOARD_POWER_BIT 0x00000004
48 48
49static bool debug;
50
51/* Version Information */ 49/* Version Information */
52#define DRIVER_VERSION "v0.1" 50#define DRIVER_VERSION "v0.1"
53#define DRIVER_DESC "Quatech SSU-100 USB to Serial Driver" 51#define DRIVER_DESC "Quatech SSU-100 USB to Serial Driver"
@@ -135,7 +133,7 @@ static inline int update_mctrl(struct usb_device *dev, unsigned int set,
135 int result; 133 int result;
136 134
137 if (((set | clear) & (TIOCM_DTR | TIOCM_RTS)) == 0) { 135 if (((set | clear) & (TIOCM_DTR | TIOCM_RTS)) == 0) {
138 dbg("%s - DTR|RTS not being set|cleared", __func__); 136 dev_dbg(&dev->dev, "%s - DTR|RTS not being set|cleared\n", __func__);
139 return 0; /* no change */ 137 return 0; /* no change */
140 } 138 }
141 139
@@ -148,7 +146,7 @@ static inline int update_mctrl(struct usb_device *dev, unsigned int set,
148 146
149 result = ssu100_setregister(dev, 0, UART_MCR, urb_value); 147 result = ssu100_setregister(dev, 0, UART_MCR, urb_value);
150 if (result < 0) 148 if (result < 0)
151 dbg("%s Error from MODEM_CTRL urb", __func__); 149 dev_dbg(&dev->dev, "%s Error from MODEM_CTRL urb\n", __func__);
152 150
153 return result; 151 return result;
154} 152}
@@ -164,7 +162,7 @@ static int ssu100_initdevice(struct usb_device *dev)
164 162
165 result = ssu100_getdevice(dev, data); 163 result = ssu100_getdevice(dev, data);
166 if (result < 0) { 164 if (result < 0) {
167 dbg("%s - get_device failed %i", __func__, result); 165 dev_dbg(&dev->dev, "%s - get_device failed %i\n", __func__, result);
168 goto out; 166 goto out;
169 } 167 }
170 168
@@ -172,25 +170,25 @@ static int ssu100_initdevice(struct usb_device *dev)
172 170
173 result = ssu100_setdevice(dev, data); 171 result = ssu100_setdevice(dev, data);
174 if (result < 0) { 172 if (result < 0) {
175 dbg("%s - setdevice failed %i", __func__, result); 173 dev_dbg(&dev->dev, "%s - setdevice failed %i\n", __func__, result);
176 goto out; 174 goto out;
177 } 175 }
178 176
179 result = ssu100_control_msg(dev, QT_GET_SET_PREBUF_TRIG_LVL, 128, 0); 177 result = ssu100_control_msg(dev, QT_GET_SET_PREBUF_TRIG_LVL, 128, 0);
180 if (result < 0) { 178 if (result < 0) {
181 dbg("%s - set prebuffer level failed %i", __func__, result); 179 dev_dbg(&dev->dev, "%s - set prebuffer level failed %i\n", __func__, result);
182 goto out; 180 goto out;
183 } 181 }
184 182
185 result = ssu100_control_msg(dev, QT_SET_ATF, ATC_DISABLED, 0); 183 result = ssu100_control_msg(dev, QT_SET_ATF, ATC_DISABLED, 0);
186 if (result < 0) { 184 if (result < 0) {
187 dbg("%s - set ATFprebuffer level failed %i", __func__, result); 185 dev_dbg(&dev->dev, "%s - set ATFprebuffer level failed %i\n", __func__, result);
188 goto out; 186 goto out;
189 } 187 }
190 188
191 result = ssu100_getdevice(dev, data); 189 result = ssu100_getdevice(dev, data);
192 if (result < 0) { 190 if (result < 0) {
193 dbg("%s - get_device failed %i", __func__, result); 191 dev_dbg(&dev->dev, "%s - get_device failed %i\n", __func__, result);
194 goto out; 192 goto out;
195 } 193 }
196 194
@@ -201,7 +199,7 @@ static int ssu100_initdevice(struct usb_device *dev)
201 199
202 result = ssu100_setdevice(dev, data); 200 result = ssu100_setdevice(dev, data);
203 if (result < 0) { 201 if (result < 0) {
204 dbg("%s - setdevice failed %i", __func__, result); 202 dev_dbg(&dev->dev, "%s - setdevice failed %i\n", __func__, result);
205 goto out; 203 goto out;
206 } 204 }
207 205
@@ -249,7 +247,7 @@ static void ssu100_set_termios(struct tty_struct *tty,
249 if (!baud) 247 if (!baud)
250 baud = 9600; 248 baud = 9600;
251 249
252 dbg("%s - got baud = %d\n", __func__, baud); 250 dev_dbg(&port->dev, "%s - got baud = %d\n", __func__, baud);
253 251
254 252
255 divisor = MAX_BAUD_RATE / baud; 253 divisor = MAX_BAUD_RATE / baud;
@@ -261,7 +259,7 @@ static void ssu100_set_termios(struct tty_struct *tty,
261 259
262 result = ssu100_control_msg(dev, QT_GET_SET_UART, divisor, urb_value); 260 result = ssu100_control_msg(dev, QT_GET_SET_UART, divisor, urb_value);
263 if (result < 0) 261 if (result < 0)
264 dbg("%s - set uart failed", __func__); 262 dev_dbg(&port->dev, "%s - set uart failed\n", __func__);
265 263
266 if (cflag & CRTSCTS) 264 if (cflag & CRTSCTS)
267 result = ssu100_control_msg(dev, QT_HW_FLOW_CONTROL_MASK, 265 result = ssu100_control_msg(dev, QT_HW_FLOW_CONTROL_MASK,
@@ -270,7 +268,7 @@ static void ssu100_set_termios(struct tty_struct *tty,
270 result = ssu100_control_msg(dev, QT_HW_FLOW_CONTROL_MASK, 268 result = ssu100_control_msg(dev, QT_HW_FLOW_CONTROL_MASK,
271 0, 0); 269 0, 0);
272 if (result < 0) 270 if (result < 0)
273 dbg("%s - set HW flow control failed", __func__); 271 dev_dbg(&port->dev, "%s - set HW flow control failed\n", __func__);
274 272
275 if (I_IXOFF(tty) || I_IXON(tty)) { 273 if (I_IXOFF(tty) || I_IXON(tty)) {
276 u16 x = ((u16)(START_CHAR(tty) << 8) | (u16)(STOP_CHAR(tty))); 274 u16 x = ((u16)(START_CHAR(tty) << 8) | (u16)(STOP_CHAR(tty)));
@@ -282,7 +280,7 @@ static void ssu100_set_termios(struct tty_struct *tty,
282 0, 0); 280 0, 0);
283 281
284 if (result < 0) 282 if (result < 0)
285 dbg("%s - set SW flow control failed", __func__); 283 dev_dbg(&port->dev, "%s - set SW flow control failed\n", __func__);
286 284
287} 285}
288 286
@@ -304,7 +302,7 @@ static int ssu100_open(struct tty_struct *tty, struct usb_serial_port *port)
304 QT_TRANSFER_IN, 0x01, 302 QT_TRANSFER_IN, 0x01,
305 0, data, 2, 300); 303 0, data, 2, 300);
306 if (result < 0) { 304 if (result < 0) {
307 dbg("%s - open failed %i", __func__, result); 305 dev_dbg(&port->dev, "%s - open failed %i\n", __func__, result);
308 kfree(data); 306 kfree(data);
309 return result; 307 return result;
310 } 308 }
@@ -319,7 +317,7 @@ static int ssu100_open(struct tty_struct *tty, struct usb_serial_port *port)
319/* set to 9600 */ 317/* set to 9600 */
320 result = ssu100_control_msg(dev, QT_GET_SET_UART, 0x30, 0x0300); 318 result = ssu100_control_msg(dev, QT_GET_SET_UART, 0x30, 0x0300);
321 if (result < 0) 319 if (result < 0)
322 dbg("%s - set uart failed", __func__); 320 dev_dbg(&port->dev, "%s - set uart failed\n", __func__);
323 321
324 if (tty) 322 if (tty)
325 ssu100_set_termios(tty, port, &tty->termios); 323 ssu100_set_termios(tty, port, &tty->termios);
@@ -423,7 +421,7 @@ static int ssu100_ioctl(struct tty_struct *tty,
423{ 421{
424 struct usb_serial_port *port = tty->driver_data; 422 struct usb_serial_port *port = tty->driver_data;
425 423
426 dbg("%s cmd 0x%04x", __func__, cmd); 424 dev_dbg(&port->dev, "%s cmd 0x%04x\n", __func__, cmd);
427 425
428 switch (cmd) { 426 switch (cmd) {
429 case TIOCGSERIAL: 427 case TIOCGSERIAL:
@@ -437,7 +435,7 @@ static int ssu100_ioctl(struct tty_struct *tty,
437 break; 435 break;
438 } 436 }
439 437
440 dbg("%s arg not supported", __func__); 438 dev_dbg(&port->dev, "%s arg not supported\n", __func__);
441 439
442 return -ENOIOCTLCMD; 440 return -ENOIOCTLCMD;
443} 441}
@@ -668,6 +666,3 @@ module_usb_serial_driver(serial_drivers, id_table);
668 666
669MODULE_DESCRIPTION(DRIVER_DESC); 667MODULE_DESCRIPTION(DRIVER_DESC);
670MODULE_LICENSE("GPL"); 668MODULE_LICENSE("GPL");
671
672module_param(debug, bool, S_IRUGO | S_IWUSR);
673MODULE_PARM_DESC(debug, "Debug enabled or not");
diff --git a/drivers/usb/serial/symbolserial.c b/drivers/usb/serial/symbolserial.c
index e53d2aac35c5..701fffa8431f 100644
--- a/drivers/usb/serial/symbolserial.c
+++ b/drivers/usb/serial/symbolserial.c
@@ -20,8 +20,6 @@
20#include <linux/usb/serial.h> 20#include <linux/usb/serial.h>
21#include <linux/uaccess.h> 21#include <linux/uaccess.h>
22 22
23static bool debug;
24
25static const struct usb_device_id id_table[] = { 23static const struct usb_device_id id_table[] = {
26 { USB_DEVICE(0x05e0, 0x0600) }, 24 { USB_DEVICE(0x05e0, 0x0600) },
27 { }, 25 { },
@@ -71,8 +69,7 @@ static void symbol_int_callback(struct urb *urb)
71 goto exit; 69 goto exit;
72 } 70 }
73 71
74 usb_serial_debug_data(debug, &port->dev, __func__, urb->actual_length, 72 usb_serial_debug_data(&port->dev, __func__, urb->actual_length, data);
75 data);
76 73
77 if (urb->actual_length > 1) { 74 if (urb->actual_length > 1) {
78 data_length = urb->actual_length - 1; 75 data_length = urb->actual_length - 1;
@@ -292,6 +289,3 @@ static struct usb_serial_driver * const serial_drivers[] = {
292module_usb_serial_driver(serial_drivers, id_table); 289module_usb_serial_driver(serial_drivers, id_table);
293 290
294MODULE_LICENSE("GPL"); 291MODULE_LICENSE("GPL");
295
296module_param(debug, bool, S_IRUGO | S_IWUSR);
297MODULE_PARM_DESC(debug, "Debug enabled or not");
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c
index f502a16aac21..6f49392cda5b 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.c
+++ b/drivers/usb/serial/ti_usb_3410_5052.c
@@ -40,7 +40,6 @@
40 40
41/* Defines */ 41/* Defines */
42 42
43#define TI_DRIVER_VERSION "v0.10"
44#define TI_DRIVER_AUTHOR "Al Borchers <alborchers@steinerpoint.com>" 43#define TI_DRIVER_AUTHOR "Al Borchers <alborchers@steinerpoint.com>"
45#define TI_DRIVER_DESC "TI USB 3410/5052 Serial Driver" 44#define TI_DRIVER_DESC "TI USB 3410/5052 Serial Driver"
46 45
@@ -141,8 +140,8 @@ static int ti_command_out_sync(struct ti_device *tdev, __u8 command,
141static int ti_command_in_sync(struct ti_device *tdev, __u8 command, 140static int ti_command_in_sync(struct ti_device *tdev, __u8 command,
142 __u16 moduleid, __u16 value, __u8 *data, int size); 141 __u16 moduleid, __u16 value, __u8 *data, int size);
143 142
144static int ti_write_byte(struct ti_device *tdev, unsigned long addr, 143static int ti_write_byte(struct usb_serial_port *port, struct ti_device *tdev,
145 __u8 mask, __u8 byte); 144 unsigned long addr, __u8 mask, __u8 byte);
146 145
147static int ti_download_firmware(struct ti_device *tdev); 146static int ti_download_firmware(struct ti_device *tdev);
148 147
@@ -150,7 +149,6 @@ static int ti_download_firmware(struct ti_device *tdev);
150/* Data */ 149/* Data */
151 150
152/* module parameters */ 151/* module parameters */
153static bool debug;
154static int closing_wait = TI_DEFAULT_CLOSING_WAIT; 152static int closing_wait = TI_DEFAULT_CLOSING_WAIT;
155static ushort vendor_3410[TI_EXTRA_VID_PID_COUNT]; 153static ushort vendor_3410[TI_EXTRA_VID_PID_COUNT];
156static unsigned int vendor_3410_count; 154static unsigned int vendor_3410_count;
@@ -277,7 +275,6 @@ static struct usb_serial_driver * const serial_drivers[] = {
277 275
278MODULE_AUTHOR(TI_DRIVER_AUTHOR); 276MODULE_AUTHOR(TI_DRIVER_AUTHOR);
279MODULE_DESCRIPTION(TI_DRIVER_DESC); 277MODULE_DESCRIPTION(TI_DRIVER_DESC);
280MODULE_VERSION(TI_DRIVER_VERSION);
281MODULE_LICENSE("GPL"); 278MODULE_LICENSE("GPL");
282 279
283MODULE_FIRMWARE("ti_3410.fw"); 280MODULE_FIRMWARE("ti_3410.fw");
@@ -288,9 +285,6 @@ MODULE_FIRMWARE("mts_edge.fw");
288MODULE_FIRMWARE("mts_mt9234mu.fw"); 285MODULE_FIRMWARE("mts_mt9234mu.fw");
289MODULE_FIRMWARE("mts_mt9234zba.fw"); 286MODULE_FIRMWARE("mts_mt9234zba.fw");
290 287
291module_param(debug, bool, S_IRUGO | S_IWUSR);
292MODULE_PARM_DESC(debug, "Enable debugging, 0=no, 1=yes");
293
294module_param(closing_wait, int, S_IRUGO | S_IWUSR); 288module_param(closing_wait, int, S_IRUGO | S_IWUSR);
295MODULE_PARM_DESC(closing_wait, 289MODULE_PARM_DESC(closing_wait,
296 "Maximum wait for data to drain in close, in .01 secs, default is 4000"); 290 "Maximum wait for data to drain in close, in .01 secs, default is 4000");
@@ -316,7 +310,6 @@ MODULE_DEVICE_TABLE(usb, ti_id_table_combined);
316static int __init ti_init(void) 310static int __init ti_init(void)
317{ 311{
318 int i, j, c; 312 int i, j, c;
319 int ret;
320 313
321 /* insert extra vendor and product ids */ 314 /* insert extra vendor and product ids */
322 c = ARRAY_SIZE(ti_id_table_combined) - 2 * TI_EXTRA_VID_PID_COUNT - 1; 315 c = ARRAY_SIZE(ti_id_table_combined) - 2 * TI_EXTRA_VID_PID_COUNT - 1;
@@ -339,11 +332,7 @@ static int __init ti_init(void)
339 ti_id_table_combined[c].match_flags = USB_DEVICE_ID_MATCH_DEVICE; 332 ti_id_table_combined[c].match_flags = USB_DEVICE_ID_MATCH_DEVICE;
340 } 333 }
341 334
342 ret = usb_serial_register_drivers(serial_drivers, KBUILD_MODNAME, ti_id_table_combined); 335 return usb_serial_register_drivers(serial_drivers, KBUILD_MODNAME, ti_id_table_combined);
343 if (ret == 0)
344 printk(KERN_INFO KBUILD_MODNAME ": " TI_DRIVER_VERSION ":"
345 TI_DRIVER_DESC "\n");
346 return ret;
347} 336}
348 337
349static void __exit ti_exit(void) 338static void __exit ti_exit(void)
@@ -364,10 +353,11 @@ static int ti_startup(struct usb_serial *serial)
364 int i; 353 int i;
365 354
366 355
367 dbg("%s - product 0x%4X, num configurations %d, configuration value %d", 356 dev_dbg(&dev->dev,
368 __func__, le16_to_cpu(dev->descriptor.idProduct), 357 "%s - product 0x%4X, num configurations %d, configuration value %d",
369 dev->descriptor.bNumConfigurations, 358 __func__, le16_to_cpu(dev->descriptor.idProduct),
370 dev->actconfig->desc.bConfigurationValue); 359 dev->descriptor.bNumConfigurations,
360 dev->actconfig->desc.bConfigurationValue);
371 361
372 /* create device structure */ 362 /* create device structure */
373 tdev = kzalloc(sizeof(struct ti_device), GFP_KERNEL); 363 tdev = kzalloc(sizeof(struct ti_device), GFP_KERNEL);
@@ -382,8 +372,8 @@ static int ti_startup(struct usb_serial *serial)
382 /* determine device type */ 372 /* determine device type */
383 if (usb_match_id(serial->interface, ti_id_table_3410)) 373 if (usb_match_id(serial->interface, ti_id_table_3410))
384 tdev->td_is_3410 = 1; 374 tdev->td_is_3410 = 1;
385 dbg("%s - device type is %s", __func__, 375 dev_dbg(&dev->dev, "%s - device type is %s\n", __func__,
386 tdev->td_is_3410 ? "3410" : "5052"); 376 tdev->td_is_3410 ? "3410" : "5052");
387 377
388 /* if we have only 1 configuration, download firmware */ 378 /* if we have only 1 configuration, download firmware */
389 if (dev->descriptor.bNumConfigurations == 1) { 379 if (dev->descriptor.bNumConfigurations == 1) {
@@ -501,20 +491,17 @@ static int ti_open(struct tty_struct *tty, struct usb_serial_port *port)
501 491
502 /* start interrupt urb the first time a port is opened on this device */ 492 /* start interrupt urb the first time a port is opened on this device */
503 if (tdev->td_open_port_count == 0) { 493 if (tdev->td_open_port_count == 0) {
504 dbg("%s - start interrupt in urb", __func__); 494 dev_dbg(&port->dev, "%s - start interrupt in urb\n", __func__);
505 urb = tdev->td_serial->port[0]->interrupt_in_urb; 495 urb = tdev->td_serial->port[0]->interrupt_in_urb;
506 if (!urb) { 496 if (!urb) {
507 dev_err(&port->dev, "%s - no interrupt urb\n", 497 dev_err(&port->dev, "%s - no interrupt urb\n", __func__);
508 __func__);
509 status = -EINVAL; 498 status = -EINVAL;
510 goto release_lock; 499 goto release_lock;
511 } 500 }
512 urb->context = tdev; 501 urb->context = tdev;
513 status = usb_submit_urb(urb, GFP_KERNEL); 502 status = usb_submit_urb(urb, GFP_KERNEL);
514 if (status) { 503 if (status) {
515 dev_err(&port->dev, 504 dev_err(&port->dev, "%s - submit interrupt urb failed, %d\n", __func__, status);
516 "%s - submit interrupt urb failed, %d\n",
517 __func__, status);
518 goto release_lock; 505 goto release_lock;
519 } 506 }
520 } 507 }
@@ -522,16 +509,16 @@ static int ti_open(struct tty_struct *tty, struct usb_serial_port *port)
522 if (tty) 509 if (tty)
523 ti_set_termios(tty, port, &tty->termios); 510 ti_set_termios(tty, port, &tty->termios);
524 511
525 dbg("%s - sending TI_OPEN_PORT", __func__); 512 dev_dbg(&port->dev, "%s - sending TI_OPEN_PORT\n", __func__);
526 status = ti_command_out_sync(tdev, TI_OPEN_PORT, 513 status = ti_command_out_sync(tdev, TI_OPEN_PORT,
527 (__u8)(TI_UART1_PORT + port_number), open_settings, NULL, 0); 514 (__u8)(TI_UART1_PORT + port_number), open_settings, NULL, 0);
528 if (status) { 515 if (status) {
529 dev_err(&port->dev, "%s - cannot send open command, %d\n", 516 dev_err(&port->dev, "%s - cannot send open command, %d\n",
530 __func__, status); 517 __func__, status);
531 goto unlink_int_urb; 518 goto unlink_int_urb;
532 } 519 }
533 520
534 dbg("%s - sending TI_START_PORT", __func__); 521 dev_dbg(&port->dev, "%s - sending TI_START_PORT\n", __func__);
535 status = ti_command_out_sync(tdev, TI_START_PORT, 522 status = ti_command_out_sync(tdev, TI_START_PORT,
536 (__u8)(TI_UART1_PORT + port_number), 0, NULL, 0); 523 (__u8)(TI_UART1_PORT + port_number), 0, NULL, 0);
537 if (status) { 524 if (status) {
@@ -540,7 +527,7 @@ static int ti_open(struct tty_struct *tty, struct usb_serial_port *port)
540 goto unlink_int_urb; 527 goto unlink_int_urb;
541 } 528 }
542 529
543 dbg("%s - sending TI_PURGE_PORT", __func__); 530 dev_dbg(&port->dev, "%s - sending TI_PURGE_PORT\n", __func__);
544 status = ti_command_out_sync(tdev, TI_PURGE_PORT, 531 status = ti_command_out_sync(tdev, TI_PURGE_PORT,
545 (__u8)(TI_UART1_PORT + port_number), TI_PURGE_INPUT, NULL, 0); 532 (__u8)(TI_UART1_PORT + port_number), TI_PURGE_INPUT, NULL, 0);
546 if (status) { 533 if (status) {
@@ -564,7 +551,7 @@ static int ti_open(struct tty_struct *tty, struct usb_serial_port *port)
564 if (tty) 551 if (tty)
565 ti_set_termios(tty, port, &tty->termios); 552 ti_set_termios(tty, port, &tty->termios);
566 553
567 dbg("%s - sending TI_OPEN_PORT (2)", __func__); 554 dev_dbg(&port->dev, "%s - sending TI_OPEN_PORT (2)\n", __func__);
568 status = ti_command_out_sync(tdev, TI_OPEN_PORT, 555 status = ti_command_out_sync(tdev, TI_OPEN_PORT,
569 (__u8)(TI_UART1_PORT + port_number), open_settings, NULL, 0); 556 (__u8)(TI_UART1_PORT + port_number), open_settings, NULL, 0);
570 if (status) { 557 if (status) {
@@ -573,7 +560,7 @@ static int ti_open(struct tty_struct *tty, struct usb_serial_port *port)
573 goto unlink_int_urb; 560 goto unlink_int_urb;
574 } 561 }
575 562
576 dbg("%s - sending TI_START_PORT (2)", __func__); 563 dev_dbg(&port->dev, "%s - sending TI_START_PORT (2)\n", __func__);
577 status = ti_command_out_sync(tdev, TI_START_PORT, 564 status = ti_command_out_sync(tdev, TI_START_PORT,
578 (__u8)(TI_UART1_PORT + port_number), 0, NULL, 0); 565 (__u8)(TI_UART1_PORT + port_number), 0, NULL, 0);
579 if (status) { 566 if (status) {
@@ -583,7 +570,7 @@ static int ti_open(struct tty_struct *tty, struct usb_serial_port *port)
583 } 570 }
584 571
585 /* start read urb */ 572 /* start read urb */
586 dbg("%s - start read urb", __func__); 573 dev_dbg(&port->dev, "%s - start read urb\n", __func__);
587 urb = port->read_urb; 574 urb = port->read_urb;
588 if (!urb) { 575 if (!urb) {
589 dev_err(&port->dev, "%s - no read urb\n", __func__); 576 dev_err(&port->dev, "%s - no read urb\n", __func__);
@@ -609,7 +596,7 @@ unlink_int_urb:
609 usb_kill_urb(port->serial->port[0]->interrupt_in_urb); 596 usb_kill_urb(port->serial->port[0]->interrupt_in_urb);
610release_lock: 597release_lock:
611 mutex_unlock(&tdev->td_open_close_lock); 598 mutex_unlock(&tdev->td_open_close_lock);
612 dbg("%s - exit %d", __func__, status); 599 dev_dbg(&port->dev, "%s - exit %d\n", __func__, status);
613 return status; 600 return status;
614} 601}
615 602
@@ -637,7 +624,7 @@ static void ti_close(struct usb_serial_port *port)
637 624
638 port_number = port->number - port->serial->minor; 625 port_number = port->number - port->serial->minor;
639 626
640 dbg("%s - sending TI_CLOSE_PORT", __func__); 627 dev_dbg(&port->dev, "%s - sending TI_CLOSE_PORT\n", __func__);
641 status = ti_command_out_sync(tdev, TI_CLOSE_PORT, 628 status = ti_command_out_sync(tdev, TI_CLOSE_PORT,
642 (__u8)(TI_UART1_PORT + port_number), 0, NULL, 0); 629 (__u8)(TI_UART1_PORT + port_number), 0, NULL, 0);
643 if (status) 630 if (status)
@@ -664,7 +651,7 @@ static int ti_write(struct tty_struct *tty, struct usb_serial_port *port,
664 struct ti_port *tport = usb_get_serial_port_data(port); 651 struct ti_port *tport = usb_get_serial_port_data(port);
665 652
666 if (count == 0) { 653 if (count == 0) {
667 dbg("%s - write request of 0 bytes", __func__); 654 dev_dbg(&port->dev, "%s - write request of 0 bytes\n", __func__);
668 return 0; 655 return 0;
669 } 656 }
670 657
@@ -693,7 +680,7 @@ static int ti_write_room(struct tty_struct *tty)
693 room = kfifo_avail(&tport->write_fifo); 680 room = kfifo_avail(&tport->write_fifo);
694 spin_unlock_irqrestore(&tport->tp_lock, flags); 681 spin_unlock_irqrestore(&tport->tp_lock, flags);
695 682
696 dbg("%s - returns %d", __func__, room); 683 dev_dbg(&port->dev, "%s - returns %d\n", __func__, room);
697 return room; 684 return room;
698} 685}
699 686
@@ -712,7 +699,7 @@ static int ti_chars_in_buffer(struct tty_struct *tty)
712 chars = kfifo_len(&tport->write_fifo); 699 chars = kfifo_len(&tport->write_fifo);
713 spin_unlock_irqrestore(&tport->tp_lock, flags); 700 spin_unlock_irqrestore(&tport->tp_lock, flags);
714 701
715 dbg("%s - returns %d", __func__, chars); 702 dev_dbg(&port->dev, "%s - returns %d\n", __func__, chars);
716 return chars; 703 return chars;
717} 704}
718 705
@@ -755,8 +742,7 @@ static int ti_get_icount(struct tty_struct *tty,
755 struct ti_port *tport = usb_get_serial_port_data(port); 742 struct ti_port *tport = usb_get_serial_port_data(port);
756 struct async_icount cnow = tport->tp_icount; 743 struct async_icount cnow = tport->tp_icount;
757 744
758 dbg("%s - (%d) TIOCGICOUNT RX=%d, TX=%d", 745 dev_dbg(&port->dev, "%s - TIOCGICOUNT RX=%d, TX=%d\n", __func__,
759 __func__, port->number,
760 cnow.rx, cnow.tx); 746 cnow.rx, cnow.tx);
761 747
762 icount->cts = cnow.cts; 748 icount->cts = cnow.cts;
@@ -782,22 +768,22 @@ static int ti_ioctl(struct tty_struct *tty,
782 struct async_icount cnow; 768 struct async_icount cnow;
783 struct async_icount cprev; 769 struct async_icount cprev;
784 770
785 dbg("%s - port %d, cmd = 0x%04X", __func__, port->number, cmd); 771 dev_dbg(&port->dev, "%s - cmd = 0x%04X\n", __func__, cmd);
786 772
787 if (tport == NULL) 773 if (tport == NULL)
788 return -ENODEV; 774 return -ENODEV;
789 775
790 switch (cmd) { 776 switch (cmd) {
791 case TIOCGSERIAL: 777 case TIOCGSERIAL:
792 dbg("%s - (%d) TIOCGSERIAL", __func__, port->number); 778 dev_dbg(&port->dev, "%s - TIOCGSERIAL\n", __func__);
793 return ti_get_serial_info(tport, 779 return ti_get_serial_info(tport,
794 (struct serial_struct __user *)arg); 780 (struct serial_struct __user *)arg);
795 case TIOCSSERIAL: 781 case TIOCSSERIAL:
796 dbg("%s - (%d) TIOCSSERIAL", __func__, port->number); 782 dev_dbg(&port->dev, "%s - TIOCSSERIAL\n", __func__);
797 return ti_set_serial_info(tty, tport, 783 return ti_set_serial_info(tty, tport,
798 (struct serial_struct __user *)arg); 784 (struct serial_struct __user *)arg);
799 case TIOCMIWAIT: 785 case TIOCMIWAIT:
800 dbg("%s - (%d) TIOCMIWAIT", __func__, port->number); 786 dev_dbg(&port->dev, "%s - TIOCMIWAIT\n", __func__);
801 cprev = tport->tp_icount; 787 cprev = tport->tp_icount;
802 while (1) { 788 while (1) {
803 interruptible_sleep_on(&tport->tp_msr_wait); 789 interruptible_sleep_on(&tport->tp_msr_wait);
@@ -834,9 +820,9 @@ static void ti_set_termios(struct tty_struct *tty,
834 cflag = tty->termios.c_cflag; 820 cflag = tty->termios.c_cflag;
835 iflag = tty->termios.c_iflag; 821 iflag = tty->termios.c_iflag;
836 822
837 dbg("%s - cflag %08x, iflag %08x", __func__, cflag, iflag); 823 dev_dbg(&port->dev, "%s - cflag %08x, iflag %08x\n", __func__, cflag, iflag);
838 dbg("%s - old clfag %08x, old iflag %08x", __func__, 824 dev_dbg(&port->dev, "%s - old clfag %08x, old iflag %08x\n", __func__,
839 old_termios->c_cflag, old_termios->c_iflag); 825 old_termios->c_cflag, old_termios->c_iflag);
840 826
841 if (tport == NULL) 827 if (tport == NULL)
842 return; 828 return;
@@ -926,8 +912,11 @@ static void ti_set_termios(struct tty_struct *tty,
926 if ((cflag & CBAUD) != B0) 912 if ((cflag & CBAUD) != B0)
927 tty_encode_baud_rate(tty, baud, baud); 913 tty_encode_baud_rate(tty, baud, baud);
928 914
929 dbg("%s - BaudRate=%d, wBaudRate=%d, wFlags=0x%04X, bDataBits=%d, bParity=%d, bStopBits=%d, cXon=%d, cXoff=%d, bUartMode=%d", 915 dev_dbg(&port->dev,
930 __func__, baud, config->wBaudRate, config->wFlags, config->bDataBits, config->bParity, config->bStopBits, config->cXon, config->cXoff, config->bUartMode); 916 "%s - BaudRate=%d, wBaudRate=%d, wFlags=0x%04X, bDataBits=%d, bParity=%d, bStopBits=%d, cXon=%d, cXoff=%d, bUartMode=%d",
917 __func__, baud, config->wBaudRate, config->wFlags,
918 config->bDataBits, config->bParity, config->bStopBits,
919 config->cXon, config->cXoff, config->bUartMode);
931 920
932 cpu_to_be16s(&config->wBaudRate); 921 cpu_to_be16s(&config->wBaudRate);
933 cpu_to_be16s(&config->wFlags); 922 cpu_to_be16s(&config->wFlags);
@@ -979,7 +968,7 @@ static int ti_tiocmget(struct tty_struct *tty)
979 | ((msr & TI_MSR_RI) ? TIOCM_RI : 0) 968 | ((msr & TI_MSR_RI) ? TIOCM_RI : 0)
980 | ((msr & TI_MSR_DSR) ? TIOCM_DSR : 0); 969 | ((msr & TI_MSR_DSR) ? TIOCM_DSR : 0);
981 970
982 dbg("%s - 0x%04X", __func__, result); 971 dev_dbg(&port->dev, "%s - 0x%04X\n", __func__, result);
983 972
984 return result; 973 return result;
985} 974}
@@ -1024,19 +1013,19 @@ static void ti_break(struct tty_struct *tty, int break_state)
1024 struct ti_port *tport = usb_get_serial_port_data(port); 1013 struct ti_port *tport = usb_get_serial_port_data(port);
1025 int status; 1014 int status;
1026 1015
1027 dbg("%s - state = %d", __func__, break_state); 1016 dev_dbg(&port->dev, "%s - state = %d\n", __func__, break_state);
1028 1017
1029 if (tport == NULL) 1018 if (tport == NULL)
1030 return; 1019 return;
1031 1020
1032 ti_drain(tport, (tport->tp_closing_wait*HZ)/100, 0); 1021 ti_drain(tport, (tport->tp_closing_wait*HZ)/100, 0);
1033 1022
1034 status = ti_write_byte(tport->tp_tdev, 1023 status = ti_write_byte(port, tport->tp_tdev,
1035 tport->tp_uart_base_addr + TI_UART_OFFSET_LCR, 1024 tport->tp_uart_base_addr + TI_UART_OFFSET_LCR,
1036 TI_LCR_BREAK, break_state == -1 ? TI_LCR_BREAK : 0); 1025 TI_LCR_BREAK, break_state == -1 ? TI_LCR_BREAK : 0);
1037 1026
1038 if (status) 1027 if (status)
1039 dbg("%s - error setting break, %d", __func__, status); 1028 dev_dbg(&port->dev, "%s - error setting break, %d\n", __func__, status);
1040} 1029}
1041 1030
1042 1031
@@ -1061,18 +1050,17 @@ static void ti_interrupt_callback(struct urb *urb)
1061 case -ECONNRESET: 1050 case -ECONNRESET:
1062 case -ENOENT: 1051 case -ENOENT:
1063 case -ESHUTDOWN: 1052 case -ESHUTDOWN:
1064 dbg("%s - urb shutting down, %d", __func__, status); 1053 dev_dbg(dev, "%s - urb shutting down, %d\n", __func__, status);
1065 tdev->td_urb_error = 1; 1054 tdev->td_urb_error = 1;
1066 return; 1055 return;
1067 default: 1056 default:
1068 dev_err(dev, "%s - nonzero urb status, %d\n", 1057 dev_err(dev, "%s - nonzero urb status, %d\n", __func__, status);
1069 __func__, status);
1070 tdev->td_urb_error = 1; 1058 tdev->td_urb_error = 1;
1071 goto exit; 1059 goto exit;
1072 } 1060 }
1073 1061
1074 if (length != 2) { 1062 if (length != 2) {
1075 dbg("%s - bad packet size, %d", __func__, length); 1063 dev_dbg(dev, "%s - bad packet size, %d\n", __func__, length);
1076 goto exit; 1064 goto exit;
1077 } 1065 }
1078 1066
@@ -1084,8 +1072,8 @@ static void ti_interrupt_callback(struct urb *urb)
1084 port_number = TI_GET_PORT_FROM_CODE(data[0]); 1072 port_number = TI_GET_PORT_FROM_CODE(data[0]);
1085 function = TI_GET_FUNC_FROM_CODE(data[0]); 1073 function = TI_GET_FUNC_FROM_CODE(data[0]);
1086 1074
1087 dbg("%s - port_number %d, function %d, data 0x%02X", 1075 dev_dbg(dev, "%s - port_number %d, function %d, data 0x%02X\n",
1088 __func__, port_number, function, data[1]); 1076 __func__, port_number, function, data[1]);
1089 1077
1090 if (port_number >= serial->num_ports) { 1078 if (port_number >= serial->num_ports) {
1091 dev_err(dev, "%s - bad port number, %d\n", 1079 dev_err(dev, "%s - bad port number, %d\n",
@@ -1102,12 +1090,12 @@ static void ti_interrupt_callback(struct urb *urb)
1102 switch (function) { 1090 switch (function) {
1103 case TI_CODE_DATA_ERROR: 1091 case TI_CODE_DATA_ERROR:
1104 dev_err(dev, "%s - DATA ERROR, port %d, data 0x%02X\n", 1092 dev_err(dev, "%s - DATA ERROR, port %d, data 0x%02X\n",
1105 __func__, port_number, data[1]); 1093 __func__, port_number, data[1]);
1106 break; 1094 break;
1107 1095
1108 case TI_CODE_MODEM_STATUS: 1096 case TI_CODE_MODEM_STATUS:
1109 msr = data[1]; 1097 msr = data[1];
1110 dbg("%s - port %d, msr 0x%02X", __func__, port_number, msr); 1098 dev_dbg(dev, "%s - port %d, msr 0x%02X\n", __func__, port_number, msr);
1111 ti_handle_new_msr(tport, msr); 1099 ti_handle_new_msr(tport, msr);
1112 break; 1100 break;
1113 1101
@@ -1140,7 +1128,7 @@ static void ti_bulk_in_callback(struct urb *urb)
1140 case -ECONNRESET: 1128 case -ECONNRESET:
1141 case -ENOENT: 1129 case -ENOENT:
1142 case -ESHUTDOWN: 1130 case -ESHUTDOWN:
1143 dbg("%s - urb shutting down, %d", __func__, status); 1131 dev_dbg(dev, "%s - urb shutting down, %d\n", __func__, status);
1144 tport->tp_tdev->td_urb_error = 1; 1132 tport->tp_tdev->td_urb_error = 1;
1145 wake_up_interruptible(&tport->tp_write_wait); 1133 wake_up_interruptible(&tport->tp_write_wait);
1146 return; 1134 return;
@@ -1162,11 +1150,11 @@ static void ti_bulk_in_callback(struct urb *urb)
1162 tty = tty_port_tty_get(&port->port); 1150 tty = tty_port_tty_get(&port->port);
1163 if (tty) { 1151 if (tty) {
1164 if (urb->actual_length) { 1152 if (urb->actual_length) {
1165 usb_serial_debug_data(debug, dev, __func__, 1153 usb_serial_debug_data(dev, __func__, urb->actual_length,
1166 urb->actual_length, urb->transfer_buffer); 1154 urb->transfer_buffer);
1167 1155
1168 if (!tport->tp_is_open) 1156 if (!tport->tp_is_open)
1169 dbg("%s - port closed, dropping data", 1157 dev_dbg(dev, "%s - port closed, dropping data\n",
1170 __func__); 1158 __func__);
1171 else 1159 else
1172 ti_recv(&urb->dev->dev, tty, 1160 ti_recv(&urb->dev->dev, tty,
@@ -1208,7 +1196,7 @@ static void ti_bulk_out_callback(struct urb *urb)
1208 case -ECONNRESET: 1196 case -ECONNRESET:
1209 case -ENOENT: 1197 case -ENOENT:
1210 case -ESHUTDOWN: 1198 case -ESHUTDOWN:
1211 dbg("%s - urb shutting down, %d", __func__, status); 1199 dev_dbg(&port->dev, "%s - urb shutting down, %d\n", __func__, status);
1212 tport->tp_tdev->td_urb_error = 1; 1200 tport->tp_tdev->td_urb_error = 1;
1213 wake_up_interruptible(&tport->tp_write_wait); 1201 wake_up_interruptible(&tport->tp_write_wait);
1214 return; 1202 return;
@@ -1268,8 +1256,8 @@ static void ti_send(struct ti_port *tport)
1268 1256
1269 spin_unlock_irqrestore(&tport->tp_lock, flags); 1257 spin_unlock_irqrestore(&tport->tp_lock, flags);
1270 1258
1271 usb_serial_debug_data(debug, &port->dev, __func__, count, 1259 usb_serial_debug_data(&port->dev, __func__, count,
1272 port->write_urb->transfer_buffer); 1260 port->write_urb->transfer_buffer);
1273 1261
1274 usb_fill_bulk_urb(port->write_urb, port->serial->dev, 1262 usb_fill_bulk_urb(port->write_urb, port->serial->dev,
1275 usb_sndbulkpipe(port->serial->dev, 1263 usb_sndbulkpipe(port->serial->dev,
@@ -1307,7 +1295,7 @@ static int ti_set_mcr(struct ti_port *tport, unsigned int mcr)
1307 unsigned long flags; 1295 unsigned long flags;
1308 int status; 1296 int status;
1309 1297
1310 status = ti_write_byte(tport->tp_tdev, 1298 status = ti_write_byte(tport->tp_port, tport->tp_tdev,
1311 tport->tp_uart_base_addr + TI_UART_OFFSET_MCR, 1299 tport->tp_uart_base_addr + TI_UART_OFFSET_MCR,
1312 TI_MCR_RTS | TI_MCR_DTR | TI_MCR_LOOP, mcr); 1300 TI_MCR_RTS | TI_MCR_DTR | TI_MCR_LOOP, mcr);
1313 1301
@@ -1344,7 +1332,7 @@ static int ti_get_lsr(struct ti_port *tport)
1344 goto free_data; 1332 goto free_data;
1345 } 1333 }
1346 1334
1347 dbg("%s - lsr 0x%02X", __func__, data->bLSR); 1335 dev_dbg(&port->dev, "%s - lsr 0x%02X\n", __func__, data->bLSR);
1348 1336
1349 tport->tp_lsr = data->bLSR; 1337 tport->tp_lsr = data->bLSR;
1350 1338
@@ -1401,7 +1389,7 @@ static void ti_handle_new_msr(struct ti_port *tport, __u8 msr)
1401 struct tty_struct *tty; 1389 struct tty_struct *tty;
1402 unsigned long flags; 1390 unsigned long flags;
1403 1391
1404 dbg("%s - msr 0x%02X", __func__, msr); 1392 dev_dbg(&tport->tp_port->dev, "%s - msr 0x%02X\n", __func__, msr);
1405 1393
1406 if (msr & TI_MSR_DELTA_MASK) { 1394 if (msr & TI_MSR_DELTA_MASK) {
1407 spin_lock_irqsave(&tport->tp_lock, flags); 1395 spin_lock_irqsave(&tport->tp_lock, flags);
@@ -1560,21 +1548,21 @@ static int ti_command_in_sync(struct ti_device *tdev, __u8 command,
1560} 1548}
1561 1549
1562 1550
1563static int ti_write_byte(struct ti_device *tdev, unsigned long addr, 1551static int ti_write_byte(struct usb_serial_port *port,
1564 __u8 mask, __u8 byte) 1552 struct ti_device *tdev, unsigned long addr,
1553 __u8 mask, __u8 byte)
1565{ 1554{
1566 int status; 1555 int status;
1567 unsigned int size; 1556 unsigned int size;
1568 struct ti_write_data_bytes *data; 1557 struct ti_write_data_bytes *data;
1569 struct device *dev = &tdev->td_serial->dev->dev;
1570 1558
1571 dbg("%s - addr 0x%08lX, mask 0x%02X, byte 0x%02X", 1559 dev_dbg(&port->dev, "%s - addr 0x%08lX, mask 0x%02X, byte 0x%02X\n", __func__,
1572 __func__, addr, mask, byte); 1560 addr, mask, byte);
1573 1561
1574 size = sizeof(struct ti_write_data_bytes) + 2; 1562 size = sizeof(struct ti_write_data_bytes) + 2;
1575 data = kmalloc(size, GFP_KERNEL); 1563 data = kmalloc(size, GFP_KERNEL);
1576 if (!data) { 1564 if (!data) {
1577 dev_err(dev, "%s - out of memory\n", __func__); 1565 dev_err(&port->dev, "%s - out of memory\n", __func__);
1578 return -ENOMEM; 1566 return -ENOMEM;
1579 } 1567 }
1580 1568
@@ -1590,7 +1578,7 @@ static int ti_write_byte(struct ti_device *tdev, unsigned long addr,
1590 (__u8 *)data, size); 1578 (__u8 *)data, size);
1591 1579
1592 if (status < 0) 1580 if (status < 0)
1593 dev_err(dev, "%s - failed, %d\n", __func__, status); 1581 dev_err(&port->dev, "%s - failed, %d\n", __func__, status);
1594 1582
1595 kfree(data); 1583 kfree(data);
1596 1584
@@ -1615,7 +1603,7 @@ static int ti_do_download(struct usb_device *dev, int pipe,
1615 - sizeof(struct ti_firmware_header))); 1603 - sizeof(struct ti_firmware_header)));
1616 header->bCheckSum = cs; 1604 header->bCheckSum = cs;
1617 1605
1618 dbg("%s - downloading firmware", __func__); 1606 dev_dbg(&dev->dev, "%s - downloading firmware\n", __func__);
1619 for (pos = 0; pos < size; pos += done) { 1607 for (pos = 0; pos < size; pos += done) {
1620 len = min(size - pos, TI_DOWNLOAD_MAX_PACKET_SIZE); 1608 len = min(size - pos, TI_DOWNLOAD_MAX_PACKET_SIZE);
1621 status = usb_bulk_msg(dev, pipe, buffer + pos, len, 1609 status = usb_bulk_msg(dev, pipe, buffer + pos, len,
@@ -1691,7 +1679,7 @@ static int ti_download_firmware(struct ti_device *tdev)
1691 status = ti_do_download(dev, pipe, buffer, fw_p->size); 1679 status = ti_do_download(dev, pipe, buffer, fw_p->size);
1692 kfree(buffer); 1680 kfree(buffer);
1693 } else { 1681 } else {
1694 dbg("%s ENOMEM\n", __func__); 1682 dev_dbg(&dev->dev, "%s ENOMEM\n", __func__);
1695 status = -ENOMEM; 1683 status = -ENOMEM;
1696 } 1684 }
1697 release_firmware(fw_p); 1685 release_firmware(fw_p);
@@ -1701,7 +1689,7 @@ static int ti_download_firmware(struct ti_device *tdev)
1701 return status; 1689 return status;
1702 } 1690 }
1703 1691
1704 dbg("%s - download successful", __func__); 1692 dev_dbg(&dev->dev, "%s - download successful\n", __func__);
1705 1693
1706 return 0; 1694 return 0;
1707} 1695}
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index aa4b0d775992..73b8e0569164 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -17,6 +17,8 @@
17 * 17 *
18 */ 18 */
19 19
20#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
21
20#include <linux/kernel.h> 22#include <linux/kernel.h>
21#include <linux/errno.h> 23#include <linux/errno.h>
22#include <linux/init.h> 24#include <linux/init.h>
@@ -37,10 +39,7 @@
37#include <linux/kfifo.h> 39#include <linux/kfifo.h>
38#include "pl2303.h" 40#include "pl2303.h"
39 41
40/* 42#define DRIVER_AUTHOR "Greg Kroah-Hartman <gregkh@linuxfoundation.org>"
41 * Version Information
42 */
43#define DRIVER_AUTHOR "Greg Kroah-Hartman, greg@kroah.com, http://www.kroah.com/linux/"
44#define DRIVER_DESC "USB Serial Driver core" 43#define DRIVER_DESC "USB Serial Driver core"
45 44
46/* There is no MODULE_DEVICE_TABLE for usbserial.c. Instead 45/* There is no MODULE_DEVICE_TABLE for usbserial.c. Instead
@@ -50,7 +49,6 @@
50 drivers depend on it. 49 drivers depend on it.
51*/ 50*/
52 51
53static bool debug;
54/* initially all NULL */ 52/* initially all NULL */
55static struct usb_serial *serial_table[SERIAL_TTY_MINORS]; 53static struct usb_serial *serial_table[SERIAL_TTY_MINORS];
56static DEFINE_MUTEX(table_lock); 54static DEFINE_MUTEX(table_lock);
@@ -87,7 +85,7 @@ static struct usb_serial *get_free_serial(struct usb_serial *serial,
87 unsigned int i, j; 85 unsigned int i, j;
88 int good_spot; 86 int good_spot;
89 87
90 dbg("%s %d", __func__, num_ports); 88 dev_dbg(&serial->interface->dev, "%s %d\n", __func__, num_ports);
91 89
92 *minor = 0; 90 *minor = 0;
93 mutex_lock(&table_lock); 91 mutex_lock(&table_lock);
@@ -107,7 +105,7 @@ static struct usb_serial *get_free_serial(struct usb_serial *serial,
107 105
108 *minor = i; 106 *minor = i;
109 j = 0; 107 j = 0;
110 dbg("%s - minor base = %d", __func__, *minor); 108 dev_dbg(&serial->interface->dev, "%s - minor base = %d\n", __func__, *minor);
111 for (i = *minor; (i < (*minor + num_ports)) && (i < SERIAL_TTY_MINORS); ++i) { 109 for (i = *minor; (i < (*minor + num_ports)) && (i < SERIAL_TTY_MINORS); ++i) {
112 serial_table[i] = serial; 110 serial_table[i] = serial;
113 serial->port[j++]->number = i; 111 serial->port[j++]->number = i;
@@ -123,8 +121,6 @@ static void return_serial(struct usb_serial *serial)
123{ 121{
124 int i; 122 int i;
125 123
126 dbg("%s", __func__);
127
128 mutex_lock(&table_lock); 124 mutex_lock(&table_lock);
129 for (i = 0; i < serial->num_ports; ++i) 125 for (i = 0; i < serial->num_ports; ++i)
130 serial_table[serial->minor + i] = NULL; 126 serial_table[serial->minor + i] = NULL;
@@ -139,8 +135,6 @@ static void destroy_serial(struct kref *kref)
139 135
140 serial = to_usb_serial(kref); 136 serial = to_usb_serial(kref);
141 137
142 dbg("%s - %s", __func__, serial->type->description);
143
144 /* return the minor range that this device had */ 138 /* return the minor range that this device had */
145 if (serial->minor != SERIAL_TTY_NO_MINOR) 139 if (serial->minor != SERIAL_TTY_NO_MINOR)
146 return_serial(serial); 140 return_serial(serial);
@@ -191,8 +185,6 @@ static int serial_install(struct tty_driver *driver, struct tty_struct *tty)
191 struct usb_serial_port *port; 185 struct usb_serial_port *port;
192 int retval = -ENODEV; 186 int retval = -ENODEV;
193 187
194 dbg("%s", __func__);
195
196 serial = usb_serial_get_by_index(idx); 188 serial = usb_serial_get_by_index(idx);
197 if (!serial) 189 if (!serial)
198 return retval; 190 return retval;
@@ -256,7 +248,7 @@ static int serial_open(struct tty_struct *tty, struct file *filp)
256{ 248{
257 struct usb_serial_port *port = tty->driver_data; 249 struct usb_serial_port *port = tty->driver_data;
258 250
259 dbg("%s - port %d", __func__, port->number); 251 dev_dbg(tty->dev, "%s - port %d\n", __func__, port->number);
260 return tty_port_open(&port->port, tty, filp); 252 return tty_port_open(&port->port, tty, filp);
261} 253}
262 254
@@ -287,14 +279,16 @@ static void serial_down(struct tty_port *tport)
287static void serial_hangup(struct tty_struct *tty) 279static void serial_hangup(struct tty_struct *tty)
288{ 280{
289 struct usb_serial_port *port = tty->driver_data; 281 struct usb_serial_port *port = tty->driver_data;
290 dbg("%s - port %d", __func__, port->number); 282
283 dev_dbg(tty->dev, "%s - port %d\n", __func__, port->number);
291 tty_port_hangup(&port->port); 284 tty_port_hangup(&port->port);
292} 285}
293 286
294static void serial_close(struct tty_struct *tty, struct file *filp) 287static void serial_close(struct tty_struct *tty, struct file *filp)
295{ 288{
296 struct usb_serial_port *port = tty->driver_data; 289 struct usb_serial_port *port = tty->driver_data;
297 dbg("%s - port %d", __func__, port->number); 290
291 dev_dbg(tty->dev, "%s - port %d\n", __func__, port->number);
298 tty_port_close(&port->port, tty, filp); 292 tty_port_close(&port->port, tty, filp);
299} 293}
300 294
@@ -319,7 +313,7 @@ static void serial_cleanup(struct tty_struct *tty)
319 if (port->port.console) 313 if (port->port.console)
320 return; 314 return;
321 315
322 dbg("%s - port %d", __func__, port->number); 316 dev_dbg(tty->dev, "%s - port %d\n", __func__, port->number);
323 317
324 tty->driver_data = NULL; 318 tty->driver_data = NULL;
325 319
@@ -344,7 +338,8 @@ static int serial_write(struct tty_struct *tty, const unsigned char *buf,
344 if (port->serial->dev->state == USB_STATE_NOTATTACHED) 338 if (port->serial->dev->state == USB_STATE_NOTATTACHED)
345 goto exit; 339 goto exit;
346 340
347 dbg("%s - port %d, %d byte(s)", __func__, port->number, count); 341 dev_dbg(tty->dev, "%s - port %d, %d byte(s)\n", __func__,
342 port->number, count);
348 343
349 /* pass on to the driver specific version of this function */ 344 /* pass on to the driver specific version of this function */
350 retval = port->serial->type->write(tty, port, buf, count); 345 retval = port->serial->type->write(tty, port, buf, count);
@@ -357,7 +352,8 @@ exit:
357static int serial_write_room(struct tty_struct *tty) 352static int serial_write_room(struct tty_struct *tty)
358{ 353{
359 struct usb_serial_port *port = tty->driver_data; 354 struct usb_serial_port *port = tty->driver_data;
360 dbg("%s - port %d", __func__, port->number); 355
356 dev_dbg(tty->dev, "%s - port %d\n", __func__, port->number);
361 /* pass on to the driver specific version of this function */ 357 /* pass on to the driver specific version of this function */
362 return port->serial->type->write_room(tty); 358 return port->serial->type->write_room(tty);
363} 359}
@@ -365,7 +361,8 @@ static int serial_write_room(struct tty_struct *tty)
365static int serial_chars_in_buffer(struct tty_struct *tty) 361static int serial_chars_in_buffer(struct tty_struct *tty)
366{ 362{
367 struct usb_serial_port *port = tty->driver_data; 363 struct usb_serial_port *port = tty->driver_data;
368 dbg("%s - port %d", __func__, port->number); 364
365 dev_dbg(tty->dev, "%s - port %d\n", __func__, port->number);
369 366
370 /* if the device was unplugged then any remaining characters 367 /* if the device was unplugged then any remaining characters
371 fell out of the connector ;) */ 368 fell out of the connector ;) */
@@ -378,7 +375,8 @@ static int serial_chars_in_buffer(struct tty_struct *tty)
378static void serial_throttle(struct tty_struct *tty) 375static void serial_throttle(struct tty_struct *tty)
379{ 376{
380 struct usb_serial_port *port = tty->driver_data; 377 struct usb_serial_port *port = tty->driver_data;
381 dbg("%s - port %d", __func__, port->number); 378
379 dev_dbg(tty->dev, "%s - port %d\n", __func__, port->number);
382 380
383 /* pass on to the driver specific version of this function */ 381 /* pass on to the driver specific version of this function */
384 if (port->serial->type->throttle) 382 if (port->serial->type->throttle)
@@ -388,7 +386,8 @@ static void serial_throttle(struct tty_struct *tty)
388static void serial_unthrottle(struct tty_struct *tty) 386static void serial_unthrottle(struct tty_struct *tty)
389{ 387{
390 struct usb_serial_port *port = tty->driver_data; 388 struct usb_serial_port *port = tty->driver_data;
391 dbg("%s - port %d", __func__, port->number); 389
390 dev_dbg(tty->dev, "%s - port %d\n", __func__, port->number);
392 391
393 /* pass on to the driver specific version of this function */ 392 /* pass on to the driver specific version of this function */
394 if (port->serial->type->unthrottle) 393 if (port->serial->type->unthrottle)
@@ -401,7 +400,8 @@ static int serial_ioctl(struct tty_struct *tty,
401 struct usb_serial_port *port = tty->driver_data; 400 struct usb_serial_port *port = tty->driver_data;
402 int retval = -ENODEV; 401 int retval = -ENODEV;
403 402
404 dbg("%s - port %d, cmd 0x%.4x", __func__, port->number, cmd); 403 dev_dbg(tty->dev, "%s - port %d, cmd 0x%.4x\n", __func__,
404 port->number, cmd);
405 405
406 /* pass on to the driver specific version of this function 406 /* pass on to the driver specific version of this function
407 if it is available */ 407 if it is available */
@@ -415,7 +415,8 @@ static int serial_ioctl(struct tty_struct *tty,
415static void serial_set_termios(struct tty_struct *tty, struct ktermios *old) 415static void serial_set_termios(struct tty_struct *tty, struct ktermios *old)
416{ 416{
417 struct usb_serial_port *port = tty->driver_data; 417 struct usb_serial_port *port = tty->driver_data;
418 dbg("%s - port %d", __func__, port->number); 418
419 dev_dbg(tty->dev, "%s - port %d\n", __func__, port->number);
419 420
420 /* pass on to the driver specific version of this function 421 /* pass on to the driver specific version of this function
421 if it is available */ 422 if it is available */
@@ -429,7 +430,7 @@ static int serial_break(struct tty_struct *tty, int break_state)
429{ 430{
430 struct usb_serial_port *port = tty->driver_data; 431 struct usb_serial_port *port = tty->driver_data;
431 432
432 dbg("%s - port %d", __func__, port->number); 433 dev_dbg(tty->dev, "%s - port %d\n", __func__, port->number);
433 434
434 /* pass on to the driver specific version of this function 435 /* pass on to the driver specific version of this function
435 if it is available */ 436 if it is available */
@@ -444,7 +445,6 @@ static int serial_proc_show(struct seq_file *m, void *v)
444 int i; 445 int i;
445 char tmp[40]; 446 char tmp[40];
446 447
447 dbg("%s", __func__);
448 seq_puts(m, "usbserinfo:1.0 driver:2.0\n"); 448 seq_puts(m, "usbserinfo:1.0 driver:2.0\n");
449 for (i = 0; i < SERIAL_TTY_MINORS; ++i) { 449 for (i = 0; i < SERIAL_TTY_MINORS; ++i) {
450 serial = usb_serial_get_by_index(i); 450 serial = usb_serial_get_by_index(i);
@@ -489,7 +489,7 @@ static int serial_tiocmget(struct tty_struct *tty)
489{ 489{
490 struct usb_serial_port *port = tty->driver_data; 490 struct usb_serial_port *port = tty->driver_data;
491 491
492 dbg("%s - port %d", __func__, port->number); 492 dev_dbg(tty->dev, "%s - port %d\n", __func__, port->number);
493 493
494 if (port->serial->type->tiocmget) 494 if (port->serial->type->tiocmget)
495 return port->serial->type->tiocmget(tty); 495 return port->serial->type->tiocmget(tty);
@@ -501,7 +501,7 @@ static int serial_tiocmset(struct tty_struct *tty,
501{ 501{
502 struct usb_serial_port *port = tty->driver_data; 502 struct usb_serial_port *port = tty->driver_data;
503 503
504 dbg("%s - port %d", __func__, port->number); 504 dev_dbg(tty->dev, "%s - port %d\n", __func__, port->number);
505 505
506 if (port->serial->type->tiocmset) 506 if (port->serial->type->tiocmset)
507 return port->serial->type->tiocmset(tty, set, clear); 507 return port->serial->type->tiocmset(tty, set, clear);
@@ -513,7 +513,7 @@ static int serial_get_icount(struct tty_struct *tty,
513{ 513{
514 struct usb_serial_port *port = tty->driver_data; 514 struct usb_serial_port *port = tty->driver_data;
515 515
516 dbg("%s - port %d", __func__, port->number); 516 dev_dbg(tty->dev, "%s - port %d\n", __func__, port->number);
517 517
518 if (port->serial->type->get_icount) 518 if (port->serial->type->get_icount)
519 return port->serial->type->get_icount(tty, icount); 519 return port->serial->type->get_icount(tty, icount);
@@ -537,12 +537,12 @@ static void usb_serial_port_work(struct work_struct *work)
537 container_of(work, struct usb_serial_port, work); 537 container_of(work, struct usb_serial_port, work);
538 struct tty_struct *tty; 538 struct tty_struct *tty;
539 539
540 dbg("%s - port %d", __func__, port->number);
541
542 tty = tty_port_tty_get(&port->port); 540 tty = tty_port_tty_get(&port->port);
543 if (!tty) 541 if (!tty)
544 return; 542 return;
545 543
544 dev_dbg(tty->dev, "%s - port %d\n", __func__, port->number);
545
546 tty_wakeup(tty); 546 tty_wakeup(tty);
547 tty_kref_put(tty); 547 tty_kref_put(tty);
548} 548}
@@ -575,7 +575,7 @@ static void port_release(struct device *dev)
575 struct usb_serial_port *port = to_usb_serial_port(dev); 575 struct usb_serial_port *port = to_usb_serial_port(dev);
576 int i; 576 int i;
577 577
578 dbg ("%s - %s", __func__, dev_name(dev)); 578 dev_dbg(dev, "%s\n", __func__);
579 579
580 /* 580 /*
581 * Stop all the traffic before cancelling the work, so that 581 * Stop all the traffic before cancelling the work, so that
@@ -644,12 +644,12 @@ static const struct usb_device_id *get_iface_id(struct usb_serial_driver *drv,
644 644
645 id = usb_match_id(intf, drv->id_table); 645 id = usb_match_id(intf, drv->id_table);
646 if (id) { 646 if (id) {
647 dbg("static descriptor matches"); 647 dev_dbg(&intf->dev, "static descriptor matches\n");
648 goto exit; 648 goto exit;
649 } 649 }
650 id = match_dynamic_id(intf, drv); 650 id = match_dynamic_id(intf, drv);
651 if (id) 651 if (id)
652 dbg("dynamic descriptor matches"); 652 dev_dbg(&intf->dev, "dynamic descriptor matches\n");
653exit: 653exit:
654 return id; 654 return id;
655} 655}
@@ -703,6 +703,7 @@ static const struct tty_port_operations serial_port_ops = {
703static int usb_serial_probe(struct usb_interface *interface, 703static int usb_serial_probe(struct usb_interface *interface,
704 const struct usb_device_id *id) 704 const struct usb_device_id *id)
705{ 705{
706 struct device *ddev = &interface->dev;
706 struct usb_device *dev = interface_to_usbdev(interface); 707 struct usb_device *dev = interface_to_usbdev(interface);
707 struct usb_serial *serial = NULL; 708 struct usb_serial *serial = NULL;
708 struct usb_serial_port *port; 709 struct usb_serial_port *port;
@@ -729,13 +730,13 @@ static int usb_serial_probe(struct usb_interface *interface,
729 type = search_serial_device(interface); 730 type = search_serial_device(interface);
730 if (!type) { 731 if (!type) {
731 mutex_unlock(&table_lock); 732 mutex_unlock(&table_lock);
732 dbg("none matched"); 733 dev_dbg(ddev, "none matched\n");
733 return -ENODEV; 734 return -ENODEV;
734 } 735 }
735 736
736 if (!try_module_get(type->driver.owner)) { 737 if (!try_module_get(type->driver.owner)) {
737 mutex_unlock(&table_lock); 738 mutex_unlock(&table_lock);
738 dev_err(&interface->dev, "module get failed, exiting\n"); 739 dev_err(ddev, "module get failed, exiting\n");
739 return -EIO; 740 return -EIO;
740 } 741 }
741 mutex_unlock(&table_lock); 742 mutex_unlock(&table_lock);
@@ -743,7 +744,7 @@ static int usb_serial_probe(struct usb_interface *interface,
743 serial = create_serial(dev, interface, type); 744 serial = create_serial(dev, interface, type);
744 if (!serial) { 745 if (!serial) {
745 module_put(type->driver.owner); 746 module_put(type->driver.owner);
746 dev_err(&interface->dev, "%s - out of memory\n", __func__); 747 dev_err(ddev, "%s - out of memory\n", __func__);
747 return -ENOMEM; 748 return -ENOMEM;
748 } 749 }
749 750
@@ -755,7 +756,7 @@ static int usb_serial_probe(struct usb_interface *interface,
755 retval = type->probe(serial, id); 756 retval = type->probe(serial, id);
756 757
757 if (retval) { 758 if (retval) {
758 dbg("sub driver rejected device"); 759 dev_dbg(ddev, "sub driver rejected device\n");
759 usb_serial_put(serial); 760 usb_serial_put(serial);
760 module_put(type->driver.owner); 761 module_put(type->driver.owner);
761 return retval; 762 return retval;
@@ -770,28 +771,28 @@ static int usb_serial_probe(struct usb_interface *interface,
770 771
771 if (usb_endpoint_is_bulk_in(endpoint)) { 772 if (usb_endpoint_is_bulk_in(endpoint)) {
772 /* we found a bulk in endpoint */ 773 /* we found a bulk in endpoint */
773 dbg("found bulk in on endpoint %d", i); 774 dev_dbg(ddev, "found bulk in on endpoint %d\n", i);
774 bulk_in_endpoint[num_bulk_in] = endpoint; 775 bulk_in_endpoint[num_bulk_in] = endpoint;
775 ++num_bulk_in; 776 ++num_bulk_in;
776 } 777 }
777 778
778 if (usb_endpoint_is_bulk_out(endpoint)) { 779 if (usb_endpoint_is_bulk_out(endpoint)) {
779 /* we found a bulk out endpoint */ 780 /* we found a bulk out endpoint */
780 dbg("found bulk out on endpoint %d", i); 781 dev_dbg(ddev, "found bulk out on endpoint %d\n", i);
781 bulk_out_endpoint[num_bulk_out] = endpoint; 782 bulk_out_endpoint[num_bulk_out] = endpoint;
782 ++num_bulk_out; 783 ++num_bulk_out;
783 } 784 }
784 785
785 if (usb_endpoint_is_int_in(endpoint)) { 786 if (usb_endpoint_is_int_in(endpoint)) {
786 /* we found a interrupt in endpoint */ 787 /* we found a interrupt in endpoint */
787 dbg("found interrupt in on endpoint %d", i); 788 dev_dbg(ddev, "found interrupt in on endpoint %d\n", i);
788 interrupt_in_endpoint[num_interrupt_in] = endpoint; 789 interrupt_in_endpoint[num_interrupt_in] = endpoint;
789 ++num_interrupt_in; 790 ++num_interrupt_in;
790 } 791 }
791 792
792 if (usb_endpoint_is_int_out(endpoint)) { 793 if (usb_endpoint_is_int_out(endpoint)) {
793 /* we found an interrupt out endpoint */ 794 /* we found an interrupt out endpoint */
794 dbg("found interrupt out on endpoint %d", i); 795 dev_dbg(ddev, "found interrupt out on endpoint %d\n", i);
795 interrupt_out_endpoint[num_interrupt_out] = endpoint; 796 interrupt_out_endpoint[num_interrupt_out] = endpoint;
796 ++num_interrupt_out; 797 ++num_interrupt_out;
797 } 798 }
@@ -815,7 +816,7 @@ static int usb_serial_probe(struct usb_interface *interface,
815 endpoint = &iface_desc->endpoint[i].desc; 816 endpoint = &iface_desc->endpoint[i].desc;
816 if (usb_endpoint_is_int_in(endpoint)) { 817 if (usb_endpoint_is_int_in(endpoint)) {
817 /* we found a interrupt in endpoint */ 818 /* we found a interrupt in endpoint */
818 dbg("found interrupt in for Prolific device on separate interface"); 819 dev_dbg(ddev, "found interrupt in for Prolific device on separate interface\n");
819 interrupt_in_endpoint[num_interrupt_in] = endpoint; 820 interrupt_in_endpoint[num_interrupt_in] = endpoint;
820 ++num_interrupt_in; 821 ++num_interrupt_in;
821 } 822 }
@@ -827,7 +828,7 @@ static int usb_serial_probe(struct usb_interface *interface,
827 * properly during a later invocation of usb_serial_probe 828 * properly during a later invocation of usb_serial_probe
828 */ 829 */
829 if (num_bulk_in == 0 || num_bulk_out == 0) { 830 if (num_bulk_in == 0 || num_bulk_out == 0) {
830 dev_info(&interface->dev, "PL-2303 hack: descriptors matched but endpoints did not\n"); 831 dev_info(ddev, "PL-2303 hack: descriptors matched but endpoints did not\n");
831 usb_serial_put(serial); 832 usb_serial_put(serial);
832 module_put(type->driver.owner); 833 module_put(type->driver.owner);
833 return -ENODEV; 834 return -ENODEV;
@@ -840,14 +841,13 @@ static int usb_serial_probe(struct usb_interface *interface,
840 if (type == &usb_serial_generic_device) { 841 if (type == &usb_serial_generic_device) {
841 num_ports = num_bulk_out; 842 num_ports = num_bulk_out;
842 if (num_ports == 0) { 843 if (num_ports == 0) {
843 dev_err(&interface->dev, 844 dev_err(ddev, "Generic device with no bulk out, not allowed.\n");
844 "Generic device with no bulk out, not allowed.\n");
845 usb_serial_put(serial); 845 usb_serial_put(serial);
846 module_put(type->driver.owner); 846 module_put(type->driver.owner);
847 return -EIO; 847 return -EIO;
848 } 848 }
849 dev_info(&interface->dev, "The \"generic\" usb-serial driver is only for testing and one-off prototypes.\n"); 849 dev_info(ddev, "The \"generic\" usb-serial driver is only for testing and one-off prototypes.\n");
850 dev_info(&interface->dev, "Tell linux-usb@vger.kernel.org to add your device to a proper driver.\n"); 850 dev_info(ddev, "Tell linux-usb@vger.kernel.org to add your device to a proper driver.\n");
851 } 851 }
852#endif 852#endif
853 if (!num_ports) { 853 if (!num_ports) {
@@ -865,8 +865,7 @@ static int usb_serial_probe(struct usb_interface *interface,
865 serial->num_interrupt_out = num_interrupt_out; 865 serial->num_interrupt_out = num_interrupt_out;
866 866
867 /* found all that we need */ 867 /* found all that we need */
868 dev_info(&interface->dev, "%s converter detected\n", 868 dev_info(ddev, "%s converter detected\n", type->description);
869 type->description);
870 869
871 /* create our ports, we need as many as the max endpoints */ 870 /* create our ports, we need as many as the max endpoints */
872 /* we don't use num_ports here because some devices have more 871 /* we don't use num_ports here because some devices have more
@@ -877,8 +876,7 @@ static int usb_serial_probe(struct usb_interface *interface,
877 max_endpoints = max(max_endpoints, (int)serial->num_ports); 876 max_endpoints = max(max_endpoints, (int)serial->num_ports);
878 serial->num_port_pointers = max_endpoints; 877 serial->num_port_pointers = max_endpoints;
879 878
880 dbg("%s - setting up %d port structures for this device", 879 dev_dbg(ddev, "setting up %d port structures for this device", max_endpoints);
881 __func__, max_endpoints);
882 for (i = 0; i < max_endpoints; ++i) { 880 for (i = 0; i < max_endpoints; ++i) {
883 port = kzalloc(sizeof(struct usb_serial_port), GFP_KERNEL); 881 port = kzalloc(sizeof(struct usb_serial_port), GFP_KERNEL);
884 if (!port) 882 if (!port)
@@ -911,15 +909,13 @@ static int usb_serial_probe(struct usb_interface *interface,
911 set_bit(j, &port->read_urbs_free); 909 set_bit(j, &port->read_urbs_free);
912 port->read_urbs[j] = usb_alloc_urb(0, GFP_KERNEL); 910 port->read_urbs[j] = usb_alloc_urb(0, GFP_KERNEL);
913 if (!port->read_urbs[j]) { 911 if (!port->read_urbs[j]) {
914 dev_err(&interface->dev, 912 dev_err(ddev, "No free urbs available\n");
915 "No free urbs available\n");
916 goto probe_error; 913 goto probe_error;
917 } 914 }
918 port->bulk_in_buffers[j] = kmalloc(buffer_size, 915 port->bulk_in_buffers[j] = kmalloc(buffer_size,
919 GFP_KERNEL); 916 GFP_KERNEL);
920 if (!port->bulk_in_buffers[j]) { 917 if (!port->bulk_in_buffers[j]) {
921 dev_err(&interface->dev, 918 dev_err(ddev, "Couldn't allocate bulk_in_buffer\n");
922 "Couldn't allocate bulk_in_buffer\n");
923 goto probe_error; 919 goto probe_error;
924 } 920 }
925 usb_fill_bulk_urb(port->read_urbs[j], dev, 921 usb_fill_bulk_urb(port->read_urbs[j], dev,
@@ -949,15 +945,13 @@ static int usb_serial_probe(struct usb_interface *interface,
949 set_bit(j, &port->write_urbs_free); 945 set_bit(j, &port->write_urbs_free);
950 port->write_urbs[j] = usb_alloc_urb(0, GFP_KERNEL); 946 port->write_urbs[j] = usb_alloc_urb(0, GFP_KERNEL);
951 if (!port->write_urbs[j]) { 947 if (!port->write_urbs[j]) {
952 dev_err(&interface->dev, 948 dev_err(ddev, "No free urbs available\n");
953 "No free urbs available\n");
954 goto probe_error; 949 goto probe_error;
955 } 950 }
956 port->bulk_out_buffers[j] = kmalloc(buffer_size, 951 port->bulk_out_buffers[j] = kmalloc(buffer_size,
957 GFP_KERNEL); 952 GFP_KERNEL);
958 if (!port->bulk_out_buffers[j]) { 953 if (!port->bulk_out_buffers[j]) {
959 dev_err(&interface->dev, 954 dev_err(ddev, "Couldn't allocate bulk_out_buffer\n");
960 "Couldn't allocate bulk_out_buffer\n");
961 goto probe_error; 955 goto probe_error;
962 } 956 }
963 usb_fill_bulk_urb(port->write_urbs[j], dev, 957 usb_fill_bulk_urb(port->write_urbs[j], dev,
@@ -978,8 +972,7 @@ static int usb_serial_probe(struct usb_interface *interface,
978 port = serial->port[i]; 972 port = serial->port[i];
979 port->interrupt_in_urb = usb_alloc_urb(0, GFP_KERNEL); 973 port->interrupt_in_urb = usb_alloc_urb(0, GFP_KERNEL);
980 if (!port->interrupt_in_urb) { 974 if (!port->interrupt_in_urb) {
981 dev_err(&interface->dev, 975 dev_err(ddev, "No free urbs available\n");
982 "No free urbs available\n");
983 goto probe_error; 976 goto probe_error;
984 } 977 }
985 buffer_size = usb_endpoint_maxp(endpoint); 978 buffer_size = usb_endpoint_maxp(endpoint);
@@ -988,8 +981,7 @@ static int usb_serial_probe(struct usb_interface *interface,
988 port->interrupt_in_buffer = kmalloc(buffer_size, 981 port->interrupt_in_buffer = kmalloc(buffer_size,
989 GFP_KERNEL); 982 GFP_KERNEL);
990 if (!port->interrupt_in_buffer) { 983 if (!port->interrupt_in_buffer) {
991 dev_err(&interface->dev, 984 dev_err(ddev, "Couldn't allocate interrupt_in_buffer\n");
992 "Couldn't allocate interrupt_in_buffer\n");
993 goto probe_error; 985 goto probe_error;
994 } 986 }
995 usb_fill_int_urb(port->interrupt_in_urb, dev, 987 usb_fill_int_urb(port->interrupt_in_urb, dev,
@@ -1000,7 +992,7 @@ static int usb_serial_probe(struct usb_interface *interface,
1000 endpoint->bInterval); 992 endpoint->bInterval);
1001 } 993 }
1002 } else if (num_interrupt_in) { 994 } else if (num_interrupt_in) {
1003 dbg("the device claims to support interrupt in transfers, but read_int_callback is not defined"); 995 dev_dbg(ddev, "The device claims to support interrupt in transfers, but read_int_callback is not defined\n");
1004 } 996 }
1005 997
1006 if (serial->type->write_int_callback) { 998 if (serial->type->write_int_callback) {
@@ -1009,8 +1001,7 @@ static int usb_serial_probe(struct usb_interface *interface,
1009 port = serial->port[i]; 1001 port = serial->port[i];
1010 port->interrupt_out_urb = usb_alloc_urb(0, GFP_KERNEL); 1002 port->interrupt_out_urb = usb_alloc_urb(0, GFP_KERNEL);
1011 if (!port->interrupt_out_urb) { 1003 if (!port->interrupt_out_urb) {
1012 dev_err(&interface->dev, 1004 dev_err(ddev, "No free urbs available\n");
1013 "No free urbs available\n");
1014 goto probe_error; 1005 goto probe_error;
1015 } 1006 }
1016 buffer_size = usb_endpoint_maxp(endpoint); 1007 buffer_size = usb_endpoint_maxp(endpoint);
@@ -1020,8 +1011,7 @@ static int usb_serial_probe(struct usb_interface *interface,
1020 port->interrupt_out_buffer = kmalloc(buffer_size, 1011 port->interrupt_out_buffer = kmalloc(buffer_size,
1021 GFP_KERNEL); 1012 GFP_KERNEL);
1022 if (!port->interrupt_out_buffer) { 1013 if (!port->interrupt_out_buffer) {
1023 dev_err(&interface->dev, 1014 dev_err(ddev, "Couldn't allocate interrupt_out_buffer\n");
1024 "Couldn't allocate interrupt_out_buffer\n");
1025 goto probe_error; 1015 goto probe_error;
1026 } 1016 }
1027 usb_fill_int_urb(port->interrupt_out_urb, dev, 1017 usb_fill_int_urb(port->interrupt_out_urb, dev,
@@ -1032,7 +1022,7 @@ static int usb_serial_probe(struct usb_interface *interface,
1032 endpoint->bInterval); 1022 endpoint->bInterval);
1033 } 1023 }
1034 } else if (num_interrupt_out) { 1024 } else if (num_interrupt_out) {
1035 dbg("the device claims to support interrupt out transfers, but write_int_callback is not defined"); 1025 dev_dbg(ddev, "The device claims to support interrupt out transfers, but write_int_callback is not defined\n");
1036 } 1026 }
1037 1027
1038 usb_set_intfdata(interface, serial); 1028 usb_set_intfdata(interface, serial);
@@ -1060,7 +1050,7 @@ static int usb_serial_probe(struct usb_interface *interface,
1060 serial->disconnected = 1; 1050 serial->disconnected = 1;
1061 1051
1062 if (get_free_serial(serial, num_ports, &minor) == NULL) { 1052 if (get_free_serial(serial, num_ports, &minor) == NULL) {
1063 dev_err(&interface->dev, "No more free serial devices\n"); 1053 dev_err(ddev, "No more free serial devices\n");
1064 goto probe_error; 1054 goto probe_error;
1065 } 1055 }
1066 serial->minor = minor; 1056 serial->minor = minor;
@@ -1069,18 +1059,17 @@ static int usb_serial_probe(struct usb_interface *interface,
1069 for (i = 0; i < num_ports; ++i) { 1059 for (i = 0; i < num_ports; ++i) {
1070 port = serial->port[i]; 1060 port = serial->port[i];
1071 dev_set_name(&port->dev, "ttyUSB%d", port->number); 1061 dev_set_name(&port->dev, "ttyUSB%d", port->number);
1072 dbg ("%s - registering %s", __func__, dev_name(&port->dev)); 1062 dev_dbg(ddev, "registering %s", dev_name(&port->dev));
1073 device_enable_async_suspend(&port->dev); 1063 device_enable_async_suspend(&port->dev);
1074 1064
1075 retval = device_add(&port->dev); 1065 retval = device_add(&port->dev);
1076 if (retval) 1066 if (retval)
1077 dev_err(&port->dev, "Error registering port device, " 1067 dev_err(ddev, "Error registering port device, continuing\n");
1078 "continuing\n");
1079 } 1068 }
1080 1069
1081 serial->disconnected = 0; 1070 serial->disconnected = 0;
1082 1071
1083 usb_serial_console_init(debug, minor); 1072 usb_serial_console_init(minor);
1084exit: 1073exit:
1085 module_put(type->driver.owner); 1074 module_put(type->driver.owner);
1086 return 0; 1075 return 0;
@@ -1099,7 +1088,6 @@ static void usb_serial_disconnect(struct usb_interface *interface)
1099 struct usb_serial_port *port; 1088 struct usb_serial_port *port;
1100 1089
1101 usb_serial_console_disconnect(serial); 1090 usb_serial_console_disconnect(serial);
1102 dbg("%s", __func__);
1103 1091
1104 mutex_lock(&serial->disc_mutex); 1092 mutex_lock(&serial->disc_mutex);
1105 /* must set a flag, to signal subdrivers */ 1093 /* must set a flag, to signal subdrivers */
@@ -1234,8 +1222,7 @@ static int __init usb_serial_init(void)
1234 1222
1235 result = bus_register(&usb_serial_bus_type); 1223 result = bus_register(&usb_serial_bus_type);
1236 if (result) { 1224 if (result) {
1237 printk(KERN_ERR "usb-serial: %s - registering bus driver " 1225 pr_err("%s - registering bus driver failed\n", __func__);
1238 "failed\n", __func__);
1239 goto exit_bus; 1226 goto exit_bus;
1240 } 1227 }
1241 1228
@@ -1255,29 +1242,24 @@ static int __init usb_serial_init(void)
1255 tty_set_operations(usb_serial_tty_driver, &serial_ops); 1242 tty_set_operations(usb_serial_tty_driver, &serial_ops);
1256 result = tty_register_driver(usb_serial_tty_driver); 1243 result = tty_register_driver(usb_serial_tty_driver);
1257 if (result) { 1244 if (result) {
1258 printk(KERN_ERR "usb-serial: %s - tty_register_driver failed\n", 1245 pr_err("%s - tty_register_driver failed\n", __func__);
1259 __func__);
1260 goto exit_reg_driver; 1246 goto exit_reg_driver;
1261 } 1247 }
1262 1248
1263 /* register the USB driver */ 1249 /* register the USB driver */
1264 result = usb_register(&usb_serial_driver); 1250 result = usb_register(&usb_serial_driver);
1265 if (result < 0) { 1251 if (result < 0) {
1266 printk(KERN_ERR "usb-serial: %s - usb_register failed\n", 1252 pr_err("%s - usb_register failed\n", __func__);
1267 __func__);
1268 goto exit_tty; 1253 goto exit_tty;
1269 } 1254 }
1270 1255
1271 /* register the generic driver, if we should */ 1256 /* register the generic driver, if we should */
1272 result = usb_serial_generic_register(debug); 1257 result = usb_serial_generic_register();
1273 if (result < 0) { 1258 if (result < 0) {
1274 printk(KERN_ERR "usb-serial: %s - registering generic " 1259 pr_err("%s - registering generic driver failed\n", __func__);
1275 "driver failed\n", __func__);
1276 goto exit_generic; 1260 goto exit_generic;
1277 } 1261 }
1278 1262
1279 printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_DESC "\n");
1280
1281 return result; 1263 return result;
1282 1264
1283exit_generic: 1265exit_generic:
@@ -1290,8 +1272,7 @@ exit_reg_driver:
1290 bus_unregister(&usb_serial_bus_type); 1272 bus_unregister(&usb_serial_bus_type);
1291 1273
1292exit_bus: 1274exit_bus:
1293 printk(KERN_ERR "usb-serial: %s - returning with error %d\n", 1275 pr_err("%s - returning with error %d\n", __func__, result);
1294 __func__, result);
1295 put_tty_driver(usb_serial_tty_driver); 1276 put_tty_driver(usb_serial_tty_driver);
1296 return result; 1277 return result;
1297} 1278}
@@ -1317,7 +1298,7 @@ module_exit(usb_serial_exit);
1317 do { \ 1298 do { \
1318 if (!type->function) { \ 1299 if (!type->function) { \
1319 type->function = usb_serial_generic_##function; \ 1300 type->function = usb_serial_generic_##function; \
1320 dbg("Had to override the " #function \ 1301 pr_debug("Had to override the " #function \
1321 " usb serial operation with the generic one.");\ 1302 " usb serial operation with the generic one.");\
1322 } \ 1303 } \
1323 } while (0) 1304 } while (0)
@@ -1360,12 +1341,10 @@ static int usb_serial_register(struct usb_serial_driver *driver)
1360 1341
1361 retval = usb_serial_bus_register(driver); 1342 retval = usb_serial_bus_register(driver);
1362 if (retval) { 1343 if (retval) {
1363 printk(KERN_ERR "usb-serial: problem %d when registering " 1344 pr_err("problem %d when registering driver %s\n", retval, driver->description);
1364 "driver %s\n", retval, driver->description);
1365 list_del(&driver->driver_list); 1345 list_del(&driver->driver_list);
1366 } else 1346 } else
1367 printk(KERN_INFO "USB Serial support registered for %s\n", 1347 pr_info("USB Serial support registered for %s\n", driver->description);
1368 driver->description);
1369 1348
1370 mutex_unlock(&table_lock); 1349 mutex_unlock(&table_lock);
1371 return retval; 1350 return retval;
@@ -1373,8 +1352,7 @@ static int usb_serial_register(struct usb_serial_driver *driver)
1373 1352
1374static void usb_serial_deregister(struct usb_serial_driver *device) 1353static void usb_serial_deregister(struct usb_serial_driver *device)
1375{ 1354{
1376 printk(KERN_INFO "USB Serial deregistering driver %s\n", 1355 pr_info("USB Serial deregistering driver %s\n", device->description);
1377 device->description);
1378 mutex_lock(&table_lock); 1356 mutex_lock(&table_lock);
1379 list_del(&device->driver_list); 1357 list_del(&device->driver_list);
1380 usb_serial_bus_deregister(device); 1358 usb_serial_bus_deregister(device);
@@ -1425,9 +1403,10 @@ int usb_serial_register_drivers(struct usb_serial_driver *const serial_drivers[]
1425 1403
1426 /* we only set the reset_resume field if the serial_driver has one */ 1404 /* we only set the reset_resume field if the serial_driver has one */
1427 for (sd = serial_drivers; *sd; ++sd) { 1405 for (sd = serial_drivers; *sd; ++sd) {
1428 if ((*sd)->reset_resume) 1406 if ((*sd)->reset_resume) {
1429 udriver->reset_resume = usb_serial_reset_resume; 1407 udriver->reset_resume = usb_serial_reset_resume;
1430 break; 1408 break;
1409 }
1431 } 1410 }
1432 1411
1433 rc = usb_register(udriver); 1412 rc = usb_register(udriver);
@@ -1477,6 +1456,3 @@ EXPORT_SYMBOL_GPL(usb_serial_deregister_drivers);
1477MODULE_AUTHOR(DRIVER_AUTHOR); 1456MODULE_AUTHOR(DRIVER_AUTHOR);
1478MODULE_DESCRIPTION(DRIVER_DESC); 1457MODULE_DESCRIPTION(DRIVER_DESC);
1479MODULE_LICENSE("GPL"); 1458MODULE_LICENSE("GPL");
1480
1481module_param(debug, bool, S_IRUGO | S_IWUSR);
1482MODULE_PARM_DESC(debug, "Debug enabled or not");
diff --git a/drivers/usb/serial/usb_wwan.c b/drivers/usb/serial/usb_wwan.c
index 72b678d90831..e42aa398ed37 100644
--- a/drivers/usb/serial/usb_wwan.c
+++ b/drivers/usb/serial/usb_wwan.c
@@ -37,8 +37,6 @@
37#include <linux/serial.h> 37#include <linux/serial.h>
38#include "usb-wwan.h" 38#include "usb-wwan.h"
39 39
40static bool debug;
41
42void usb_wwan_dtr_rts(struct usb_serial_port *port, int on) 40void usb_wwan_dtr_rts(struct usb_serial_port *port, int on)
43{ 41{
44 struct usb_serial *serial = port->serial; 42 struct usb_serial *serial = port->serial;
@@ -178,7 +176,7 @@ int usb_wwan_ioctl(struct tty_struct *tty,
178{ 176{
179 struct usb_serial_port *port = tty->driver_data; 177 struct usb_serial_port *port = tty->driver_data;
180 178
181 dbg("%s cmd 0x%04x", __func__, cmd); 179 dev_dbg(&port->dev, "%s cmd 0x%04x\n", __func__, cmd);
182 180
183 switch (cmd) { 181 switch (cmd) {
184 case TIOCGSERIAL: 182 case TIOCGSERIAL:
@@ -191,7 +189,7 @@ int usb_wwan_ioctl(struct tty_struct *tty,
191 break; 189 break;
192 } 190 }
193 191
194 dbg("%s arg not supported", __func__); 192 dev_dbg(&port->dev, "%s arg not supported\n", __func__);
195 193
196 return -ENOIOCTLCMD; 194 return -ENOIOCTLCMD;
197} 195}
@@ -212,7 +210,7 @@ int usb_wwan_write(struct tty_struct *tty, struct usb_serial_port *port,
212 portdata = usb_get_serial_port_data(port); 210 portdata = usb_get_serial_port_data(port);
213 intfdata = port->serial->private; 211 intfdata = port->serial->private;
214 212
215 dbg("%s: write (%d chars)", __func__, count); 213 dev_dbg(&port->dev, "%s: write (%d chars)\n", __func__, count);
216 214
217 i = 0; 215 i = 0;
218 left = count; 216 left = count;
@@ -229,8 +227,8 @@ int usb_wwan_write(struct tty_struct *tty, struct usb_serial_port *port,
229 usb_unlink_urb(this_urb); 227 usb_unlink_urb(this_urb);
230 continue; 228 continue;
231 } 229 }
232 dbg("%s: endpoint %d buf %d", __func__, 230 dev_dbg(&port->dev, "%s: endpoint %d buf %d\n", __func__,
233 usb_pipeendpoint(this_urb->pipe), i); 231 usb_pipeendpoint(this_urb->pipe), i);
234 232
235 err = usb_autopm_get_interface_async(port->serial->interface); 233 err = usb_autopm_get_interface_async(port->serial->interface);
236 if (err < 0) 234 if (err < 0)
@@ -249,8 +247,9 @@ int usb_wwan_write(struct tty_struct *tty, struct usb_serial_port *port,
249 spin_unlock_irqrestore(&intfdata->susp_lock, flags); 247 spin_unlock_irqrestore(&intfdata->susp_lock, flags);
250 err = usb_submit_urb(this_urb, GFP_ATOMIC); 248 err = usb_submit_urb(this_urb, GFP_ATOMIC);
251 if (err) { 249 if (err) {
252 dbg("usb_submit_urb %p (write bulk) failed " 250 dev_dbg(&port->dev,
253 "(%d)", this_urb, err); 251 "usb_submit_urb %p (write bulk) failed (%d)\n",
252 this_urb, err);
254 clear_bit(i, &portdata->out_busy); 253 clear_bit(i, &portdata->out_busy);
255 spin_lock_irqsave(&intfdata->susp_lock, flags); 254 spin_lock_irqsave(&intfdata->susp_lock, flags);
256 intfdata->in_flight--; 255 intfdata->in_flight--;
@@ -267,7 +266,7 @@ int usb_wwan_write(struct tty_struct *tty, struct usb_serial_port *port,
267 } 266 }
268 267
269 count -= left; 268 count -= left;
270 dbg("%s: wrote (did %d)", __func__, count); 269 dev_dbg(&port->dev, "%s: wrote (did %d)\n", __func__, count);
271 return count; 270 return count;
272} 271}
273EXPORT_SYMBOL(usb_wwan_write); 272EXPORT_SYMBOL(usb_wwan_write);
@@ -278,15 +277,17 @@ static void usb_wwan_indat_callback(struct urb *urb)
278 int endpoint; 277 int endpoint;
279 struct usb_serial_port *port; 278 struct usb_serial_port *port;
280 struct tty_struct *tty; 279 struct tty_struct *tty;
280 struct device *dev;
281 unsigned char *data = urb->transfer_buffer; 281 unsigned char *data = urb->transfer_buffer;
282 int status = urb->status; 282 int status = urb->status;
283 283
284 endpoint = usb_pipeendpoint(urb->pipe); 284 endpoint = usb_pipeendpoint(urb->pipe);
285 port = urb->context; 285 port = urb->context;
286 dev = &port->dev;
286 287
287 if (status) { 288 if (status) {
288 dbg("%s: nonzero status: %d on endpoint %02x.", 289 dev_dbg(dev, "%s: nonzero status: %d on endpoint %02x.\n",
289 __func__, status, endpoint); 290 __func__, status, endpoint);
290 } else { 291 } else {
291 tty = tty_port_tty_get(&port->port); 292 tty = tty_port_tty_get(&port->port);
292 if (tty) { 293 if (tty) {
@@ -295,7 +296,7 @@ static void usb_wwan_indat_callback(struct urb *urb)
295 urb->actual_length); 296 urb->actual_length);
296 tty_flip_buffer_push(tty); 297 tty_flip_buffer_push(tty);
297 } else 298 } else
298 dbg("%s: empty read urb received", __func__); 299 dev_dbg(dev, "%s: empty read urb received\n", __func__);
299 tty_kref_put(tty); 300 tty_kref_put(tty);
300 } 301 }
301 302
@@ -303,8 +304,7 @@ static void usb_wwan_indat_callback(struct urb *urb)
303 err = usb_submit_urb(urb, GFP_ATOMIC); 304 err = usb_submit_urb(urb, GFP_ATOMIC);
304 if (err) { 305 if (err) {
305 if (err != -EPERM) { 306 if (err != -EPERM) {
306 printk(KERN_ERR "%s: resubmit read urb failed. " 307 dev_err(dev, "%s: resubmit read urb failed. (%d)\n", __func__, err);
307 "(%d)", __func__, err);
308 /* busy also in error unless we are killed */ 308 /* busy also in error unless we are killed */
309 usb_mark_last_busy(port->serial->dev); 309 usb_mark_last_busy(port->serial->dev);
310 } 310 }
@@ -356,7 +356,7 @@ int usb_wwan_write_room(struct tty_struct *tty)
356 data_len += OUT_BUFLEN; 356 data_len += OUT_BUFLEN;
357 } 357 }
358 358
359 dbg("%s: %d", __func__, data_len); 359 dev_dbg(&port->dev, "%s: %d\n", __func__, data_len);
360 return data_len; 360 return data_len;
361} 361}
362EXPORT_SYMBOL(usb_wwan_write_room); 362EXPORT_SYMBOL(usb_wwan_write_room);
@@ -378,7 +378,7 @@ int usb_wwan_chars_in_buffer(struct tty_struct *tty)
378 if (this_urb && test_bit(i, &portdata->out_busy)) 378 if (this_urb && test_bit(i, &portdata->out_busy))
379 data_len += this_urb->transfer_buffer_length; 379 data_len += this_urb->transfer_buffer_length;
380 } 380 }
381 dbg("%s: %d", __func__, data_len); 381 dev_dbg(&port->dev, "%s: %d\n", __func__, data_len);
382 return data_len; 382 return data_len;
383} 383}
384EXPORT_SYMBOL(usb_wwan_chars_in_buffer); 384EXPORT_SYMBOL(usb_wwan_chars_in_buffer);
@@ -401,8 +401,8 @@ int usb_wwan_open(struct tty_struct *tty, struct usb_serial_port *port)
401 continue; 401 continue;
402 err = usb_submit_urb(urb, GFP_KERNEL); 402 err = usb_submit_urb(urb, GFP_KERNEL);
403 if (err) { 403 if (err) {
404 dbg("%s: submit urb %d failed (%d) %d", 404 dev_dbg(&port->dev, "%s: submit urb %d failed (%d) %d\n",
405 __func__, i, err, urb->transfer_buffer_length); 405 __func__, i, err, urb->transfer_buffer_length);
406 } 406 }
407 } 407 }
408 408
@@ -458,7 +458,9 @@ static struct urb *usb_wwan_setup_urb(struct usb_serial *serial, int endpoint,
458 458
459 urb = usb_alloc_urb(0, GFP_KERNEL); /* No ISO */ 459 urb = usb_alloc_urb(0, GFP_KERNEL); /* No ISO */
460 if (urb == NULL) { 460 if (urb == NULL) {
461 dbg("%s: alloc for endpoint %d failed.", __func__, endpoint); 461 dev_dbg(&serial->interface->dev,
462 "%s: alloc for endpoint %d failed.\n", __func__,
463 endpoint);
462 return NULL; 464 return NULL;
463 } 465 }
464 466
@@ -522,8 +524,8 @@ int usb_wwan_startup(struct usb_serial *serial)
522 port = serial->port[i]; 524 port = serial->port[i];
523 portdata = kzalloc(sizeof(*portdata), GFP_KERNEL); 525 portdata = kzalloc(sizeof(*portdata), GFP_KERNEL);
524 if (!portdata) { 526 if (!portdata) {
525 dbg("%s: kmalloc for usb_wwan_port_private (%d) failed!.", 527 dev_dbg(&port->dev, "%s: kmalloc for usb_wwan_port_private (%d) failed!.\n",
526 __func__, i); 528 __func__, i);
527 return 1; 529 return 1;
528 } 530 }
529 init_usb_anchor(&portdata->delayed); 531 init_usb_anchor(&portdata->delayed);
@@ -548,7 +550,8 @@ int usb_wwan_startup(struct usb_serial *serial)
548 continue; 550 continue;
549 err = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); 551 err = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
550 if (err) 552 if (err)
551 dbg("%s: submit irq_in urb failed %d", __func__, err); 553 dev_dbg(&port->dev, "%s: submit irq_in urb failed %d\n",
554 __func__, err);
552 } 555 }
553 usb_wwan_setup_urbs(serial); 556 usb_wwan_setup_urbs(serial);
554 return 0; 557 return 0;
@@ -683,11 +686,11 @@ int usb_wwan_resume(struct usb_serial *serial)
683 for (i = 0; i < serial->num_ports; i++) { 686 for (i = 0; i < serial->num_ports; i++) {
684 port = serial->port[i]; 687 port = serial->port[i];
685 if (!port->interrupt_in_urb) { 688 if (!port->interrupt_in_urb) {
686 dbg("%s: No interrupt URB for port %d", __func__, i); 689 dev_dbg(&port->dev, "%s: No interrupt URB for port\n", __func__);
687 continue; 690 continue;
688 } 691 }
689 err = usb_submit_urb(port->interrupt_in_urb, GFP_NOIO); 692 err = usb_submit_urb(port->interrupt_in_urb, GFP_NOIO);
690 dbg("Submitted interrupt URB for port %d (result %d)", i, err); 693 dev_dbg(&port->dev, "Submitted interrupt URB for port (result %d)\n", err);
691 if (err < 0) { 694 if (err < 0) {
692 dev_err(&port->dev, "%s: Error %d for interrupt URB\n", 695 dev_err(&port->dev, "%s: Error %d for interrupt URB\n",
693 __func__, err); 696 __func__, err);
@@ -733,6 +736,3 @@ MODULE_AUTHOR(DRIVER_AUTHOR);
733MODULE_DESCRIPTION(DRIVER_DESC); 736MODULE_DESCRIPTION(DRIVER_DESC);
734MODULE_VERSION(DRIVER_VERSION); 737MODULE_VERSION(DRIVER_VERSION);
735MODULE_LICENSE("GPL"); 738MODULE_LICENSE("GPL");
736
737module_param(debug, bool, S_IRUGO | S_IWUSR);
738MODULE_PARM_DESC(debug, "Debug messages");
diff --git a/drivers/usb/serial/visor.c b/drivers/usb/serial/visor.c
index f253c91383da..1129aa73c23e 100644
--- a/drivers/usb/serial/visor.c
+++ b/drivers/usb/serial/visor.c
@@ -51,9 +51,6 @@ static int palm_os_3_probe(struct usb_serial *serial,
51static int palm_os_4_probe(struct usb_serial *serial, 51static int palm_os_4_probe(struct usb_serial *serial,
52 const struct usb_device_id *id); 52 const struct usb_device_id *id);
53 53
54/* Parameters that may be passed into the module. */
55static bool debug;
56
57static struct usb_device_id id_table [] = { 54static struct usb_device_id id_table [] = {
58 { USB_DEVICE(HANDSPRING_VENDOR_ID, HANDSPRING_VISOR_ID), 55 { USB_DEVICE(HANDSPRING_VENDOR_ID, HANDSPRING_VISOR_ID),
59 .driver_info = (kernel_ulong_t)&palm_os_3_probe }, 56 .driver_info = (kernel_ulong_t)&palm_os_3_probe },
@@ -310,8 +307,8 @@ static void visor_read_int_callback(struct urb *urb)
310 * Rumor has it this endpoint is used to notify when data 307 * Rumor has it this endpoint is used to notify when data
311 * is ready to be read from the bulk ones. 308 * is ready to be read from the bulk ones.
312 */ 309 */
313 usb_serial_debug_data(debug, &port->dev, __func__, 310 usb_serial_debug_data(&port->dev, __func__, urb->actual_length,
314 urb->actual_length, urb->transfer_buffer); 311 urb->transfer_buffer);
315 312
316exit: 313exit:
317 result = usb_submit_urb(urb, GFP_ATOMIC); 314 result = usb_submit_urb(urb, GFP_ATOMIC);
@@ -443,8 +440,7 @@ static int palm_os_4_probe(struct usb_serial *serial,
443 dev_err(dev, "%s - error %d getting connection info\n", 440 dev_err(dev, "%s - error %d getting connection info\n",
444 __func__, retval); 441 __func__, retval);
445 else 442 else
446 usb_serial_debug_data(debug, &serial->dev->dev, __func__, 443 usb_serial_debug_data(dev, __func__, retval, transfer_buffer);
447 retval, transfer_buffer);
448 444
449 kfree(transfer_buffer); 445 kfree(transfer_buffer);
450 return 0; 446 return 0;
@@ -625,6 +621,3 @@ module_usb_serial_driver(serial_drivers, id_table_combined);
625MODULE_AUTHOR(DRIVER_AUTHOR); 621MODULE_AUTHOR(DRIVER_AUTHOR);
626MODULE_DESCRIPTION(DRIVER_DESC); 622MODULE_DESCRIPTION(DRIVER_DESC);
627MODULE_LICENSE("GPL"); 623MODULE_LICENSE("GPL");
628
629module_param(debug, bool, S_IRUGO | S_IWUSR);
630MODULE_PARM_DESC(debug, "Debug enabled or not");
diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c
index b36077de72b9..346c7efc20b0 100644
--- a/drivers/usb/serial/whiteheat.c
+++ b/drivers/usb/serial/whiteheat.c
@@ -32,12 +32,9 @@
32#include <linux/serial_reg.h> 32#include <linux/serial_reg.h>
33#include <linux/serial.h> 33#include <linux/serial.h>
34#include <linux/usb/serial.h> 34#include <linux/usb/serial.h>
35#include <linux/firmware.h> 35#include <linux/usb/ezusb.h>
36#include <linux/ihex.h>
37#include "whiteheat.h" /* WhiteHEAT specific commands */ 36#include "whiteheat.h" /* WhiteHEAT specific commands */
38 37
39static bool debug;
40
41#ifndef CMSPAR 38#ifndef CMSPAR
42#define CMSPAR 0 39#define CMSPAR 0
43#endif 40#endif
@@ -195,84 +192,15 @@ static int firm_report_tx_done(struct usb_serial_port *port);
195static int whiteheat_firmware_download(struct usb_serial *serial, 192static int whiteheat_firmware_download(struct usb_serial *serial,
196 const struct usb_device_id *id) 193 const struct usb_device_id *id)
197{ 194{
198 int response, ret = -ENOENT; 195 int response;
199 const struct firmware *loader_fw = NULL, *firmware_fw = NULL;
200 const struct ihex_binrec *record;
201 196
202 if (request_ihex_firmware(&firmware_fw, "whiteheat.fw", 197 response = ezusb_fx1_ihex_firmware_download(serial->dev, "whiteheat_loader.fw");
203 &serial->dev->dev)) { 198 if (response >= 0) {
204 dev_err(&serial->dev->dev, 199 response = ezusb_fx1_ihex_firmware_download(serial->dev, "whiteheat.fw");
205 "%s - request \"whiteheat.fw\" failed\n", __func__); 200 if (response >= 0)
206 goto out; 201 return 0;
207 }
208 if (request_ihex_firmware(&loader_fw, "whiteheat_loader.fw",
209 &serial->dev->dev)) {
210 dev_err(&serial->dev->dev,
211 "%s - request \"whiteheat_loader.fw\" failed\n",
212 __func__);
213 goto out;
214 } 202 }
215 ret = 0; 203 return -ENOENT;
216 response = ezusb_set_reset (serial, 1);
217
218 record = (const struct ihex_binrec *)loader_fw->data;
219 while (record) {
220 response = ezusb_writememory (serial, be32_to_cpu(record->addr),
221 (unsigned char *)record->data,
222 be16_to_cpu(record->len), 0xa0);
223 if (response < 0) {
224 dev_err(&serial->dev->dev, "%s - ezusb_writememory "
225 "failed for loader (%d %04X %p %d)\n",
226 __func__, response, be32_to_cpu(record->addr),
227 record->data, be16_to_cpu(record->len));
228 break;
229 }
230 record = ihex_next_binrec(record);
231 }
232
233 response = ezusb_set_reset(serial, 0);
234
235 record = (const struct ihex_binrec *)firmware_fw->data;
236 while (record && be32_to_cpu(record->addr) < 0x1b40)
237 record = ihex_next_binrec(record);
238 while (record) {
239 response = ezusb_writememory (serial, be32_to_cpu(record->addr),
240 (unsigned char *)record->data,
241 be16_to_cpu(record->len), 0xa3);
242 if (response < 0) {
243 dev_err(&serial->dev->dev, "%s - ezusb_writememory "
244 "failed for first firmware step "
245 "(%d %04X %p %d)\n", __func__, response,
246 be32_to_cpu(record->addr), record->data,
247 be16_to_cpu(record->len));
248 break;
249 }
250 ++record;
251 }
252
253 response = ezusb_set_reset(serial, 1);
254
255 record = (const struct ihex_binrec *)firmware_fw->data;
256 while (record && be32_to_cpu(record->addr) < 0x1b40) {
257 response = ezusb_writememory (serial, be32_to_cpu(record->addr),
258 (unsigned char *)record->data,
259 be16_to_cpu(record->len), 0xa0);
260 if (response < 0) {
261 dev_err(&serial->dev->dev, "%s - ezusb_writememory "
262 "failed for second firmware step "
263 "(%d %04X %p %d)\n", __func__, response,
264 be32_to_cpu(record->addr), record->data,
265 be16_to_cpu(record->len));
266 break;
267 }
268 ++record;
269 }
270 ret = 0;
271 response = ezusb_set_reset (serial, 0);
272 out:
273 release_firmware(loader_fw);
274 release_firmware(firmware_fw);
275 return ret;
276} 204}
277 205
278 206
@@ -533,7 +461,7 @@ static int whiteheat_ioctl(struct tty_struct *tty,
533 struct serial_struct serstruct; 461 struct serial_struct serstruct;
534 void __user *user_arg = (void __user *)arg; 462 void __user *user_arg = (void __user *)arg;
535 463
536 dbg("%s - port %d, cmd 0x%.4x", __func__, port->number, cmd); 464 dev_dbg(&port->dev, "%s - cmd 0x%.4x\n", __func__, cmd);
537 465
538 switch (cmd) { 466 switch (cmd) {
539 case TIOCGSERIAL: 467 case TIOCGSERIAL:
@@ -580,7 +508,7 @@ static void command_port_write_callback(struct urb *urb)
580 int status = urb->status; 508 int status = urb->status;
581 509
582 if (status) { 510 if (status) {
583 dbg("nonzero urb status: %d", status); 511 dev_dbg(&urb->dev->dev, "nonzero urb status: %d\n", status);
584 return; 512 return;
585 } 513 }
586} 514}
@@ -596,19 +524,18 @@ static void command_port_read_callback(struct urb *urb)
596 524
597 command_info = usb_get_serial_port_data(command_port); 525 command_info = usb_get_serial_port_data(command_port);
598 if (!command_info) { 526 if (!command_info) {
599 dbg("%s - command_info is NULL, exiting.", __func__); 527 dev_dbg(&urb->dev->dev, "%s - command_info is NULL, exiting.\n", __func__);
600 return; 528 return;
601 } 529 }
602 if (status) { 530 if (status) {
603 dbg("%s - nonzero urb status: %d", __func__, status); 531 dev_dbg(&urb->dev->dev, "%s - nonzero urb status: %d\n", __func__, status);
604 if (status != -ENOENT) 532 if (status != -ENOENT)
605 command_info->command_finished = WHITEHEAT_CMD_FAILURE; 533 command_info->command_finished = WHITEHEAT_CMD_FAILURE;
606 wake_up(&command_info->wait_command); 534 wake_up(&command_info->wait_command);
607 return; 535 return;
608 } 536 }
609 537
610 usb_serial_debug_data(debug, &command_port->dev, 538 usb_serial_debug_data(&command_port->dev, __func__, urb->actual_length, data);
611 __func__, urb->actual_length, data);
612 539
613 if (data[0] == WHITEHEAT_CMD_COMPLETE) { 540 if (data[0] == WHITEHEAT_CMD_COMPLETE) {
614 command_info->command_finished = WHITEHEAT_CMD_COMPLETE; 541 command_info->command_finished = WHITEHEAT_CMD_COMPLETE;
@@ -619,19 +546,19 @@ static void command_port_read_callback(struct urb *urb)
619 } else if (data[0] == WHITEHEAT_EVENT) { 546 } else if (data[0] == WHITEHEAT_EVENT) {
620 /* These are unsolicited reports from the firmware, hence no 547 /* These are unsolicited reports from the firmware, hence no
621 waiting command to wakeup */ 548 waiting command to wakeup */
622 dbg("%s - event received", __func__); 549 dev_dbg(&urb->dev->dev, "%s - event received\n", __func__);
623 } else if (data[0] == WHITEHEAT_GET_DTR_RTS) { 550 } else if (data[0] == WHITEHEAT_GET_DTR_RTS) {
624 memcpy(command_info->result_buffer, &data[1], 551 memcpy(command_info->result_buffer, &data[1],
625 urb->actual_length - 1); 552 urb->actual_length - 1);
626 command_info->command_finished = WHITEHEAT_CMD_COMPLETE; 553 command_info->command_finished = WHITEHEAT_CMD_COMPLETE;
627 wake_up(&command_info->wait_command); 554 wake_up(&command_info->wait_command);
628 } else 555 } else
629 dbg("%s - bad reply from firmware", __func__); 556 dev_dbg(&urb->dev->dev, "%s - bad reply from firmware\n", __func__);
630 557
631 /* Continue trying to always read */ 558 /* Continue trying to always read */
632 result = usb_submit_urb(command_port->read_urb, GFP_ATOMIC); 559 result = usb_submit_urb(command_port->read_urb, GFP_ATOMIC);
633 if (result) 560 if (result)
634 dbg("%s - failed resubmitting read urb, error %d", 561 dev_dbg(&urb->dev->dev, "%s - failed resubmitting read urb, error %d\n",
635 __func__, result); 562 __func__, result);
636} 563}
637 564
@@ -645,11 +572,12 @@ static int firm_send_command(struct usb_serial_port *port, __u8 command,
645 struct usb_serial_port *command_port; 572 struct usb_serial_port *command_port;
646 struct whiteheat_command_private *command_info; 573 struct whiteheat_command_private *command_info;
647 struct whiteheat_private *info; 574 struct whiteheat_private *info;
575 struct device *dev = &port->dev;
648 __u8 *transfer_buffer; 576 __u8 *transfer_buffer;
649 int retval = 0; 577 int retval = 0;
650 int t; 578 int t;
651 579
652 dbg("%s - command %d", __func__, command); 580 dev_dbg(dev, "%s - command %d\n", __func__, command);
653 581
654 command_port = port->serial->port[COMMAND_PORT]; 582 command_port = port->serial->port[COMMAND_PORT];
655 command_info = usb_get_serial_port_data(command_port); 583 command_info = usb_get_serial_port_data(command_port);
@@ -662,7 +590,7 @@ static int firm_send_command(struct usb_serial_port *port, __u8 command,
662 command_port->write_urb->transfer_buffer_length = datasize + 1; 590 command_port->write_urb->transfer_buffer_length = datasize + 1;
663 retval = usb_submit_urb(command_port->write_urb, GFP_NOIO); 591 retval = usb_submit_urb(command_port->write_urb, GFP_NOIO);
664 if (retval) { 592 if (retval) {
665 dbg("%s - submit urb failed", __func__); 593 dev_dbg(dev, "%s - submit urb failed\n", __func__);
666 goto exit; 594 goto exit;
667 } 595 }
668 596
@@ -673,19 +601,19 @@ static int firm_send_command(struct usb_serial_port *port, __u8 command,
673 usb_kill_urb(command_port->write_urb); 601 usb_kill_urb(command_port->write_urb);
674 602
675 if (command_info->command_finished == false) { 603 if (command_info->command_finished == false) {
676 dbg("%s - command timed out.", __func__); 604 dev_dbg(dev, "%s - command timed out.\n", __func__);
677 retval = -ETIMEDOUT; 605 retval = -ETIMEDOUT;
678 goto exit; 606 goto exit;
679 } 607 }
680 608
681 if (command_info->command_finished == WHITEHEAT_CMD_FAILURE) { 609 if (command_info->command_finished == WHITEHEAT_CMD_FAILURE) {
682 dbg("%s - command failed.", __func__); 610 dev_dbg(dev, "%s - command failed.\n", __func__);
683 retval = -EIO; 611 retval = -EIO;
684 goto exit; 612 goto exit;
685 } 613 }
686 614
687 if (command_info->command_finished == WHITEHEAT_CMD_COMPLETE) { 615 if (command_info->command_finished == WHITEHEAT_CMD_COMPLETE) {
688 dbg("%s - command completed.", __func__); 616 dev_dbg(dev, "%s - command completed.\n", __func__);
689 switch (command) { 617 switch (command) {
690 case WHITEHEAT_GET_DTR_RTS: 618 case WHITEHEAT_GET_DTR_RTS:
691 info = usb_get_serial_port_data(port); 619 info = usb_get_serial_port_data(port);
@@ -723,6 +651,7 @@ static int firm_close(struct usb_serial_port *port)
723static void firm_setup_port(struct tty_struct *tty) 651static void firm_setup_port(struct tty_struct *tty)
724{ 652{
725 struct usb_serial_port *port = tty->driver_data; 653 struct usb_serial_port *port = tty->driver_data;
654 struct device *dev = &port->dev;
726 struct whiteheat_port_settings port_settings; 655 struct whiteheat_port_settings port_settings;
727 unsigned int cflag = tty->termios.c_cflag; 656 unsigned int cflag = tty->termios.c_cflag;
728 657
@@ -736,7 +665,7 @@ static void firm_setup_port(struct tty_struct *tty)
736 default: 665 default:
737 case CS8: port_settings.bits = 8; break; 666 case CS8: port_settings.bits = 8; break;
738 } 667 }
739 dbg("%s - data bits = %d", __func__, port_settings.bits); 668 dev_dbg(dev, "%s - data bits = %d\n", __func__, port_settings.bits);
740 669
741 /* determine the parity */ 670 /* determine the parity */
742 if (cflag & PARENB) 671 if (cflag & PARENB)
@@ -752,14 +681,14 @@ static void firm_setup_port(struct tty_struct *tty)
752 port_settings.parity = WHITEHEAT_PAR_EVEN; 681 port_settings.parity = WHITEHEAT_PAR_EVEN;
753 else 682 else
754 port_settings.parity = WHITEHEAT_PAR_NONE; 683 port_settings.parity = WHITEHEAT_PAR_NONE;
755 dbg("%s - parity = %c", __func__, port_settings.parity); 684 dev_dbg(dev, "%s - parity = %c\n", __func__, port_settings.parity);
756 685
757 /* figure out the stop bits requested */ 686 /* figure out the stop bits requested */
758 if (cflag & CSTOPB) 687 if (cflag & CSTOPB)
759 port_settings.stop = 2; 688 port_settings.stop = 2;
760 else 689 else
761 port_settings.stop = 1; 690 port_settings.stop = 1;
762 dbg("%s - stop bits = %d", __func__, port_settings.stop); 691 dev_dbg(dev, "%s - stop bits = %d\n", __func__, port_settings.stop);
763 692
764 /* figure out the flow control settings */ 693 /* figure out the flow control settings */
765 if (cflag & CRTSCTS) 694 if (cflag & CRTSCTS)
@@ -767,7 +696,7 @@ static void firm_setup_port(struct tty_struct *tty)
767 WHITEHEAT_HFLOW_RTS); 696 WHITEHEAT_HFLOW_RTS);
768 else 697 else
769 port_settings.hflow = WHITEHEAT_HFLOW_NONE; 698 port_settings.hflow = WHITEHEAT_HFLOW_NONE;
770 dbg("%s - hardware flow control = %s %s %s %s", __func__, 699 dev_dbg(dev, "%s - hardware flow control = %s %s %s %s\n", __func__,
771 (port_settings.hflow & WHITEHEAT_HFLOW_CTS) ? "CTS" : "", 700 (port_settings.hflow & WHITEHEAT_HFLOW_CTS) ? "CTS" : "",
772 (port_settings.hflow & WHITEHEAT_HFLOW_RTS) ? "RTS" : "", 701 (port_settings.hflow & WHITEHEAT_HFLOW_RTS) ? "RTS" : "",
773 (port_settings.hflow & WHITEHEAT_HFLOW_DSR) ? "DSR" : "", 702 (port_settings.hflow & WHITEHEAT_HFLOW_DSR) ? "DSR" : "",
@@ -778,16 +707,15 @@ static void firm_setup_port(struct tty_struct *tty)
778 port_settings.sflow = WHITEHEAT_SFLOW_RXTX; 707 port_settings.sflow = WHITEHEAT_SFLOW_RXTX;
779 else 708 else
780 port_settings.sflow = WHITEHEAT_SFLOW_NONE; 709 port_settings.sflow = WHITEHEAT_SFLOW_NONE;
781 dbg("%s - software flow control = %c", __func__, port_settings.sflow); 710 dev_dbg(dev, "%s - software flow control = %c\n", __func__, port_settings.sflow);
782 711
783 port_settings.xon = START_CHAR(tty); 712 port_settings.xon = START_CHAR(tty);
784 port_settings.xoff = STOP_CHAR(tty); 713 port_settings.xoff = STOP_CHAR(tty);
785 dbg("%s - XON = %2x, XOFF = %2x", 714 dev_dbg(dev, "%s - XON = %2x, XOFF = %2x\n", __func__, port_settings.xon, port_settings.xoff);
786 __func__, port_settings.xon, port_settings.xoff);
787 715
788 /* get the baud rate wanted */ 716 /* get the baud rate wanted */
789 port_settings.baud = tty_get_baud_rate(tty); 717 port_settings.baud = tty_get_baud_rate(tty);
790 dbg("%s - baud rate = %d", __func__, port_settings.baud); 718 dev_dbg(dev, "%s - baud rate = %d\n", __func__, port_settings.baud);
791 719
792 /* fixme: should set validated settings */ 720 /* fixme: should set validated settings */
793 tty_encode_baud_rate(tty, port_settings.baud, port_settings.baud); 721 tty_encode_baud_rate(tty, port_settings.baud, port_settings.baud);
@@ -918,6 +846,3 @@ MODULE_LICENSE("GPL");
918 846
919MODULE_FIRMWARE("whiteheat.fw"); 847MODULE_FIRMWARE("whiteheat.fw");
920MODULE_FIRMWARE("whiteheat_loader.fw"); 848MODULE_FIRMWARE("whiteheat_loader.fw");
921
922module_param(debug, bool, S_IRUGO | S_IWUSR);
923MODULE_PARM_DESC(debug, "Debug enabled or not");
diff --git a/drivers/usb/serial/zte_ev.c b/drivers/usb/serial/zte_ev.c
new file mode 100644
index 000000000000..39ee7373b4ee
--- /dev/null
+++ b/drivers/usb/serial/zte_ev.c
@@ -0,0 +1,307 @@
1/*
2 * ZTE_EV USB serial driver
3 *
4 * Copyright (C) 2012 Greg Kroah-Hartman <gregkh@linuxfoundation.org>
5 * Copyright (C) 2012 Linux Foundation
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 *
11 * This driver is based on code found in a ZTE_ENV patch that modified
12 * the usb-serial generic driver. Comments were left in that I think
13 * show the commands used to talk to the device, but I am not sure.
14 */
15#include <linux/kernel.h>
16#include <linux/init.h>
17#include <linux/tty.h>
18#include <linux/slab.h>
19#include <linux/module.h>
20#include <linux/usb.h>
21#include <linux/usb/serial.h>
22#include <linux/uaccess.h>
23
24#define MAX_SETUP_DATA_SIZE 32
25
26static void debug_data(struct device *dev, const char *function, int len,
27 const unsigned char *data, int result)
28{
29 dev_dbg(dev, "result = %d\n", result);
30 if (result == len)
31 dev_dbg(dev, "%s - length = %d, data = %*ph\n", function,
32 len, len, data);
33}
34
35static int zte_ev_usb_serial_open(struct tty_struct *tty,
36 struct usb_serial_port *port)
37{
38 struct usb_device *udev = port->serial->dev;
39 struct device *dev = &port->dev;
40 int result = 0;
41 int len;
42 unsigned char *buf;
43
44 if (port->number != 0)
45 return -ENODEV;
46
47 buf = kmalloc(MAX_SETUP_DATA_SIZE, GFP_KERNEL);
48 if (!buf)
49 return -ENOMEM;
50
51 /* send 1st ctl cmd(CTL 21 22 01 00 00 00 00 00) */
52 len = 0;
53 result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
54 0x22, 0x21,
55 0x0001, 0x0000, NULL, len,
56 HZ * USB_CTRL_GET_TIMEOUT);
57 dev_dbg(dev, "result = %d\n", result);
58
59 /* send 2st cmd and recieve data */
60 /*
61 * 16.0 CTL a1 21 00 00 00 00 07 00 CLASS 25.1.0(5)
62 * 16.0 DI 00 96 00 00 00 00 08
63 */
64 len = 0x0007;
65 result = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
66 0x21, 0xa1,
67 0x0000, 0x0000, buf, len,
68 HZ * USB_CTRL_GET_TIMEOUT);
69 debug_data(dev, __func__, len, buf, result);
70
71 /* send 3 cmd */
72 /*
73 * 16.0 CTL 21 20 00 00 00 00 07 00 CLASS 30.1.0
74 * 16.0 DO 80 25 00 00 00 00 08 .%..... 30.2.0
75 */
76 len = 0x0007;
77 buf[0] = 0x80;
78 buf[1] = 0x25;
79 buf[2] = 0x00;
80 buf[3] = 0x00;
81 buf[4] = 0x00;
82 buf[5] = 0x00;
83 buf[6] = 0x08;
84 result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
85 0x20, 0x21,
86 0x0000, 0x0000, buf, len,
87 HZ * USB_CTRL_GET_TIMEOUT);
88 debug_data(dev, __func__, len, buf, result);
89
90 /* send 4 cmd */
91 /*
92 * 16.0 CTL 21 22 03 00 00 00 00 00
93 */
94 len = 0;
95 result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
96 0x22, 0x21,
97 0x0003, 0x0000, NULL, len,
98 HZ * USB_CTRL_GET_TIMEOUT);
99 dev_dbg(dev, "result = %d\n", result);
100
101 /* send 5 cmd */
102 /*
103 * 16.0 CTL a1 21 00 00 00 00 07 00 CLASS 33.1.0
104 * 16.0 DI 80 25 00 00 00 00 08
105 */
106 len = 0x0007;
107 result = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
108 0x21, 0xa1,
109 0x0000, 0x0000, buf, len,
110 HZ * USB_CTRL_GET_TIMEOUT);
111 debug_data(dev, __func__, len, buf, result);
112
113 /* send 6 cmd */
114 /*
115 * 16.0 CTL 21 20 00 00 00 00 07 00 CLASS 34.1.0
116 * 16.0 DO 80 25 00 00 00 00 08
117 */
118 len = 0x0007;
119 buf[0] = 0x80;
120 buf[1] = 0x25;
121 buf[2] = 0x00;
122 buf[3] = 0x00;
123 buf[4] = 0x00;
124 buf[5] = 0x00;
125 buf[6] = 0x08;
126 result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
127 0x20, 0x21,
128 0x0000, 0x0000, buf, len,
129 HZ * USB_CTRL_GET_TIMEOUT);
130 debug_data(dev, __func__, len, buf, result);
131 kfree(buf);
132
133 return usb_serial_generic_open(tty, port);
134}
135
136/*
137 * CTL 21 22 02 00 00 00 00 00 CLASS 338.1.0
138 *
139 * 16.1 DI a1 20 00 00 00 00 02 00 02 00 . ........ 340.1.0
140 * 16.0 CTL 21 22 03 00 00 00 00 00 CLASS 341.1.0
141 *
142 * 16.0 CTL a1 21 00 00 00 00 07 00 CLASS 346.1.0(3)
143 * 16.0 DI 00 08 07 00 00 00 08 ....... 346.2.0
144 *
145 * 16.0 CTL 21 20 00 00 00 00 07 00 CLASS 349.1.0
146 * 16.0 DO 00 c2 01 00 00 00 08 ....... 349.2.0
147 *
148 * 16.0 CTL 21 22 03 00 00 00 00 00 CLASS 350.1.0(2)
149 *
150 * 16.0 CTL a1 21 00 00 00 00 07 00 CLASS 352.1.0
151 * 16.0 DI 00 c2 01 00 00 00 08 ....... 352.2.0
152 *
153 * 16.1 DI a1 20 00 00 00 00 02 00 02 00 . ........ 353.1.0
154 *
155 * 16.0 CTL 21 20 00 00 00 00 07 00 CLASS 354.1.0
156 * 16.0 DO 00 c2 01 00 00 00 08 ....... 354.2.0
157 *
158 * 16.0 CTL 21 22 03 00 00 00 00 00
159*/
160
161static void zte_ev_usb_serial_close(struct usb_serial_port *port)
162{
163 struct usb_device *udev = port->serial->dev;
164 struct device *dev = &port->dev;
165 int result = 0;
166 int len;
167 unsigned char *buf;
168
169 if (port->number != 0)
170 return;
171
172 buf = kmalloc(MAX_SETUP_DATA_SIZE, GFP_KERNEL);
173 if (!buf)
174 return;
175
176 /* send 1st ctl cmd(CTL 21 22 02 00 00 00 00 00) */
177 len = 0;
178 result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
179 0x22, 0x21,
180 0x0002, 0x0000, NULL, len,
181 HZ * USB_CTRL_GET_TIMEOUT);
182 dev_dbg(dev, "result = %d\n", result);
183
184 /* send 2st ctl cmd(CTL 21 22 03 00 00 00 00 00 ) */
185 len = 0;
186 result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
187 0x22, 0x21,
188 0x0003, 0x0000, NULL, len,
189 HZ * USB_CTRL_GET_TIMEOUT);
190 dev_dbg(dev, "result = %d\n", result);
191
192 /* send 3st cmd and recieve data */
193 /*
194 * 16.0 CTL a1 21 00 00 00 00 07 00 CLASS 25.1.0(5)
195 * 16.0 DI 00 08 07 00 00 00 08
196 */
197 len = 0x0007;
198 result = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
199 0x21, 0xa1,
200 0x0000, 0x0000, buf, len,
201 HZ * USB_CTRL_GET_TIMEOUT);
202 debug_data(dev, __func__, len, buf, result);
203
204 /* send 4 cmd */
205 /*
206 * 16.0 CTL 21 20 00 00 00 00 07 00 CLASS 30.1.0
207 * 16.0 DO 00 c2 01 00 00 00 08 .%..... 30.2.0
208 */
209 len = 0x0007;
210 buf[0] = 0x00;
211 buf[1] = 0xc2;
212 buf[2] = 0x01;
213 buf[3] = 0x00;
214 buf[4] = 0x00;
215 buf[5] = 0x00;
216 buf[6] = 0x08;
217 result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
218 0x20, 0x21,
219 0x0000, 0x0000, buf, len,
220 HZ * USB_CTRL_GET_TIMEOUT);
221 debug_data(dev, __func__, len, buf, result);
222
223 /* send 5 cmd */
224 /*
225 * 16.0 CTL 21 22 03 00 00 00 00 00
226 */
227 len = 0;
228 result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
229 0x22, 0x21,
230 0x0003, 0x0000, NULL, len,
231 HZ * USB_CTRL_GET_TIMEOUT);
232 dev_dbg(dev, "result = %d\n", result);
233
234 /* send 6 cmd */
235 /*
236 * 16.0 CTL a1 21 00 00 00 00 07 00 CLASS 33.1.0
237 * 16.0 DI 00 c2 01 00 00 00 08
238 */
239 len = 0x0007;
240 result = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
241 0x21, 0xa1,
242 0x0000, 0x0000, buf, len,
243 HZ * USB_CTRL_GET_TIMEOUT);
244 debug_data(dev, __func__, len, buf, result);
245
246 /* send 7 cmd */
247 /*
248 * 16.0 CTL 21 20 00 00 00 00 07 00 CLASS 354.1.0
249 * 16.0 DO 00 c2 01 00 00 00 08 ....... 354.2.0
250 */
251 len = 0x0007;
252 buf[0] = 0x00;
253 buf[1] = 0xc2;
254 buf[2] = 0x01;
255 buf[3] = 0x00;
256 buf[4] = 0x00;
257 buf[5] = 0x00;
258 buf[6] = 0x08;
259 result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
260 0x20, 0x21,
261 0x0000, 0x0000, buf, len,
262 HZ * USB_CTRL_GET_TIMEOUT);
263 debug_data(dev, __func__, len, buf, result);
264
265 /* send 8 cmd */
266 /*
267 * 16.0 CTL 21 22 03 00 00 00 00 00
268 */
269 len = 0;
270 result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
271 0x22, 0x21,
272 0x0003, 0x0000, NULL, len,
273 HZ * USB_CTRL_GET_TIMEOUT);
274 dev_dbg(dev, "result = %d\n", result);
275
276 kfree(buf);
277
278 usb_serial_generic_close(port);
279}
280
281static const struct usb_device_id id_table[] = {
282 { USB_DEVICE(0x19d2, 0xffff) }, /* AC8700 */
283 { USB_DEVICE(0x19d2, 0xfffe) },
284 { USB_DEVICE(0x19d2, 0xfffd) }, /* MG880 */
285 { USB_DEVICE(0x05C6, 0x3197) },
286 { USB_DEVICE(0x05C6, 0x6000) },
287 { },
288};
289MODULE_DEVICE_TABLE(usb, id_table);
290
291static struct usb_serial_driver zio_device = {
292 .driver = {
293 .owner = THIS_MODULE,
294 .name = "zte_ev",
295 },
296 .id_table = id_table,
297 .num_ports = 1,
298 .open = zte_ev_usb_serial_open,
299 .close = zte_ev_usb_serial_close,
300};
301
302static struct usb_serial_driver * const serial_drivers[] = {
303 &zio_device, NULL
304};
305
306module_usb_serial_driver(serial_drivers, id_table);
307MODULE_LICENSE("GPL v2");