aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial
diff options
context:
space:
mode:
authorJohan Hovold <jhovold@gmail.com>2013-12-29 13:23:00 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-01-03 15:31:47 -0500
commitccfe8188a321f4039a7e52c8336bb4ff3ca35139 (patch)
tree07957fea4fa7be2a9b633ea3d1b818d22e166231 /drivers/usb/serial
parent71c671bf4cead0e801eccbed3fe790e817f6b6d4 (diff)
USB: pl2303: clean up driver somewhat
Use u16 rather than __u16. Fix multi-line comment style. Remove some comments. Remove unnecessary whitespace and add some where appropriate. Drop DRIVER_DESC define. Merge and simplify multi-line error message. Signed-off-by: Johan Hovold <jhovold@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/serial')
-rw-r--r--drivers/usb/serial/pl2303.c61
1 files changed, 34 insertions, 27 deletions
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index 6234d55372cb..a44154ac335c 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -12,7 +12,6 @@
12 * 12 *
13 * See Documentation/usb/usb-serial.txt for more information on using this 13 * See Documentation/usb/usb-serial.txt for more information on using this
14 * driver 14 * driver
15 *
16 */ 15 */
17 16
18#include <linux/kernel.h> 17#include <linux/kernel.h>
@@ -32,11 +31,6 @@
32#include <asm/unaligned.h> 31#include <asm/unaligned.h>
33#include "pl2303.h" 32#include "pl2303.h"
34 33
35/*
36 * Version Information
37 */
38#define DRIVER_DESC "Prolific PL2303 USB to serial adaptor driver"
39
40static const struct usb_device_id id_table[] = { 34static const struct usb_device_id id_table[] = {
41 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID) }, 35 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID) },
42 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_RSAQ2) }, 36 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_RSAQ2) },
@@ -146,27 +140,34 @@ struct pl2303_private {
146 u8 line_settings[7]; 140 u8 line_settings[7];
147}; 141};
148 142
149static int pl2303_vendor_read(__u16 value, __u16 index, 143static int pl2303_vendor_read(u16 value, u16 index,
150 struct usb_serial *serial, unsigned char *buf) 144 struct usb_serial *serial, unsigned char *buf)
151{ 145{
152 int res = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), 146 int res;
147
148 res = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0),
153 VENDOR_READ_REQUEST, VENDOR_READ_REQUEST_TYPE, 149 VENDOR_READ_REQUEST, VENDOR_READ_REQUEST_TYPE,
154 value, index, buf, 1, 100); 150 value, index, buf, 1, 100);
151
155 dev_dbg(&serial->interface->dev, "0x%x:0x%x:0x%x:0x%x %d - %x\n", 152 dev_dbg(&serial->interface->dev, "0x%x:0x%x:0x%x:0x%x %d - %x\n",
156 VENDOR_READ_REQUEST_TYPE, VENDOR_READ_REQUEST, value, index, 153 VENDOR_READ_REQUEST_TYPE, VENDOR_READ_REQUEST, value, index,
157 res, buf[0]); 154 res, buf[0]);
155
158 return res; 156 return res;
159} 157}
160 158
161static int pl2303_vendor_write(__u16 value, __u16 index, 159static int pl2303_vendor_write(u16 value, u16 index, struct usb_serial *serial)
162 struct usb_serial *serial)
163{ 160{
164 int res = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), 161 int res;
162
163 res = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
165 VENDOR_WRITE_REQUEST, VENDOR_WRITE_REQUEST_TYPE, 164 VENDOR_WRITE_REQUEST, VENDOR_WRITE_REQUEST_TYPE,
166 value, index, NULL, 0, 100); 165 value, index, NULL, 0, 100);
166
167 dev_dbg(&serial->interface->dev, "0x%x:0x%x:0x%x:0x%x %d\n", 167 dev_dbg(&serial->interface->dev, "0x%x:0x%x:0x%x:0x%x %d\n",
168 VENDOR_WRITE_REQUEST_TYPE, VENDOR_WRITE_REQUEST, value, index, 168 VENDOR_WRITE_REQUEST_TYPE, VENDOR_WRITE_REQUEST, value, index,
169 res); 169 res);
170
170 return res; 171 return res;
171} 172}
172 173
@@ -215,14 +216,14 @@ static int pl2303_startup(struct usb_serial *serial)
215 pl2303_vendor_write(2, 0x24, serial); 216 pl2303_vendor_write(2, 0x24, serial);
216 217
217 kfree(buf); 218 kfree(buf);
219
218 return 0; 220 return 0;
219} 221}
220 222
221static void pl2303_release(struct usb_serial *serial) 223static void pl2303_release(struct usb_serial *serial)
222{ 224{
223 struct pl2303_serial_private *spriv; 225 struct pl2303_serial_private *spriv = usb_get_serial_data(serial);
224 226
225 spriv = usb_get_serial_data(serial);
226 kfree(spriv); 227 kfree(spriv);
227} 228}
228 229
@@ -245,9 +246,8 @@ static int pl2303_port_probe(struct usb_serial_port *port)
245 246
246static int pl2303_port_remove(struct usb_serial_port *port) 247static int pl2303_port_remove(struct usb_serial_port *port)
247{ 248{
248 struct pl2303_private *priv; 249 struct pl2303_private *priv = usb_get_serial_port_data(port);
249 250
250 priv = usb_get_serial_port_data(port);
251 kfree(priv); 251 kfree(priv);
252 252
253 return 0; 253 return 0;
@@ -261,8 +261,10 @@ static int pl2303_set_control_lines(struct usb_serial_port *port, u8 value)
261 retval = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 261 retval = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
262 SET_CONTROL_REQUEST, SET_CONTROL_REQUEST_TYPE, 262 SET_CONTROL_REQUEST, SET_CONTROL_REQUEST_TYPE,
263 value, 0, NULL, 0, 100); 263 value, 0, NULL, 0, 100);
264
264 dev_dbg(&port->dev, "%s - value = %d, retval = %d\n", __func__, 265 dev_dbg(&port->dev, "%s - value = %d, retval = %d\n", __func__,
265 value, retval); 266 value, retval);
267
266 return retval; 268 return retval;
267} 269}
268 270
@@ -488,13 +490,13 @@ static void pl2303_dtr_rts(struct usb_serial_port *port, int on)
488 u8 control; 490 u8 control;
489 491
490 spin_lock_irqsave(&priv->lock, flags); 492 spin_lock_irqsave(&priv->lock, flags);
491 /* Change DTR and RTS */
492 if (on) 493 if (on)
493 priv->line_control |= (CONTROL_DTR | CONTROL_RTS); 494 priv->line_control |= (CONTROL_DTR | CONTROL_RTS);
494 else 495 else
495 priv->line_control &= ~(CONTROL_DTR | CONTROL_RTS); 496 priv->line_control &= ~(CONTROL_DTR | CONTROL_RTS);
496 control = priv->line_control; 497 control = priv->line_control;
497 spin_unlock_irqrestore(&priv->lock, flags); 498 spin_unlock_irqrestore(&priv->lock, flags);
499
498 pl2303_set_control_lines(port, control); 500 pl2303_set_control_lines(port, control);
499} 501}
500 502
@@ -525,8 +527,8 @@ static int pl2303_open(struct tty_struct *tty, struct usb_serial_port *port)
525 527
526 result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); 528 result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
527 if (result) { 529 if (result) {
528 dev_err(&port->dev, "%s - failed submitting interrupt urb," 530 dev_err(&port->dev, "failed to submit interrupt urb: %d\n",
529 " error %d\n", __func__, result); 531 result);
530 return result; 532 return result;
531 } 533 }
532 534
@@ -596,8 +598,10 @@ static int pl2303_tiocmget(struct tty_struct *tty)
596static int pl2303_carrier_raised(struct usb_serial_port *port) 598static int pl2303_carrier_raised(struct usb_serial_port *port)
597{ 599{
598 struct pl2303_private *priv = usb_get_serial_port_data(port); 600 struct pl2303_private *priv = usb_get_serial_port_data(port);
601
599 if (priv->line_status & UART_DCD) 602 if (priv->line_status & UART_DCD)
600 return 1; 603 return 1;
604
601 return 0; 605 return 0;
602} 606}
603 607
@@ -662,6 +666,7 @@ static int pl2303_ioctl(struct tty_struct *tty,
662 default: 666 default:
663 break; 667 break;
664 } 668 }
669
665 return -ENOIOCTLCMD; 670 return -ENOIOCTLCMD;
666} 671}
667 672
@@ -676,6 +681,7 @@ static void pl2303_break_ctl(struct tty_struct *tty, int break_state)
676 state = BREAK_OFF; 681 state = BREAK_OFF;
677 else 682 else
678 state = BREAK_ON; 683 state = BREAK_ON;
684
679 dev_dbg(&port->dev, "%s - turning break %s\n", __func__, 685 dev_dbg(&port->dev, "%s - turning break %s\n", __func__,
680 state == BREAK_OFF ? "off" : "on"); 686 state == BREAK_OFF ? "off" : "on");
681 687
@@ -690,7 +696,6 @@ static void pl2303_update_line_status(struct usb_serial_port *port,
690 unsigned char *data, 696 unsigned char *data,
691 unsigned int actual_length) 697 unsigned int actual_length)
692{ 698{
693
694 struct pl2303_private *priv = usb_get_serial_port_data(port); 699 struct pl2303_private *priv = usb_get_serial_port_data(port);
695 struct tty_struct *tty; 700 struct tty_struct *tty;
696 unsigned long flags; 701 unsigned long flags;
@@ -702,12 +707,10 @@ static void pl2303_update_line_status(struct usb_serial_port *port,
702 idv = le16_to_cpu(port->serial->dev->descriptor.idVendor); 707 idv = le16_to_cpu(port->serial->dev->descriptor.idVendor);
703 idp = le16_to_cpu(port->serial->dev->descriptor.idProduct); 708 idp = le16_to_cpu(port->serial->dev->descriptor.idProduct);
704 709
705
706 if (idv == SIEMENS_VENDOR_ID) { 710 if (idv == SIEMENS_VENDOR_ID) {
707 if (idp == SIEMENS_PRODUCT_ID_X65 || 711 if (idp == SIEMENS_PRODUCT_ID_X65 ||
708 idp == SIEMENS_PRODUCT_ID_SX1 || 712 idp == SIEMENS_PRODUCT_ID_SX1 ||
709 idp == SIEMENS_PRODUCT_ID_X75) { 713 idp == SIEMENS_PRODUCT_ID_X75) {
710
711 length = 1; 714 length = 1;
712 status_idx = 0; 715 status_idx = 0;
713 } 716 }
@@ -721,8 +724,10 @@ static void pl2303_update_line_status(struct usb_serial_port *port,
721 prev_line_status = priv->line_status; 724 prev_line_status = priv->line_status;
722 priv->line_status = data[status_idx]; 725 priv->line_status = data[status_idx];
723 spin_unlock_irqrestore(&priv->lock, flags); 726 spin_unlock_irqrestore(&priv->lock, flags);
727
724 if (priv->line_status & UART_BREAK_ERROR) 728 if (priv->line_status & UART_BREAK_ERROR)
725 usb_serial_handle_break(port); 729 usb_serial_handle_break(port);
730
726 wake_up_interruptible(&port->port.delta_msr_wait); 731 wake_up_interruptible(&port->port.delta_msr_wait);
727 732
728 tty = tty_port_tty_get(&port->port); 733 tty = tty_port_tty_get(&port->port);
@@ -766,10 +771,11 @@ static void pl2303_read_int_callback(struct urb *urb)
766 771
767exit: 772exit:
768 retval = usb_submit_urb(urb, GFP_ATOMIC); 773 retval = usb_submit_urb(urb, GFP_ATOMIC);
769 if (retval) 774 if (retval) {
770 dev_err(&port->dev, 775 dev_err(&port->dev,
771 "%s - usb_submit_urb failed with result %d\n", 776 "%s - usb_submit_urb failed with result %d\n",
772 __func__, retval); 777 __func__, retval);
778 }
773} 779}
774 780
775static void pl2303_process_read_urb(struct urb *urb) 781static void pl2303_process_read_urb(struct urb *urb)
@@ -791,8 +797,10 @@ static void pl2303_process_read_urb(struct urb *urb)
791 if (!urb->actual_length) 797 if (!urb->actual_length)
792 return; 798 return;
793 799
794 /* break takes precedence over parity, */ 800 /*
795 /* which takes precedence over framing errors */ 801 * Break takes precedence over parity, which takes precedence over
802 * framing errors.
803 */
796 if (line_status & UART_BREAK_ERROR) 804 if (line_status & UART_BREAK_ERROR)
797 tty_flag = TTY_BREAK; 805 tty_flag = TTY_BREAK;
798 else if (line_status & UART_PARITY_ERROR) 806 else if (line_status & UART_PARITY_ERROR)
@@ -820,7 +828,6 @@ static void pl2303_process_read_urb(struct urb *urb)
820 tty_flip_buffer_push(&port->port); 828 tty_flip_buffer_push(&port->port);
821} 829}
822 830
823/* All of the device info needed for the PL2303 SIO serial converter */
824static struct usb_serial_driver pl2303_device = { 831static struct usb_serial_driver pl2303_device = {
825 .driver = { 832 .driver = {
826 .owner = THIS_MODULE, 833 .owner = THIS_MODULE,
@@ -832,7 +839,7 @@ static struct usb_serial_driver pl2303_device = {
832 .bulk_out_size = 256, 839 .bulk_out_size = 256,
833 .open = pl2303_open, 840 .open = pl2303_open,
834 .close = pl2303_close, 841 .close = pl2303_close,
835 .dtr_rts = pl2303_dtr_rts, 842 .dtr_rts = pl2303_dtr_rts,
836 .carrier_raised = pl2303_carrier_raised, 843 .carrier_raised = pl2303_carrier_raised,
837 .ioctl = pl2303_ioctl, 844 .ioctl = pl2303_ioctl,
838 .break_ctl = pl2303_break_ctl, 845 .break_ctl = pl2303_break_ctl,
@@ -854,5 +861,5 @@ static struct usb_serial_driver * const serial_drivers[] = {
854 861
855module_usb_serial_driver(serial_drivers, id_table); 862module_usb_serial_driver(serial_drivers, id_table);
856 863
857MODULE_DESCRIPTION(DRIVER_DESC); 864MODULE_DESCRIPTION("Prolific PL2303 USB to serial adaptor driver");
858MODULE_LICENSE("GPL"); 865MODULE_LICENSE("GPL");