aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/ch341.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/serial/ch341.c')
-rw-r--r--drivers/usb/serial/ch341.c49
1 files changed, 24 insertions, 25 deletions
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");