aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/mct_u232.c
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-09-14 18:08:30 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-09-14 18:08:30 -0400
commit4a770ccaae1fd2ecad9dcc3f7942d3b163ecf362 (patch)
treef5aeea86bfe5c3126e1b0c91a6a9cf67d7d963cb /drivers/usb/serial/mct_u232.c
parent2621cee19a33a713d539fea9870e5fd56aa1fcd5 (diff)
USB: serial: mct_u232.c: remove dbg() usage
dbg() was a very old USB-serial-specific macro. This patch removes it from being used in the driver and uses dev_dbg() instead. CC: Johan Hovold <jhovold@gmail.com> CC: Rusty Russell <rusty@rustcorp.com.au> CC: Alan Stern <stern@rowland.harvard.edu> CC: Mauro Carvalho Chehab <mchehab@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/serial/mct_u232.c')
-rw-r--r--drivers/usb/serial/mct_u232.c96
1 files changed, 43 insertions, 53 deletions
diff --git a/drivers/usb/serial/mct_u232.c b/drivers/usb/serial/mct_u232.c
index a71fa0aa0406..ab8f9ff75abd 100644
--- a/drivers/usb/serial/mct_u232.c
+++ b/drivers/usb/serial/mct_u232.c
@@ -214,7 +214,7 @@ static int mct_u232_set_baud_rate(struct tty_struct *tty,
214 value, rc); 214 value, rc);
215 else 215 else
216 tty_encode_baud_rate(tty, speed, speed); 216 tty_encode_baud_rate(tty, speed, speed);
217 dbg("set_baud_rate: value: 0x%x, divisor: 0x%x", value, divisor); 217 dev_dbg(&port->dev, "set_baud_rate: value: 0x%x, divisor: 0x%x\n", value, divisor);
218 218
219 /* Mimic the MCT-supplied Windows driver (version 1.21P.0104), which 219 /* Mimic the MCT-supplied Windows driver (version 1.21P.0104), which
220 always sends two extra USB 'device request' messages after the 220 always sends two extra USB 'device request' messages after the
@@ -247,8 +247,8 @@ static int mct_u232_set_baud_rate(struct tty_struct *tty,
247 if (port && C_CRTSCTS(tty)) 247 if (port && C_CRTSCTS(tty))
248 cts_enable_byte = 1; 248 cts_enable_byte = 1;
249 249
250 dbg("set_baud_rate: send second control message, data = %02X", 250 dev_dbg(&port->dev, "set_baud_rate: send second control message, data = %02X\n",
251 cts_enable_byte); 251 cts_enable_byte);
252 buf[0] = cts_enable_byte; 252 buf[0] = cts_enable_byte;
253 rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), 253 rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
254 MCT_U232_SET_CTS_REQUEST, 254 MCT_U232_SET_CTS_REQUEST,
@@ -263,7 +263,8 @@ static int mct_u232_set_baud_rate(struct tty_struct *tty,
263 return rc; 263 return rc;
264} /* mct_u232_set_baud_rate */ 264} /* mct_u232_set_baud_rate */
265 265
266static int mct_u232_set_line_ctrl(struct usb_serial *serial, unsigned char lcr) 266static int mct_u232_set_line_ctrl(struct usb_serial_port *port,
267 unsigned char lcr)
267{ 268{
268 int rc; 269 int rc;
269 unsigned char *buf; 270 unsigned char *buf;
@@ -273,20 +274,19 @@ static int mct_u232_set_line_ctrl(struct usb_serial *serial, unsigned char lcr)
273 return -ENOMEM; 274 return -ENOMEM;
274 275
275 buf[0] = lcr; 276 buf[0] = lcr;
276 rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), 277 rc = usb_control_msg(port->serial->dev, usb_sndctrlpipe(port->serial->dev, 0),
277 MCT_U232_SET_LINE_CTRL_REQUEST, 278 MCT_U232_SET_LINE_CTRL_REQUEST,
278 MCT_U232_SET_REQUEST_TYPE, 279 MCT_U232_SET_REQUEST_TYPE,
279 0, 0, buf, MCT_U232_SET_LINE_CTRL_SIZE, 280 0, 0, buf, MCT_U232_SET_LINE_CTRL_SIZE,
280 WDR_TIMEOUT); 281 WDR_TIMEOUT);
281 if (rc < 0) 282 if (rc < 0)
282 dev_err(&serial->dev->dev, 283 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); 284 dev_dbg(&port->dev, "set_line_ctrl: 0x%x\n", lcr);
284 dbg("set_line_ctrl: 0x%x", lcr);
285 kfree(buf); 285 kfree(buf);
286 return rc; 286 return rc;
287} /* mct_u232_set_line_ctrl */ 287} /* mct_u232_set_line_ctrl */
288 288
289static int mct_u232_set_modem_ctrl(struct usb_serial *serial, 289static int mct_u232_set_modem_ctrl(struct usb_serial_port *port,
290 unsigned int control_state) 290 unsigned int control_state)
291{ 291{
292 int rc; 292 int rc;
@@ -304,25 +304,24 @@ static int mct_u232_set_modem_ctrl(struct usb_serial *serial,
304 mcr |= MCT_U232_MCR_RTS; 304 mcr |= MCT_U232_MCR_RTS;
305 305
306 buf[0] = mcr; 306 buf[0] = mcr;
307 rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), 307 rc = usb_control_msg(port->serial->dev, usb_sndctrlpipe(port->serial->dev, 0),
308 MCT_U232_SET_MODEM_CTRL_REQUEST, 308 MCT_U232_SET_MODEM_CTRL_REQUEST,
309 MCT_U232_SET_REQUEST_TYPE, 309 MCT_U232_SET_REQUEST_TYPE,
310 0, 0, buf, MCT_U232_SET_MODEM_CTRL_SIZE, 310 0, 0, buf, MCT_U232_SET_MODEM_CTRL_SIZE,
311 WDR_TIMEOUT); 311 WDR_TIMEOUT);
312 kfree(buf); 312 kfree(buf);
313 313
314 dbg("set_modem_ctrl: state=0x%x ==> mcr=0x%x", control_state, mcr); 314 dev_dbg(&port->dev, "set_modem_ctrl: state=0x%x ==> mcr=0x%x\n", control_state, mcr);
315 315
316 if (rc < 0) { 316 if (rc < 0) {
317 dev_err(&serial->dev->dev, 317 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; 318 return rc;
320 } 319 }
321 return 0; 320 return 0;
322} /* mct_u232_set_modem_ctrl */ 321} /* mct_u232_set_modem_ctrl */
323 322
324static int mct_u232_get_modem_stat(struct usb_serial *serial, 323static int mct_u232_get_modem_stat(struct usb_serial_port *port,
325 unsigned char *msr) 324 unsigned char *msr)
326{ 325{
327 int rc; 326 int rc;
328 unsigned char *buf; 327 unsigned char *buf;
@@ -332,19 +331,18 @@ static int mct_u232_get_modem_stat(struct usb_serial *serial,
332 *msr = 0; 331 *msr = 0;
333 return -ENOMEM; 332 return -ENOMEM;
334 } 333 }
335 rc = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), 334 rc = usb_control_msg(port->serial->dev, usb_rcvctrlpipe(port->serial->dev, 0),
336 MCT_U232_GET_MODEM_STAT_REQUEST, 335 MCT_U232_GET_MODEM_STAT_REQUEST,
337 MCT_U232_GET_REQUEST_TYPE, 336 MCT_U232_GET_REQUEST_TYPE,
338 0, 0, buf, MCT_U232_GET_MODEM_STAT_SIZE, 337 0, 0, buf, MCT_U232_GET_MODEM_STAT_SIZE,
339 WDR_TIMEOUT); 338 WDR_TIMEOUT);
340 if (rc < 0) { 339 if (rc < 0) {
341 dev_err(&serial->dev->dev, 340 dev_err(&port->dev, "Get MODEM STATus failed (error = %d)\n", rc);
342 "Get MODEM STATus failed (error = %d)\n", rc);
343 *msr = 0; 341 *msr = 0;
344 } else { 342 } else {
345 *msr = buf[0]; 343 *msr = buf[0];
346 } 344 }
347 dbg("get_modem_stat: 0x%x", *msr); 345 dev_dbg(&port->dev, "get_modem_stat: 0x%x\n", *msr);
348 kfree(buf); 346 kfree(buf);
349 return rc; 347 return rc;
350} /* mct_u232_get_modem_stat */ 348} /* mct_u232_get_modem_stat */
@@ -363,8 +361,8 @@ static void mct_u232_msr_to_icount(struct async_icount *icount,
363 icount->dcd++; 361 icount->dcd++;
364} /* mct_u232_msr_to_icount */ 362} /* mct_u232_msr_to_icount */
365 363
366static void mct_u232_msr_to_state(unsigned int *control_state, 364static void mct_u232_msr_to_state(struct usb_serial_port *port,
367 unsigned char msr) 365 unsigned int *control_state, unsigned char msr)
368{ 366{
369 /* Translate Control Line states */ 367 /* Translate Control Line states */
370 if (msr & MCT_U232_MSR_DSR) 368 if (msr & MCT_U232_MSR_DSR)
@@ -383,7 +381,7 @@ static void mct_u232_msr_to_state(unsigned int *control_state,
383 *control_state |= TIOCM_CD; 381 *control_state |= TIOCM_CD;
384 else 382 else
385 *control_state &= ~TIOCM_CD; 383 *control_state &= ~TIOCM_CD;
386 dbg("msr_to_state: msr=0x%x ==> state=0x%x", msr, *control_state); 384 dev_dbg(&port->dev, "msr_to_state: msr=0x%x ==> state=0x%x\n", msr, *control_state);
387} /* mct_u232_msr_to_state */ 385} /* mct_u232_msr_to_state */
388 386
389/* 387/*
@@ -465,14 +463,14 @@ static int mct_u232_open(struct tty_struct *tty, struct usb_serial_port *port)
465 control_state = priv->control_state; 463 control_state = priv->control_state;
466 last_lcr = priv->last_lcr; 464 last_lcr = priv->last_lcr;
467 spin_unlock_irqrestore(&priv->lock, flags); 465 spin_unlock_irqrestore(&priv->lock, flags);
468 mct_u232_set_modem_ctrl(serial, control_state); 466 mct_u232_set_modem_ctrl(port, control_state);
469 mct_u232_set_line_ctrl(serial, last_lcr); 467 mct_u232_set_line_ctrl(port, last_lcr);
470 468
471 /* Read modem status and update control state */ 469 /* Read modem status and update control state */
472 mct_u232_get_modem_stat(serial, &last_msr); 470 mct_u232_get_modem_stat(port, &last_msr);
473 spin_lock_irqsave(&priv->lock, flags); 471 spin_lock_irqsave(&priv->lock, flags);
474 priv->last_msr = last_msr; 472 priv->last_msr = last_msr;
475 mct_u232_msr_to_state(&priv->control_state, priv->last_msr); 473 mct_u232_msr_to_state(port, &priv->control_state, priv->last_msr);
476 spin_unlock_irqrestore(&priv->lock, flags); 474 spin_unlock_irqrestore(&priv->lock, flags);
477 475
478 retval = usb_submit_urb(port->read_urb, GFP_KERNEL); 476 retval = usb_submit_urb(port->read_urb, GFP_KERNEL);
@@ -512,7 +510,7 @@ static void mct_u232_dtr_rts(struct usb_serial_port *port, int on)
512 priv->control_state &= ~(TIOCM_DTR | TIOCM_RTS); 510 priv->control_state &= ~(TIOCM_DTR | TIOCM_RTS);
513 control_state = priv->control_state; 511 control_state = priv->control_state;
514 spin_unlock_irq(&priv->lock); 512 spin_unlock_irq(&priv->lock);
515 mct_u232_set_modem_ctrl(port->serial, control_state); 513 mct_u232_set_modem_ctrl(port, control_state);
516 } 514 }
517 mutex_unlock(&port->serial->disc_mutex); 515 mutex_unlock(&port->serial->disc_mutex);
518} 516}
@@ -532,7 +530,6 @@ static void mct_u232_read_int_callback(struct urb *urb)
532{ 530{
533 struct usb_serial_port *port = urb->context; 531 struct usb_serial_port *port = urb->context;
534 struct mct_u232_private *priv = usb_get_serial_port_data(port); 532 struct mct_u232_private *priv = usb_get_serial_port_data(port);
535 struct usb_serial *serial = port->serial;
536 struct tty_struct *tty; 533 struct tty_struct *tty;
537 unsigned char *data = urb->transfer_buffer; 534 unsigned char *data = urb->transfer_buffer;
538 int retval; 535 int retval;
@@ -547,20 +544,15 @@ static void mct_u232_read_int_callback(struct urb *urb)
547 case -ENOENT: 544 case -ENOENT:
548 case -ESHUTDOWN: 545 case -ESHUTDOWN:
549 /* this urb is terminated, clean up */ 546 /* this urb is terminated, clean up */
550 dbg("%s - urb shutting down with status: %d", 547 dev_dbg(&port->dev, "%s - urb shutting down with status: %d\n",
551 __func__, status); 548 __func__, status);
552 return; 549 return;
553 default: 550 default:
554 dbg("%s - nonzero urb status received: %d", 551 dev_dbg(&port->dev, "%s - nonzero urb status received: %d\n",
555 __func__, status); 552 __func__, status);
556 goto exit; 553 goto exit;
557 } 554 }
558 555
559 if (!serial) {
560 dbg("%s - bad serial pointer, exiting", __func__);
561 return;
562 }
563
564 usb_serial_debug_data(debug, &port->dev, __func__, 556 usb_serial_debug_data(debug, &port->dev, __func__,
565 urb->actual_length, data); 557 urb->actual_length, data);
566 558
@@ -588,7 +580,7 @@ static void mct_u232_read_int_callback(struct urb *urb)
588 priv->last_msr = data[MCT_U232_MSR_INDEX]; 580 priv->last_msr = data[MCT_U232_MSR_INDEX];
589 581
590 /* Record Control Line states */ 582 /* Record Control Line states */
591 mct_u232_msr_to_state(&priv->control_state, priv->last_msr); 583 mct_u232_msr_to_state(port, &priv->control_state, priv->last_msr);
592 584
593 mct_u232_msr_to_icount(&priv->icount, priv->last_msr); 585 mct_u232_msr_to_icount(&priv->icount, priv->last_msr);
594 586
@@ -656,18 +648,18 @@ static void mct_u232_set_termios(struct tty_struct *tty,
656 648
657 /* reassert DTR and RTS on transition from B0 */ 649 /* reassert DTR and RTS on transition from B0 */
658 if ((old_cflag & CBAUD) == B0) { 650 if ((old_cflag & CBAUD) == B0) {
659 dbg("%s: baud was B0", __func__); 651 dev_dbg(&port->dev, "%s: baud was B0\n", __func__);
660 control_state |= TIOCM_DTR | TIOCM_RTS; 652 control_state |= TIOCM_DTR | TIOCM_RTS;
661 mct_u232_set_modem_ctrl(serial, control_state); 653 mct_u232_set_modem_ctrl(port, control_state);
662 } 654 }
663 655
664 mct_u232_set_baud_rate(tty, serial, port, tty_get_baud_rate(tty)); 656 mct_u232_set_baud_rate(tty, serial, port, tty_get_baud_rate(tty));
665 657
666 if ((cflag & CBAUD) == B0) { 658 if ((cflag & CBAUD) == B0) {
667 dbg("%s: baud is B0", __func__); 659 dev_dbg(&port->dev, "%s: baud is B0\n", __func__);
668 /* Drop RTS and DTR */ 660 /* Drop RTS and DTR */
669 control_state &= ~(TIOCM_DTR | TIOCM_RTS); 661 control_state &= ~(TIOCM_DTR | TIOCM_RTS);
670 mct_u232_set_modem_ctrl(serial, control_state); 662 mct_u232_set_modem_ctrl(port, control_state);
671 } 663 }
672 664
673 /* 665 /*
@@ -704,7 +696,7 @@ static void mct_u232_set_termios(struct tty_struct *tty,
704 last_lcr |= (cflag & CSTOPB) ? 696 last_lcr |= (cflag & CSTOPB) ?
705 MCT_U232_STOP_BITS_2 : MCT_U232_STOP_BITS_1; 697 MCT_U232_STOP_BITS_2 : MCT_U232_STOP_BITS_1;
706 698
707 mct_u232_set_line_ctrl(serial, last_lcr); 699 mct_u232_set_line_ctrl(port, last_lcr);
708 700
709 /* save off the modified port settings */ 701 /* save off the modified port settings */
710 spin_lock_irqsave(&priv->lock, flags); 702 spin_lock_irqsave(&priv->lock, flags);
@@ -716,7 +708,6 @@ static void mct_u232_set_termios(struct tty_struct *tty,
716static void mct_u232_break_ctl(struct tty_struct *tty, int break_state) 708static void mct_u232_break_ctl(struct tty_struct *tty, int break_state)
717{ 709{
718 struct usb_serial_port *port = tty->driver_data; 710 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); 711 struct mct_u232_private *priv = usb_get_serial_port_data(port);
721 unsigned char lcr; 712 unsigned char lcr;
722 unsigned long flags; 713 unsigned long flags;
@@ -728,7 +719,7 @@ static void mct_u232_break_ctl(struct tty_struct *tty, int break_state)
728 lcr |= MCT_U232_SET_BREAK; 719 lcr |= MCT_U232_SET_BREAK;
729 spin_unlock_irqrestore(&priv->lock, flags); 720 spin_unlock_irqrestore(&priv->lock, flags);
730 721
731 mct_u232_set_line_ctrl(serial, lcr); 722 mct_u232_set_line_ctrl(port, lcr);
732} /* mct_u232_break_ctl */ 723} /* mct_u232_break_ctl */
733 724
734 725
@@ -750,7 +741,6 @@ static int mct_u232_tiocmset(struct tty_struct *tty,
750 unsigned int set, unsigned int clear) 741 unsigned int set, unsigned int clear)
751{ 742{
752 struct usb_serial_port *port = tty->driver_data; 743 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); 744 struct mct_u232_private *priv = usb_get_serial_port_data(port);
755 unsigned int control_state; 745 unsigned int control_state;
756 unsigned long flags; 746 unsigned long flags;
@@ -769,7 +759,7 @@ static int mct_u232_tiocmset(struct tty_struct *tty,
769 759
770 priv->control_state = control_state; 760 priv->control_state = control_state;
771 spin_unlock_irqrestore(&priv->lock, flags); 761 spin_unlock_irqrestore(&priv->lock, flags);
772 return mct_u232_set_modem_ctrl(serial, control_state); 762 return mct_u232_set_modem_ctrl(port, control_state);
773} 763}
774 764
775static void mct_u232_throttle(struct tty_struct *tty) 765static void mct_u232_throttle(struct tty_struct *tty)
@@ -784,7 +774,7 @@ static void mct_u232_throttle(struct tty_struct *tty)
784 priv->control_state &= ~TIOCM_RTS; 774 priv->control_state &= ~TIOCM_RTS;
785 control_state = priv->control_state; 775 control_state = priv->control_state;
786 spin_unlock_irq(&priv->lock); 776 spin_unlock_irq(&priv->lock);
787 (void) mct_u232_set_modem_ctrl(port->serial, control_state); 777 mct_u232_set_modem_ctrl(port, control_state);
788 } else { 778 } else {
789 spin_unlock_irq(&priv->lock); 779 spin_unlock_irq(&priv->lock);
790 } 780 }
@@ -802,7 +792,7 @@ static void mct_u232_unthrottle(struct tty_struct *tty)
802 priv->control_state |= TIOCM_RTS; 792 priv->control_state |= TIOCM_RTS;
803 control_state = priv->control_state; 793 control_state = priv->control_state;
804 spin_unlock_irq(&priv->lock); 794 spin_unlock_irq(&priv->lock);
805 (void) mct_u232_set_modem_ctrl(port->serial, control_state); 795 mct_u232_set_modem_ctrl(port, control_state);
806 } else { 796 } else {
807 spin_unlock_irq(&priv->lock); 797 spin_unlock_irq(&priv->lock);
808 } 798 }
@@ -817,13 +807,13 @@ static int mct_u232_ioctl(struct tty_struct *tty,
817 struct async_icount cnow, cprev; 807 struct async_icount cnow, cprev;
818 unsigned long flags; 808 unsigned long flags;
819 809
820 dbg("%s - port %d, cmd = 0x%x", __func__, port->number, cmd); 810 dev_dbg(&port->dev, "%s - cmd = 0x%x\n", __func__, cmd);
821 811
822 switch (cmd) { 812 switch (cmd) {
823 813
824 case TIOCMIWAIT: 814 case TIOCMIWAIT:
825 815
826 dbg("%s (%d) TIOCMIWAIT", __func__, port->number); 816 dev_dbg(&port->dev, "%s TIOCMIWAIT", __func__);
827 817
828 spin_lock_irqsave(&mct_u232_port->lock, flags); 818 spin_lock_irqsave(&mct_u232_port->lock, flags);
829 cprev = mct_u232_port->icount; 819 cprev = mct_u232_port->icount;
@@ -879,8 +869,8 @@ static int mct_u232_get_icount(struct tty_struct *tty,
879 869
880 spin_unlock_irqrestore(&mct_u232_port->lock, flags); 870 spin_unlock_irqrestore(&mct_u232_port->lock, flags);
881 871
882 dbg("%s (%d) TIOCGICOUNT RX=%d, TX=%d", 872 dev_dbg(&port->dev, "%s TIOCGICOUNT RX=%d, TX=%d\n",
883 __func__, port->number, icount->rx, icount->tx); 873 __func__, icount->rx, icount->tx);
884 return 0; 874 return 0;
885} 875}
886 876