aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/pl2303.c
diff options
context:
space:
mode:
authorThiago Galesi <thiagogalesi@gmail.com>2006-07-31 14:39:27 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2006-09-27 14:58:51 -0400
commit372db8a780f63368c6960a167b7a19aad776d704 (patch)
tree02c9a9ce71a28442e126ec183bee00c06aa31875 /drivers/usb/serial/pl2303.c
parenta009b75aa0ed55f0bc473c8a3b3e872cbca807ec (diff)
USB: pl2303: remove 80-columns limit violations in pl2303 driver
Fixes several lines that overrun 80 columns in Prolific pl2303 driver and cleans up some space usages in the function calls. Signed-off-by: Thiago Galesi <thiagogalesi@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/serial/pl2303.c')
-rw-r--r--drivers/usb/serial/pl2303.c252
1 files changed, 123 insertions, 129 deletions
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index 54c32ccce626..90d0e7935665 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -84,7 +84,7 @@ static struct usb_device_id id_table [] = {
84 { } /* Terminating entry */ 84 { } /* Terminating entry */
85}; 85};
86 86
87MODULE_DEVICE_TABLE (usb, id_table); 87MODULE_DEVICE_TABLE(usb, id_table);
88 88
89static struct usb_driver pl2303_driver = { 89static struct usb_driver pl2303_driver = {
90 .name = "pl2303", 90 .name = "pl2303",
@@ -205,7 +205,7 @@ struct pl2303_private {
205}; 205};
206 206
207 207
208static int pl2303_startup (struct usb_serial *serial) 208static int pl2303_startup(struct usb_serial *serial)
209{ 209{
210 struct pl2303_private *priv; 210 struct pl2303_private *priv;
211 enum pl2303_type type = type_0; 211 enum pl2303_type type = type_0;
@@ -247,18 +247,19 @@ cleanup:
247 return -ENOMEM; 247 return -ENOMEM;
248} 248}
249 249
250static int set_control_lines (struct usb_device *dev, u8 value) 250static int set_control_lines(struct usb_device *dev, u8 value)
251{ 251{
252 int retval; 252 int retval;
253 253
254 retval = usb_control_msg (dev, usb_sndctrlpipe (dev, 0), 254 retval = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
255 SET_CONTROL_REQUEST, SET_CONTROL_REQUEST_TYPE, 255 SET_CONTROL_REQUEST, SET_CONTROL_REQUEST_TYPE,
256 value, 0, NULL, 0, 100); 256 value, 0, NULL, 0, 100);
257 dbg("%s - value = %d, retval = %d", __FUNCTION__, value, retval); 257 dbg("%s - value = %d, retval = %d", __FUNCTION__, value, retval);
258 return retval; 258 return retval;
259} 259}
260 260
261static int pl2303_write (struct usb_serial_port *port, const unsigned char *buf, int count) 261static int pl2303_write(struct usb_serial_port *port, const unsigned char *buf,
262 int count)
262{ 263{
263 struct pl2303_private *priv = usb_get_serial_port_data(port); 264 struct pl2303_private *priv = usb_get_serial_port_data(port);
264 unsigned long flags; 265 unsigned long flags;
@@ -293,7 +294,7 @@ static void pl2303_send(struct usb_serial_port *port)
293 } 294 }
294 295
295 count = pl2303_buf_get(priv->buf, port->write_urb->transfer_buffer, 296 count = pl2303_buf_get(priv->buf, port->write_urb->transfer_buffer,
296 port->bulk_out_size); 297 port->bulk_out_size);
297 298
298 if (count == 0) { 299 if (count == 0) {
299 spin_unlock_irqrestore(&priv->lock, flags); 300 spin_unlock_irqrestore(&priv->lock, flags);
@@ -304,13 +305,15 @@ static void pl2303_send(struct usb_serial_port *port)
304 305
305 spin_unlock_irqrestore(&priv->lock, flags); 306 spin_unlock_irqrestore(&priv->lock, flags);
306 307
307 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, count, port->write_urb->transfer_buffer); 308 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, count,
309 port->write_urb->transfer_buffer);
308 310
309 port->write_urb->transfer_buffer_length = count; 311 port->write_urb->transfer_buffer_length = count;
310 port->write_urb->dev = port->serial->dev; 312 port->write_urb->dev = port->serial->dev;
311 result = usb_submit_urb (port->write_urb, GFP_ATOMIC); 313 result = usb_submit_urb(port->write_urb, GFP_ATOMIC);
312 if (result) { 314 if (result) {
313 dev_err(&port->dev, "%s - failed submitting write urb, error %d\n", __FUNCTION__, result); 315 dev_err(&port->dev, "%s - failed submitting write urb,"
316 " error %d\n", __FUNCTION__, result);
314 priv->write_urb_in_use = 0; 317 priv->write_urb_in_use = 0;
315 // TODO: reschedule pl2303_send 318 // TODO: reschedule pl2303_send
316 } 319 }
@@ -350,7 +353,8 @@ static int pl2303_chars_in_buffer(struct usb_serial_port *port)
350 return chars; 353 return chars;
351} 354}
352 355
353static void pl2303_set_termios (struct usb_serial_port *port, struct termios *old_termios) 356static void pl2303_set_termios(struct usb_serial_port *port,
357 struct termios *old_termios)
354{ 358{
355 struct usb_serial *serial = port->serial; 359 struct usb_serial *serial = port->serial;
356 struct pl2303_private *priv = usb_get_serial_port_data(port); 360 struct pl2303_private *priv = usb_get_serial_port_data(port);
@@ -371,7 +375,8 @@ static void pl2303_set_termios (struct usb_serial_port *port, struct termios *ol
371 spin_lock_irqsave(&priv->lock, flags); 375 spin_lock_irqsave(&priv->lock, flags);
372 if (!priv->termios_initialized) { 376 if (!priv->termios_initialized) {
373 *(port->tty->termios) = tty_std_termios; 377 *(port->tty->termios) = tty_std_termios;
374 port->tty->termios->c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL; 378 port->tty->termios->c_cflag = B9600 | CS8 | CREAD |
379 HUPCL | CLOCAL;
375 priv->termios_initialized = 1; 380 priv->termios_initialized = 1;
376 } 381 }
377 spin_unlock_irqrestore(&priv->lock, flags); 382 spin_unlock_irqrestore(&priv->lock, flags);
@@ -380,24 +385,24 @@ static void pl2303_set_termios (struct usb_serial_port *port, struct termios *ol
380 /* check that they really want us to change something */ 385 /* check that they really want us to change something */
381 if (old_termios) { 386 if (old_termios) {
382 if ((cflag == old_termios->c_cflag) && 387 if ((cflag == old_termios->c_cflag) &&
383 (RELEVANT_IFLAG(port->tty->termios->c_iflag) == RELEVANT_IFLAG(old_termios->c_iflag))) { 388 (RELEVANT_IFLAG(port->tty->termios->c_iflag) ==
384 dbg("%s - nothing to change...", __FUNCTION__); 389 RELEVANT_IFLAG(old_termios->c_iflag))) {
385 return; 390 dbg("%s - nothing to change...", __FUNCTION__);
391 return;
386 } 392 }
387 } 393 }
388 394
389 buf = kzalloc (7, GFP_KERNEL); 395 buf = kzalloc(7, GFP_KERNEL);
390 if (!buf) { 396 if (!buf) {
391 dev_err(&port->dev, "%s - out of memory.\n", __FUNCTION__); 397 dev_err(&port->dev, "%s - out of memory.\n", __FUNCTION__);
392 return; 398 return;
393 } 399 }
394
395 i = usb_control_msg (serial->dev, usb_rcvctrlpipe (serial->dev, 0),
396 GET_LINE_REQUEST, GET_LINE_REQUEST_TYPE,
397 0, 0, buf, 7, 100);
398 dbg ("0xa1:0x21:0:0 %d - %x %x %x %x %x %x %x", i,
399 buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6]);
400 400
401 i = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0),
402 GET_LINE_REQUEST, GET_LINE_REQUEST_TYPE,
403 0, 0, buf, 7, 100);
404 dbg("0xa1:0x21:0:0 %d - %x %x %x %x %x %x %x", i,
405 buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6]);
401 406
402 if (cflag & CSIZE) { 407 if (cflag & CSIZE) {
403 switch (cflag & CSIZE) { 408 switch (cflag & CSIZE) {
@@ -429,7 +434,8 @@ static void pl2303_set_termios (struct usb_serial_port *port, struct termios *ol
429 case B230400: baud = 230400; break; 434 case B230400: baud = 230400; break;
430 case B460800: baud = 460800; break; 435 case B460800: baud = 460800; break;
431 default: 436 default:
432 dev_err(&port->dev, "pl2303 driver does not support the baudrate requested (fix it)\n"); 437 dev_err(&port->dev, "pl2303 driver does not support"
438 " the baudrate requested (fix it)\n");
433 break; 439 break;
434 } 440 }
435 dbg("%s - baud = %d", __FUNCTION__, baud); 441 dbg("%s - baud = %d", __FUNCTION__, baud);
@@ -469,10 +475,10 @@ static void pl2303_set_termios (struct usb_serial_port *port, struct termios *ol
469 dbg("%s - parity = none", __FUNCTION__); 475 dbg("%s - parity = none", __FUNCTION__);
470 } 476 }
471 477
472 i = usb_control_msg (serial->dev, usb_sndctrlpipe (serial->dev, 0), 478 i = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
473 SET_LINE_REQUEST, SET_LINE_REQUEST_TYPE, 479 SET_LINE_REQUEST, SET_LINE_REQUEST_TYPE,
474 0, 0, buf, 7, 100); 480 0, 0, buf, 7, 100);
475 dbg ("0x21:0x20:0:0 %d", i); 481 dbg("0x21:0x20:0:0 %d", i);
476 482
477 /* change control lines if we are switching to or from B0 */ 483 /* change control lines if we are switching to or from B0 */
478 spin_lock_irqsave(&priv->lock, flags); 484 spin_lock_irqsave(&priv->lock, flags);
@@ -488,13 +494,13 @@ static void pl2303_set_termios (struct usb_serial_port *port, struct termios *ol
488 } else { 494 } else {
489 spin_unlock_irqrestore(&priv->lock, flags); 495 spin_unlock_irqrestore(&priv->lock, flags);
490 } 496 }
491 497
492 buf[0] = buf[1] = buf[2] = buf[3] = buf[4] = buf[5] = buf[6] = 0; 498 buf[0] = buf[1] = buf[2] = buf[3] = buf[4] = buf[5] = buf[6] = 0;
493 499
494 i = usb_control_msg (serial->dev, usb_rcvctrlpipe (serial->dev, 0), 500 i = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0),
495 GET_LINE_REQUEST, GET_LINE_REQUEST_TYPE, 501 GET_LINE_REQUEST, GET_LINE_REQUEST_TYPE,
496 0, 0, buf, 7, 100); 502 0, 0, buf, 7, 100);
497 dbg ("0xa1:0x21:0:0 %d - %x %x %x %x %x %x %x", i, 503 dbg("0xa1:0x21:0:0 %d - %x %x %x %x %x %x %x", i,
498 buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6]); 504 buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6]);
499 505
500 if (cflag & CRTSCTS) { 506 if (cflag & CRTSCTS) {
@@ -503,18 +509,18 @@ static void pl2303_set_termios (struct usb_serial_port *port, struct termios *ol
503 index = 0x61; 509 index = 0x61;
504 else 510 else
505 index = 0x41; 511 index = 0x41;
506 i = usb_control_msg(serial->dev, 512 i = usb_control_msg(serial->dev,
507 usb_sndctrlpipe(serial->dev, 0), 513 usb_sndctrlpipe(serial->dev, 0),
508 VENDOR_WRITE_REQUEST, 514 VENDOR_WRITE_REQUEST,
509 VENDOR_WRITE_REQUEST_TYPE, 515 VENDOR_WRITE_REQUEST_TYPE,
510 0x0, index, NULL, 0, 100); 516 0x0, index, NULL, 0, 100);
511 dbg ("0x40:0x1:0x0:0x%x %d", index, i); 517 dbg("0x40:0x1:0x0:0x%x %d", index, i);
512 } 518 }
513 519
514 kfree (buf); 520 kfree(buf);
515} 521}
516 522
517static int pl2303_open (struct usb_serial_port *port, struct file *filp) 523static int pl2303_open(struct usb_serial_port *port, struct file *filp)
518{ 524{
519 struct termios tmp_termios; 525 struct termios tmp_termios;
520 struct usb_serial *serial = port->serial; 526 struct usb_serial *serial = port->serial;
@@ -568,33 +574,34 @@ static int pl2303_open (struct usb_serial_port *port, struct file *filp)
568 574
569 /* Setup termios */ 575 /* Setup termios */
570 if (port->tty) { 576 if (port->tty) {
571 pl2303_set_termios (port, &tmp_termios); 577 pl2303_set_termios(port, &tmp_termios);
572 } 578 }
573 579
574 //FIXME: need to assert RTS and DTR if CRTSCTS off 580 //FIXME: need to assert RTS and DTR if CRTSCTS off
575 581
576 dbg("%s - submitting read urb", __FUNCTION__); 582 dbg("%s - submitting read urb", __FUNCTION__);
577 port->read_urb->dev = serial->dev; 583 port->read_urb->dev = serial->dev;
578 result = usb_submit_urb (port->read_urb, GFP_KERNEL); 584 result = usb_submit_urb(port->read_urb, GFP_KERNEL);
579 if (result) { 585 if (result) {
580 dev_err(&port->dev, "%s - failed submitting read urb, error %d\n", __FUNCTION__, result); 586 dev_err(&port->dev, "%s - failed submitting read urb,"
581 pl2303_close (port, NULL); 587 " error %d\n", __FUNCTION__, result);
588 pl2303_close(port, NULL);
582 return -EPROTO; 589 return -EPROTO;
583 } 590 }
584 591
585 dbg("%s - submitting interrupt urb", __FUNCTION__); 592 dbg("%s - submitting interrupt urb", __FUNCTION__);
586 port->interrupt_in_urb->dev = serial->dev; 593 port->interrupt_in_urb->dev = serial->dev;
587 result = usb_submit_urb (port->interrupt_in_urb, GFP_KERNEL); 594 result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
588 if (result) { 595 if (result) {
589 dev_err(&port->dev, "%s - failed submitting interrupt urb, error %d\n", __FUNCTION__, result); 596 dev_err(&port->dev, "%s - failed submitting interrupt urb,"
590 pl2303_close (port, NULL); 597 " error %d\n", __FUNCTION__, result);
598 pl2303_close(port, NULL);
591 return -EPROTO; 599 return -EPROTO;
592 } 600 }
593 return 0; 601 return 0;
594} 602}
595 603
596 604static void pl2303_close(struct usb_serial_port *port, struct file *filp)
597static void pl2303_close (struct usb_serial_port *port, struct file *filp)
598{ 605{
599 struct pl2303_private *priv = usb_get_serial_port_data(port); 606 struct pl2303_private *priv = usb_get_serial_port_data(port);
600 unsigned long flags; 607 unsigned long flags;
@@ -612,9 +619,9 @@ static void pl2303_close (struct usb_serial_port *port, struct file *filp)
612 add_wait_queue(&port->tty->write_wait, &wait); 619 add_wait_queue(&port->tty->write_wait, &wait);
613 for (;;) { 620 for (;;) {
614 set_current_state(TASK_INTERRUPTIBLE); 621 set_current_state(TASK_INTERRUPTIBLE);
615 if (pl2303_buf_data_avail(priv->buf) == 0 622 if (pl2303_buf_data_avail(priv->buf) == 0 ||
616 || timeout == 0 || signal_pending(current) 623 timeout == 0 || signal_pending(current) ||
617 || !usb_get_intfdata(port->serial->interface)) /* disconnect */ 624 !usb_get_intfdata(port->serial->interface)) /* disconnect */
618 break; 625 break;
619 spin_unlock_irqrestore(&priv->lock, flags); 626 spin_unlock_irqrestore(&priv->lock, flags);
620 timeout = schedule_timeout(timeout); 627 timeout = schedule_timeout(timeout);
@@ -652,14 +659,14 @@ static void pl2303_close (struct usb_serial_port *port, struct file *filp)
652 /* drop DTR and RTS */ 659 /* drop DTR and RTS */
653 spin_lock_irqsave(&priv->lock, flags); 660 spin_lock_irqsave(&priv->lock, flags);
654 priv->line_control = 0; 661 priv->line_control = 0;
655 spin_unlock_irqrestore (&priv->lock, flags); 662 spin_unlock_irqrestore(&priv->lock, flags);
656 set_control_lines (port->serial->dev, 0); 663 set_control_lines(port->serial->dev, 0);
657 } 664 }
658 } 665 }
659} 666}
660 667
661static int pl2303_tiocmset (struct usb_serial_port *port, struct file *file, 668static int pl2303_tiocmset(struct usb_serial_port *port, struct file *file,
662 unsigned int set, unsigned int clear) 669 unsigned int set, unsigned int clear)
663{ 670{
664 struct pl2303_private *priv = usb_get_serial_port_data(port); 671 struct pl2303_private *priv = usb_get_serial_port_data(port);
665 unsigned long flags; 672 unsigned long flags;
@@ -668,7 +675,7 @@ static int pl2303_tiocmset (struct usb_serial_port *port, struct file *file,
668 if (!usb_get_intfdata(port->serial->interface)) 675 if (!usb_get_intfdata(port->serial->interface))
669 return -ENODEV; 676 return -ENODEV;
670 677
671 spin_lock_irqsave (&priv->lock, flags); 678 spin_lock_irqsave(&priv->lock, flags);
672 if (set & TIOCM_RTS) 679 if (set & TIOCM_RTS)
673 priv->line_control |= CONTROL_RTS; 680 priv->line_control |= CONTROL_RTS;
674 if (set & TIOCM_DTR) 681 if (set & TIOCM_DTR)
@@ -678,12 +685,12 @@ static int pl2303_tiocmset (struct usb_serial_port *port, struct file *file,
678 if (clear & TIOCM_DTR) 685 if (clear & TIOCM_DTR)
679 priv->line_control &= ~CONTROL_DTR; 686 priv->line_control &= ~CONTROL_DTR;
680 control = priv->line_control; 687 control = priv->line_control;
681 spin_unlock_irqrestore (&priv->lock, flags); 688 spin_unlock_irqrestore(&priv->lock, flags);
682 689
683 return set_control_lines (port->serial->dev, control); 690 return set_control_lines(port->serial->dev, control);
684} 691}
685 692
686static int pl2303_tiocmget (struct usb_serial_port *port, struct file *file) 693static int pl2303_tiocmget(struct usb_serial_port *port, struct file *file)
687{ 694{
688 struct pl2303_private *priv = usb_get_serial_port_data(port); 695 struct pl2303_private *priv = usb_get_serial_port_data(port);
689 unsigned long flags; 696 unsigned long flags;
@@ -696,10 +703,10 @@ static int pl2303_tiocmget (struct usb_serial_port *port, struct file *file)
696 if (!usb_get_intfdata(port->serial->interface)) 703 if (!usb_get_intfdata(port->serial->interface))
697 return -ENODEV; 704 return -ENODEV;
698 705
699 spin_lock_irqsave (&priv->lock, flags); 706 spin_lock_irqsave(&priv->lock, flags);
700 mcr = priv->line_control; 707 mcr = priv->line_control;
701 status = priv->line_status; 708 status = priv->line_status;
702 spin_unlock_irqrestore (&priv->lock, flags); 709 spin_unlock_irqrestore(&priv->lock, flags);
703 710
704 result = ((mcr & CONTROL_DTR) ? TIOCM_DTR : 0) 711 result = ((mcr & CONTROL_DTR) ? TIOCM_DTR : 0)
705 | ((mcr & CONTROL_RTS) ? TIOCM_RTS : 0) 712 | ((mcr & CONTROL_RTS) ? TIOCM_RTS : 0)
@@ -721,22 +728,22 @@ static int wait_modem_info(struct usb_serial_port *port, unsigned int arg)
721 unsigned int status; 728 unsigned int status;
722 unsigned int changed; 729 unsigned int changed;
723 730
724 spin_lock_irqsave (&priv->lock, flags); 731 spin_lock_irqsave(&priv->lock, flags);
725 prevstatus = priv->line_status; 732 prevstatus = priv->line_status;
726 spin_unlock_irqrestore (&priv->lock, flags); 733 spin_unlock_irqrestore(&priv->lock, flags);
727 734
728 while (1) { 735 while (1) {
729 interruptible_sleep_on(&priv->delta_msr_wait); 736 interruptible_sleep_on(&priv->delta_msr_wait);
730 /* see if a signal did it */ 737 /* see if a signal did it */
731 if (signal_pending(current)) 738 if (signal_pending(current))
732 return -ERESTARTSYS; 739 return -ERESTARTSYS;
733 740
734 spin_lock_irqsave (&priv->lock, flags); 741 spin_lock_irqsave(&priv->lock, flags);
735 status = priv->line_status; 742 status = priv->line_status;
736 spin_unlock_irqrestore (&priv->lock, flags); 743 spin_unlock_irqrestore(&priv->lock, flags);
737 744
738 changed=prevstatus^status; 745 changed=prevstatus^status;
739 746
740 if (((arg & TIOCM_RNG) && (changed & UART_RING)) || 747 if (((arg & TIOCM_RNG) && (changed & UART_RING)) ||
741 ((arg & TIOCM_DSR) && (changed & UART_DSR)) || 748 ((arg & TIOCM_DSR) && (changed & UART_DSR)) ||
742 ((arg & TIOCM_CD) && (changed & UART_DCD)) || 749 ((arg & TIOCM_CD) && (changed & UART_DCD)) ||
@@ -749,7 +756,8 @@ static int wait_modem_info(struct usb_serial_port *port, unsigned int arg)
749 return 0; 756 return 0;
750} 757}
751 758
752static int pl2303_ioctl (struct usb_serial_port *port, struct file *file, unsigned int cmd, unsigned long arg) 759static int pl2303_ioctl(struct usb_serial_port *port, struct file *file,
760 unsigned int cmd, unsigned long arg)
753{ 761{
754 dbg("%s (%d) cmd = 0x%04x", __FUNCTION__, port->number, cmd); 762 dbg("%s (%d) cmd = 0x%04x", __FUNCTION__, port->number, cmd);
755 763
@@ -766,7 +774,7 @@ static int pl2303_ioctl (struct usb_serial_port *port, struct file *file, unsign
766 return -ENOIOCTLCMD; 774 return -ENOIOCTLCMD;
767} 775}
768 776
769static void pl2303_break_ctl (struct usb_serial_port *port, int break_state) 777static void pl2303_break_ctl(struct usb_serial_port *port, int break_state)
770{ 778{
771 struct usb_serial *serial = port->serial; 779 struct usb_serial *serial = port->serial;
772 u16 state; 780 u16 state;
@@ -780,15 +788,14 @@ static void pl2303_break_ctl (struct usb_serial_port *port, int break_state)
780 state = BREAK_ON; 788 state = BREAK_ON;
781 dbg("%s - turning break %s", __FUNCTION__, state==BREAK_OFF ? "off" : "on"); 789 dbg("%s - turning break %s", __FUNCTION__, state==BREAK_OFF ? "off" : "on");
782 790
783 result = usb_control_msg (serial->dev, usb_sndctrlpipe (serial->dev, 0), 791 result = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
784 BREAK_REQUEST, BREAK_REQUEST_TYPE, state, 792 BREAK_REQUEST, BREAK_REQUEST_TYPE, state,
785 0, NULL, 0, 100); 793 0, NULL, 0, 100);
786 if (result) 794 if (result)
787 dbg("%s - error sending break = %d", __FUNCTION__, result); 795 dbg("%s - error sending break = %d", __FUNCTION__, result);
788} 796}
789 797
790 798static void pl2303_shutdown(struct usb_serial *serial)
791static void pl2303_shutdown (struct usb_serial *serial)
792{ 799{
793 int i; 800 int i;
794 struct pl2303_private *priv; 801 struct pl2303_private *priv;
@@ -802,7 +809,7 @@ static void pl2303_shutdown (struct usb_serial *serial)
802 kfree(priv); 809 kfree(priv);
803 usb_set_serial_port_data(serial->port[i], NULL); 810 usb_set_serial_port_data(serial->port[i], NULL);
804 } 811 }
805 } 812 }
806} 813}
807 814
808static void pl2303_update_line_status(struct usb_serial_port *port, 815static void pl2303_update_line_status(struct usb_serial_port *port,
@@ -830,10 +837,10 @@ static void pl2303_update_line_status(struct usb_serial_port *port,
830 spin_lock_irqsave(&priv->lock, flags); 837 spin_lock_irqsave(&priv->lock, flags);
831 priv->line_status = data[status_idx]; 838 priv->line_status = data[status_idx];
832 spin_unlock_irqrestore(&priv->lock, flags); 839 spin_unlock_irqrestore(&priv->lock, flags);
833 wake_up_interruptible (&priv->delta_msr_wait); 840 wake_up_interruptible(&priv->delta_msr_wait);
834} 841}
835 842
836static void pl2303_read_int_callback (struct urb *urb, struct pt_regs *regs) 843static void pl2303_read_int_callback(struct urb *urb, struct pt_regs *regs)
837{ 844{
838 struct usb_serial_port *port = (struct usb_serial_port *) urb->context; 845 struct usb_serial_port *port = (struct usb_serial_port *) urb->context;
839 unsigned char *data = urb->transfer_buffer; 846 unsigned char *data = urb->transfer_buffer;
@@ -850,25 +857,29 @@ static void pl2303_read_int_callback (struct urb *urb, struct pt_regs *regs)
850 case -ENOENT: 857 case -ENOENT:
851 case -ESHUTDOWN: 858 case -ESHUTDOWN:
852 /* this urb is terminated, clean up */ 859 /* this urb is terminated, clean up */
853 dbg("%s - urb shutting down with status: %d", __FUNCTION__, urb->status); 860 dbg("%s - urb shutting down with status: %d", __FUNCTION__,
861 urb->status);
854 return; 862 return;
855 default: 863 default:
856 dbg("%s - nonzero urb status received: %d", __FUNCTION__, urb->status); 864 dbg("%s - nonzero urb status received: %d", __FUNCTION__,
865 urb->status);
857 goto exit; 866 goto exit;
858 } 867 }
859 868
860 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, urb->actual_length, urb->transfer_buffer); 869 usb_serial_debug_data(debug, &port->dev, __FUNCTION__,
870 urb->actual_length, urb->transfer_buffer);
871
861 pl2303_update_line_status(port, data, actual_length); 872 pl2303_update_line_status(port, data, actual_length);
862 873
863exit: 874exit:
864 status = usb_submit_urb (urb, GFP_ATOMIC); 875 status = usb_submit_urb(urb, GFP_ATOMIC);
865 if (status) 876 if (status)
866 dev_err(&urb->dev->dev, "%s - usb_submit_urb failed with result %d\n", 877 dev_err(&urb->dev->dev,
878 "%s - usb_submit_urb failed with result %d\n",
867 __FUNCTION__, status); 879 __FUNCTION__, status);
868} 880}
869 881
870 882static void pl2303_read_bulk_callback(struct urb *urb, struct pt_regs *regs)
871static void pl2303_read_bulk_callback (struct urb *urb, struct pt_regs *regs)
872{ 883{
873 struct usb_serial_port *port = (struct usb_serial_port *) urb->context; 884 struct usb_serial_port *port = (struct usb_serial_port *) urb->context;
874 struct pl2303_private *priv = usb_get_serial_port_data(port); 885 struct pl2303_private *priv = usb_get_serial_port_data(port);
@@ -889,20 +900,25 @@ static void pl2303_read_bulk_callback (struct urb *urb, struct pt_regs *regs)
889 return; 900 return;
890 } 901 }
891 if (urb->status == -EPROTO) { 902 if (urb->status == -EPROTO) {
892 /* PL2303 mysteriously fails with -EPROTO reschedule the read */ 903 /* PL2303 mysteriously fails with -EPROTO reschedule
893 dbg("%s - caught -EPROTO, resubmitting the urb", __FUNCTION__); 904 * the read */
905 dbg("%s - caught -EPROTO, resubmitting the urb",
906 __FUNCTION__);
894 urb->status = 0; 907 urb->status = 0;
895 urb->dev = port->serial->dev; 908 urb->dev = port->serial->dev;
896 result = usb_submit_urb(urb, GFP_ATOMIC); 909 result = usb_submit_urb(urb, GFP_ATOMIC);
897 if (result) 910 if (result)
898 dev_err(&urb->dev->dev, "%s - failed resubmitting read urb, error %d\n", __FUNCTION__, result); 911 dev_err(&urb->dev->dev, "%s - failed"
912 " resubmitting read urb, error %d\n",
913 __FUNCTION__, result);
899 return; 914 return;
900 } 915 }
901 dbg("%s - unable to handle the error, exiting.", __FUNCTION__); 916 dbg("%s - unable to handle the error, exiting.", __FUNCTION__);
902 return; 917 return;
903 } 918 }
904 919
905 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, urb->actual_length, data); 920 usb_serial_debug_data(debug, &port->dev, __FUNCTION__,
921 urb->actual_length, data);
906 922
907 /* get tty_flag from status */ 923 /* get tty_flag from status */
908 tty_flag = TTY_NORMAL; 924 tty_flag = TTY_NORMAL;
@@ -911,7 +927,7 @@ static void pl2303_read_bulk_callback (struct urb *urb, struct pt_regs *regs)
911 status = priv->line_status; 927 status = priv->line_status;
912 priv->line_status &= ~UART_STATE_TRANSIENT_MASK; 928 priv->line_status &= ~UART_STATE_TRANSIENT_MASK;
913 spin_unlock_irqrestore(&priv->lock, flags); 929 spin_unlock_irqrestore(&priv->lock, flags);
914 wake_up_interruptible (&priv->delta_msr_wait); 930 wake_up_interruptible(&priv->delta_msr_wait);
915 931
916 /* break takes precedence over parity, */ 932 /* break takes precedence over parity, */
917 /* which takes precedence over framing errors */ 933 /* which takes precedence over framing errors */
@@ -930,8 +946,8 @@ static void pl2303_read_bulk_callback (struct urb *urb, struct pt_regs *regs)
930 if (status & UART_OVERRUN_ERROR) 946 if (status & UART_OVERRUN_ERROR)
931 tty_insert_flip_char(tty, 0, TTY_OVERRUN); 947 tty_insert_flip_char(tty, 0, TTY_OVERRUN);
932 for (i = 0; i < urb->actual_length; ++i) 948 for (i = 0; i < urb->actual_length; ++i)
933 tty_insert_flip_char (tty, data[i], tty_flag); 949 tty_insert_flip_char(tty, data[i], tty_flag);
934 tty_flip_buffer_push (tty); 950 tty_flip_buffer_push(tty);
935 } 951 }
936 952
937 /* Schedule the next read _if_ we are still open */ 953 /* Schedule the next read _if_ we are still open */
@@ -939,15 +955,14 @@ static void pl2303_read_bulk_callback (struct urb *urb, struct pt_regs *regs)
939 urb->dev = port->serial->dev; 955 urb->dev = port->serial->dev;
940 result = usb_submit_urb(urb, GFP_ATOMIC); 956 result = usb_submit_urb(urb, GFP_ATOMIC);
941 if (result) 957 if (result)
942 dev_err(&urb->dev->dev, "%s - failed resubmitting read urb, error %d\n", __FUNCTION__, result); 958 dev_err(&urb->dev->dev, "%s - failed resubmitting"
959 " read urb, error %d\n", __FUNCTION__, result);
943 } 960 }
944 961
945 return; 962 return;
946} 963}
947 964
948 965static void pl2303_write_bulk_callback(struct urb *urb, struct pt_regs *regs)
949
950static void pl2303_write_bulk_callback (struct urb *urb, struct pt_regs *regs)
951{ 966{
952 struct usb_serial_port *port = (struct usb_serial_port *) urb->context; 967 struct usb_serial_port *port = (struct usb_serial_port *) urb->context;
953 struct pl2303_private *priv = usb_get_serial_port_data(port); 968 struct pl2303_private *priv = usb_get_serial_port_data(port);
@@ -963,18 +978,21 @@ static void pl2303_write_bulk_callback (struct urb *urb, struct pt_regs *regs)
963 case -ENOENT: 978 case -ENOENT:
964 case -ESHUTDOWN: 979 case -ESHUTDOWN:
965 /* this urb is terminated, clean up */ 980 /* this urb is terminated, clean up */
966 dbg("%s - urb shutting down with status: %d", __FUNCTION__, urb->status); 981 dbg("%s - urb shutting down with status: %d", __FUNCTION__,
982 urb->status);
967 priv->write_urb_in_use = 0; 983 priv->write_urb_in_use = 0;
968 return; 984 return;
969 default: 985 default:
970 /* error in the urb, so we have to resubmit it */ 986 /* error in the urb, so we have to resubmit it */
971 dbg("%s - Overflow in write", __FUNCTION__); 987 dbg("%s - Overflow in write", __FUNCTION__);
972 dbg("%s - nonzero write bulk status received: %d", __FUNCTION__, urb->status); 988 dbg("%s - nonzero write bulk status received: %d", __FUNCTION__,
989 urb->status);
973 port->write_urb->transfer_buffer_length = 1; 990 port->write_urb->transfer_buffer_length = 1;
974 port->write_urb->dev = port->serial->dev; 991 port->write_urb->dev = port->serial->dev;
975 result = usb_submit_urb (port->write_urb, GFP_ATOMIC); 992 result = usb_submit_urb(port->write_urb, GFP_ATOMIC);
976 if (result) 993 if (result)
977 dev_err(&urb->dev->dev, "%s - failed resubmitting write urb, error %d\n", __FUNCTION__, result); 994 dev_err(&urb->dev->dev, "%s - failed resubmitting write"
995 " urb, error %d\n", __FUNCTION__, result);
978 else 996 else
979 return; 997 return;
980 } 998 }
@@ -985,19 +1003,15 @@ static void pl2303_write_bulk_callback (struct urb *urb, struct pt_regs *regs)
985 pl2303_send(port); 1003 pl2303_send(port);
986} 1004}
987 1005
988
989/* 1006/*
990 * pl2303_buf_alloc 1007 * pl2303_buf_alloc
991 * 1008 *
992 * Allocate a circular buffer and all associated memory. 1009 * Allocate a circular buffer and all associated memory.
993 */ 1010 */
994
995static struct pl2303_buf *pl2303_buf_alloc(unsigned int size) 1011static struct pl2303_buf *pl2303_buf_alloc(unsigned int size)
996{ 1012{
997
998 struct pl2303_buf *pb; 1013 struct pl2303_buf *pb;
999 1014
1000
1001 if (size == 0) 1015 if (size == 0)
1002 return NULL; 1016 return NULL;
1003 1017
@@ -1015,16 +1029,13 @@ static struct pl2303_buf *pl2303_buf_alloc(unsigned int size)
1015 pb->buf_get = pb->buf_put = pb->buf_buf; 1029 pb->buf_get = pb->buf_put = pb->buf_buf;
1016 1030
1017 return pb; 1031 return pb;
1018
1019} 1032}
1020 1033
1021
1022/* 1034/*
1023 * pl2303_buf_free 1035 * pl2303_buf_free
1024 * 1036 *
1025 * Free the buffer and all associated memory. 1037 * Free the buffer and all associated memory.
1026 */ 1038 */
1027
1028static void pl2303_buf_free(struct pl2303_buf *pb) 1039static void pl2303_buf_free(struct pl2303_buf *pb)
1029{ 1040{
1030 if (pb) { 1041 if (pb) {
@@ -1033,13 +1044,11 @@ static void pl2303_buf_free(struct pl2303_buf *pb)
1033 } 1044 }
1034} 1045}
1035 1046
1036
1037/* 1047/*
1038 * pl2303_buf_clear 1048 * pl2303_buf_clear
1039 * 1049 *
1040 * Clear out all data in the circular buffer. 1050 * Clear out all data in the circular buffer.
1041 */ 1051 */
1042
1043static void pl2303_buf_clear(struct pl2303_buf *pb) 1052static void pl2303_buf_clear(struct pl2303_buf *pb)
1044{ 1053{
1045 if (pb != NULL) 1054 if (pb != NULL)
@@ -1047,14 +1056,12 @@ static void pl2303_buf_clear(struct pl2303_buf *pb)
1047 /* equivalent to a get of all data available */ 1056 /* equivalent to a get of all data available */
1048} 1057}
1049 1058
1050
1051/* 1059/*
1052 * pl2303_buf_data_avail 1060 * pl2303_buf_data_avail
1053 * 1061 *
1054 * Return the number of bytes of data available in the circular 1062 * Return the number of bytes of data available in the circular
1055 * buffer. 1063 * buffer.
1056 */ 1064 */
1057
1058static unsigned int pl2303_buf_data_avail(struct pl2303_buf *pb) 1065static unsigned int pl2303_buf_data_avail(struct pl2303_buf *pb)
1059{ 1066{
1060 if (pb != NULL) 1067 if (pb != NULL)
@@ -1063,14 +1070,12 @@ static unsigned int pl2303_buf_data_avail(struct pl2303_buf *pb)
1063 return 0; 1070 return 0;
1064} 1071}
1065 1072
1066
1067/* 1073/*
1068 * pl2303_buf_space_avail 1074 * pl2303_buf_space_avail
1069 * 1075 *
1070 * Return the number of bytes of space available in the circular 1076 * Return the number of bytes of space available in the circular
1071 * buffer. 1077 * buffer.
1072 */ 1078 */
1073
1074static unsigned int pl2303_buf_space_avail(struct pl2303_buf *pb) 1079static unsigned int pl2303_buf_space_avail(struct pl2303_buf *pb)
1075{ 1080{
1076 if (pb != NULL) 1081 if (pb != NULL)
@@ -1079,7 +1084,6 @@ static unsigned int pl2303_buf_space_avail(struct pl2303_buf *pb)
1079 return 0; 1084 return 0;
1080} 1085}
1081 1086
1082
1083/* 1087/*
1084 * pl2303_buf_put 1088 * pl2303_buf_put
1085 * 1089 *
@@ -1088,14 +1092,11 @@ static unsigned int pl2303_buf_space_avail(struct pl2303_buf *pb)
1088 * 1092 *
1089 * Return the number of bytes copied. 1093 * Return the number of bytes copied.
1090 */ 1094 */
1091
1092static unsigned int pl2303_buf_put(struct pl2303_buf *pb, const char *buf, 1095static unsigned int pl2303_buf_put(struct pl2303_buf *pb, const char *buf,
1093 unsigned int count) 1096 unsigned int count)
1094{ 1097{
1095
1096 unsigned int len; 1098 unsigned int len;
1097 1099
1098
1099 if (pb == NULL) 1100 if (pb == NULL)
1100 return 0; 1101 return 0;
1101 1102
@@ -1120,10 +1121,8 @@ static unsigned int pl2303_buf_put(struct pl2303_buf *pb, const char *buf,
1120 } 1121 }
1121 1122
1122 return count; 1123 return count;
1123
1124} 1124}
1125 1125
1126
1127/* 1126/*
1128 * pl2303_buf_get 1127 * pl2303_buf_get
1129 * 1128 *
@@ -1132,14 +1131,11 @@ static unsigned int pl2303_buf_put(struct pl2303_buf *pb, const char *buf,
1132 * 1131 *
1133 * Return the number of bytes copied. 1132 * Return the number of bytes copied.
1134 */ 1133 */
1135
1136static unsigned int pl2303_buf_get(struct pl2303_buf *pb, char *buf, 1134static unsigned int pl2303_buf_get(struct pl2303_buf *pb, char *buf,
1137 unsigned int count) 1135 unsigned int count)
1138{ 1136{
1139
1140 unsigned int len; 1137 unsigned int len;
1141 1138
1142
1143 if (pb == NULL) 1139 if (pb == NULL)
1144 return 0; 1140 return 0;
1145 1141
@@ -1164,12 +1160,12 @@ static unsigned int pl2303_buf_get(struct pl2303_buf *pb, char *buf,
1164 } 1160 }
1165 1161
1166 return count; 1162 return count;
1167
1168} 1163}
1169 1164
1170static int __init pl2303_init (void) 1165static int __init pl2303_init(void)
1171{ 1166{
1172 int retval; 1167 int retval;
1168
1173 retval = usb_serial_register(&pl2303_device); 1169 retval = usb_serial_register(&pl2303_device);
1174 if (retval) 1170 if (retval)
1175 goto failed_usb_serial_register; 1171 goto failed_usb_serial_register;
@@ -1184,14 +1180,12 @@ failed_usb_serial_register:
1184 return retval; 1180 return retval;
1185} 1181}
1186 1182
1187 1183static void __exit pl2303_exit(void)
1188static void __exit pl2303_exit (void)
1189{ 1184{
1190 usb_deregister (&pl2303_driver); 1185 usb_deregister(&pl2303_driver);
1191 usb_serial_deregister (&pl2303_device); 1186 usb_serial_deregister(&pl2303_device);
1192} 1187}
1193 1188
1194
1195module_init(pl2303_init); 1189module_init(pl2303_init);
1196module_exit(pl2303_exit); 1190module_exit(pl2303_exit);
1197 1191