aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/cp210x.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/serial/cp210x.c')
-rw-r--r--drivers/usb/serial/cp210x.c37
1 files changed, 15 insertions, 22 deletions
diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
index eb033fc92a15..f14736f647ff 100644
--- a/drivers/usb/serial/cp210x.c
+++ b/drivers/usb/serial/cp210x.c
@@ -24,10 +24,6 @@
24#include <linux/uaccess.h> 24#include <linux/uaccess.h>
25#include <linux/usb/serial.h> 25#include <linux/usb/serial.h>
26 26
27/*
28 * Version Information
29 */
30#define DRIVER_VERSION "v0.09"
31#define DRIVER_DESC "Silicon Labs CP210x RS232 serial adaptor driver" 27#define DRIVER_DESC "Silicon Labs CP210x RS232 serial adaptor driver"
32 28
33/* 29/*
@@ -35,8 +31,7 @@
35 */ 31 */
36static int cp210x_open(struct tty_struct *tty, struct usb_serial_port *); 32static int cp210x_open(struct tty_struct *tty, struct usb_serial_port *);
37static void cp210x_close(struct usb_serial_port *); 33static void cp210x_close(struct usb_serial_port *);
38static void cp210x_get_termios(struct tty_struct *, 34static void cp210x_get_termios(struct tty_struct *, struct usb_serial_port *);
39 struct usb_serial_port *port);
40static void cp210x_get_termios_port(struct usb_serial_port *port, 35static void cp210x_get_termios_port(struct usb_serial_port *port,
41 unsigned int *cflagp, unsigned int *baudp); 36 unsigned int *cflagp, unsigned int *baudp);
42static void cp210x_change_speed(struct tty_struct *, struct usb_serial_port *, 37static void cp210x_change_speed(struct tty_struct *, struct usb_serial_port *,
@@ -118,6 +113,7 @@ static const struct usb_device_id id_table[] = {
118 { USB_DEVICE(0x10C4, 0x8477) }, /* Balluff RFID */ 113 { USB_DEVICE(0x10C4, 0x8477) }, /* Balluff RFID */
119 { USB_DEVICE(0x10C4, 0x85EA) }, /* AC-Services IBUS-IF */ 114 { USB_DEVICE(0x10C4, 0x85EA) }, /* AC-Services IBUS-IF */
120 { USB_DEVICE(0x10C4, 0x85EB) }, /* AC-Services CIS-IBUS */ 115 { USB_DEVICE(0x10C4, 0x85EB) }, /* AC-Services CIS-IBUS */
116 { USB_DEVICE(0x10C4, 0x85F8) }, /* Virtenio Preon32 */
121 { USB_DEVICE(0x10C4, 0x8664) }, /* AC-Services CAN-IF */ 117 { USB_DEVICE(0x10C4, 0x8664) }, /* AC-Services CAN-IF */
122 { USB_DEVICE(0x10C4, 0x8665) }, /* AC-Services OBD-IF */ 118 { USB_DEVICE(0x10C4, 0x8665) }, /* AC-Services OBD-IF */
123 { USB_DEVICE(0x10C4, 0xEA60) }, /* Silicon Labs factory default */ 119 { USB_DEVICE(0x10C4, 0xEA60) }, /* Silicon Labs factory default */
@@ -169,7 +165,7 @@ struct cp210x_serial_private {
169static struct usb_serial_driver cp210x_device = { 165static struct usb_serial_driver cp210x_device = {
170 .driver = { 166 .driver = {
171 .owner = THIS_MODULE, 167 .owner = THIS_MODULE,
172 .name = "cp210x", 168 .name = "cp210x",
173 }, 169 },
174 .id_table = id_table, 170 .id_table = id_table,
175 .num_ports = 1, 171 .num_ports = 1,
@@ -179,7 +175,7 @@ static struct usb_serial_driver cp210x_device = {
179 .close = cp210x_close, 175 .close = cp210x_close,
180 .break_ctl = cp210x_break_ctl, 176 .break_ctl = cp210x_break_ctl,
181 .set_termios = cp210x_set_termios, 177 .set_termios = cp210x_set_termios,
182 .tiocmget = cp210x_tiocmget, 178 .tiocmget = cp210x_tiocmget,
183 .tiocmset = cp210x_tiocmset, 179 .tiocmset = cp210x_tiocmset,
184 .attach = cp210x_startup, 180 .attach = cp210x_startup,
185 .release = cp210x_release, 181 .release = cp210x_release,
@@ -281,7 +277,7 @@ static int cp210x_get_config(struct usb_serial_port *port, u8 request,
281 int result, i, length; 277 int result, i, length;
282 278
283 /* Number of integers required to contain the array */ 279 /* Number of integers required to contain the array */
284 length = (((size - 1) | 3) + 1)/4; 280 length = (((size - 1) | 3) + 1) / 4;
285 281
286 buf = kcalloc(length, sizeof(__le32), GFP_KERNEL); 282 buf = kcalloc(length, sizeof(__le32), GFP_KERNEL);
287 if (!buf) { 283 if (!buf) {
@@ -328,12 +324,11 @@ static int cp210x_set_config(struct usb_serial_port *port, u8 request,
328 int result, i, length; 324 int result, i, length;
329 325
330 /* Number of integers required to contain the array */ 326 /* Number of integers required to contain the array */
331 length = (((size - 1) | 3) + 1)/4; 327 length = (((size - 1) | 3) + 1) / 4;
332 328
333 buf = kmalloc(length * sizeof(__le32), GFP_KERNEL); 329 buf = kmalloc(length * sizeof(__le32), GFP_KERNEL);
334 if (!buf) { 330 if (!buf) {
335 dev_err(&port->dev, "%s - out of memory.\n", 331 dev_err(&port->dev, "%s - out of memory.\n", __func__);
336 __func__);
337 return -ENOMEM; 332 return -ENOMEM;
338 } 333 }
339 334
@@ -384,7 +379,8 @@ static inline int cp210x_set_config_single(struct usb_serial_port *port,
384 * cp210x_quantise_baudrate 379 * cp210x_quantise_baudrate
385 * Quantises the baud rate as per AN205 Table 1 380 * Quantises the baud rate as per AN205 Table 1
386 */ 381 */
387static unsigned int cp210x_quantise_baudrate(unsigned int baud) { 382static unsigned int cp210x_quantise_baudrate(unsigned int baud)
383{
388 if (baud <= 300) 384 if (baud <= 300)
389 baud = 300; 385 baud = 300;
390 else if (baud <= 600) baud = 600; 386 else if (baud <= 600) baud = 600;
@@ -467,9 +463,7 @@ static void cp210x_get_termios(struct tty_struct *tty,
467 cp210x_get_termios_port(tty->driver_data, 463 cp210x_get_termios_port(tty->driver_data,
468 &tty->termios.c_cflag, &baud); 464 &tty->termios.c_cflag, &baud);
469 tty_encode_baud_rate(tty, baud, baud); 465 tty_encode_baud_rate(tty, baud, baud);
470 } 466 } else {
471
472 else {
473 unsigned int cflag; 467 unsigned int cflag;
474 cflag = 0; 468 cflag = 0;
475 cp210x_get_termios_port(port, &cflag, &baud); 469 cp210x_get_termios_port(port, &cflag, &baud);
@@ -693,8 +687,8 @@ static void cp210x_set_termios(struct tty_struct *tty,
693 break;*/ 687 break;*/
694 default: 688 default:
695 dev_dbg(dev, "cp210x driver does not support the number of bits requested, using 8 bit mode\n"); 689 dev_dbg(dev, "cp210x driver does not support the number of bits requested, using 8 bit mode\n");
696 bits |= BITS_DATA_8; 690 bits |= BITS_DATA_8;
697 break; 691 break;
698 } 692 }
699 if (cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2)) 693 if (cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2))
700 dev_dbg(dev, "Number of data bits requested not supported by device\n"); 694 dev_dbg(dev, "Number of data bits requested not supported by device\n");
@@ -767,7 +761,7 @@ static void cp210x_set_termios(struct tty_struct *tty,
767 761
768} 762}
769 763
770static int cp210x_tiocmset (struct tty_struct *tty, 764static int cp210x_tiocmset(struct tty_struct *tty,
771 unsigned int set, unsigned int clear) 765 unsigned int set, unsigned int clear)
772{ 766{
773 struct usb_serial_port *port = tty->driver_data; 767 struct usb_serial_port *port = tty->driver_data;
@@ -809,7 +803,7 @@ static void cp210x_dtr_rts(struct usb_serial_port *p, int on)
809 cp210x_tiocmset_port(p, 0, TIOCM_DTR|TIOCM_RTS); 803 cp210x_tiocmset_port(p, 0, TIOCM_DTR|TIOCM_RTS);
810} 804}
811 805
812static int cp210x_tiocmget (struct tty_struct *tty) 806static int cp210x_tiocmget(struct tty_struct *tty)
813{ 807{
814 struct usb_serial_port *port = tty->driver_data; 808 struct usb_serial_port *port = tty->driver_data;
815 unsigned int control; 809 unsigned int control;
@@ -829,7 +823,7 @@ static int cp210x_tiocmget (struct tty_struct *tty)
829 return result; 823 return result;
830} 824}
831 825
832static void cp210x_break_ctl (struct tty_struct *tty, int break_state) 826static void cp210x_break_ctl(struct tty_struct *tty, int break_state)
833{ 827{
834 struct usb_serial_port *port = tty->driver_data; 828 struct usb_serial_port *port = tty->driver_data;
835 unsigned int state; 829 unsigned int state;
@@ -874,5 +868,4 @@ static void cp210x_release(struct usb_serial *serial)
874module_usb_serial_driver(serial_drivers, id_table); 868module_usb_serial_driver(serial_drivers, id_table);
875 869
876MODULE_DESCRIPTION(DRIVER_DESC); 870MODULE_DESCRIPTION(DRIVER_DESC);
877MODULE_VERSION(DRIVER_VERSION);
878MODULE_LICENSE("GPL"); 871MODULE_LICENSE("GPL");