aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/ftdi_sio.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/serial/ftdi_sio.c')
-rw-r--r--drivers/usb/serial/ftdi_sio.c256
1 files changed, 129 insertions, 127 deletions
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index d3dc1a15ec6c..c186b4e73c72 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -1,16 +1,16 @@
1/* 1/*
2 * USB FTDI SIO driver 2 * USB FTDI SIO driver
3 * 3 *
4 * Copyright (C) 1999 - 2001 4 * Copyright (C) 1999 - 2001
5 * Greg Kroah-Hartman (greg@kroah.com) 5 * Greg Kroah-Hartman (greg@kroah.com)
6 * Bill Ryder (bryder@sgi.com) 6 * Bill Ryder (bryder@sgi.com)
7 * Copyright (C) 2002 7 * Copyright (C) 2002
8 * Kuba Ober (kuba@mareimbrium.org) 8 * Kuba Ober (kuba@mareimbrium.org)
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify 10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by 11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or 12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version. 13 * (at your option) any later version.
14 * 14 *
15 * See Documentation/usb/usb-serial.txt for more information on using this driver 15 * See Documentation/usb/usb-serial.txt for more information on using this driver
16 * 16 *
@@ -32,7 +32,7 @@
32 * Changed full name of USB-UIRT device to avoid "/" character. 32 * Changed full name of USB-UIRT device to avoid "/" character.
33 * Added FTDI's alternate PID (0x6006) for FT232/245 devices. 33 * Added FTDI's alternate PID (0x6006) for FT232/245 devices.
34 * Added PID for "ELV USB Module UO100" from Stefan Frings. 34 * Added PID for "ELV USB Module UO100" from Stefan Frings.
35 * 35 *
36 * (21/Oct/2003) Ian Abbott 36 * (21/Oct/2003) Ian Abbott
37 * Renamed some VID/PID macros for Matrix Orbital and Perle Systems 37 * Renamed some VID/PID macros for Matrix Orbital and Perle Systems
38 * devices. Removed Matrix Orbital and Perle Systems devices from the 38 * devices. Removed Matrix Orbital and Perle Systems devices from the
@@ -69,7 +69,7 @@
69 * does not incure any measurable overhead. This also relies on the fact 69 * does not incure any measurable overhead. This also relies on the fact
70 * that we have proper reference counting logic for urbs. I nicked this 70 * that we have proper reference counting logic for urbs. I nicked this
71 * from Greg KH's Visor driver. 71 * from Greg KH's Visor driver.
72 * 72 *
73 * (23/Jun/2003) Ian Abbott 73 * (23/Jun/2003) Ian Abbott
74 * Reduced flip buffer pushes and corrected a data length test in 74 * Reduced flip buffer pushes and corrected a data length test in
75 * ftdi_read_bulk_callback. 75 * ftdi_read_bulk_callback.
@@ -77,7 +77,7 @@
77 * 77 *
78 * (21/Jun/2003) Erik Nygren 78 * (21/Jun/2003) Erik Nygren
79 * Added support for Home Electronics Tira-1 IR transceiver using FT232BM chip. 79 * Added support for Home Electronics Tira-1 IR transceiver using FT232BM chip.
80 * See <http://www.home-electro.com/tira1.htm>. Only operates properly 80 * See <http://www.home-electro.com/tira1.htm>. Only operates properly
81 * at 100000 and RTS-CTS, so set custom divisor mode on startup. 81 * at 100000 and RTS-CTS, so set custom divisor mode on startup.
82 * Also force the Tira-1 and USB-UIRT to only use their custom baud rates. 82 * Also force the Tira-1 and USB-UIRT to only use their custom baud rates.
83 * 83 *
@@ -137,17 +137,17 @@
137 * (17/Feb/2003) Bill Ryder 137 * (17/Feb/2003) Bill Ryder
138 * Added write urb buffer pool on a per device basis 138 * Added write urb buffer pool on a per device basis
139 * Added more checking for open file on callbacks (fixed OOPS) 139 * Added more checking for open file on callbacks (fixed OOPS)
140 * Added CrystalFontz 632 and 634 PIDs 140 * Added CrystalFontz 632 and 634 PIDs
141 * (thanx to CrystalFontz for the sample devices - they flushed out 141 * (thanx to CrystalFontz for the sample devices - they flushed out
142 * some driver bugs) 142 * some driver bugs)
143 * Minor debugging message changes 143 * Minor debugging message changes
144 * Added throttle, unthrottle and chars_in_buffer functions 144 * Added throttle, unthrottle and chars_in_buffer functions
145 * Fixed FTDI_SIO (the original device) bug 145 * Fixed FTDI_SIO (the original device) bug
146 * Fixed some shutdown handling 146 * Fixed some shutdown handling
147 * 147 *
148 * 148 *
149 * 149 *
150 * 150 *
151 * (07/Jun/2002) Kuba Ober 151 * (07/Jun/2002) Kuba Ober
152 * Changed FTDI_SIO_BASE_BAUD_TO_DIVISOR macro into ftdi_baud_to_divisor 152 * Changed FTDI_SIO_BASE_BAUD_TO_DIVISOR macro into ftdi_baud_to_divisor
153 * function. It was getting too complex. 153 * function. It was getting too complex.
@@ -158,7 +158,7 @@
158 * 158 *
159 * (25/Jul/2002) Bill Ryder inserted Dmitri's TIOCMIWAIT patch 159 * (25/Jul/2002) Bill Ryder inserted Dmitri's TIOCMIWAIT patch
160 * Not tested by me but it doesn't break anything I use. 160 * Not tested by me but it doesn't break anything I use.
161 * 161 *
162 * (04/Jan/2002) Kuba Ober 162 * (04/Jan/2002) Kuba Ober
163 * Implemented 38400 baudrate kludge, where it can be substituted with other 163 * Implemented 38400 baudrate kludge, where it can be substituted with other
164 * values. That's the only way to set custom baudrates. 164 * values. That's the only way to set custom baudrates.
@@ -179,7 +179,7 @@
179 * (the previous version caused panics) 179 * (the previous version caused panics)
180 * Removed port iteration code since the device only has one I/O port and it 180 * Removed port iteration code since the device only has one I/O port and it
181 * was wrong anyway. 181 * was wrong anyway.
182 * 182 *
183 * (31/May/2001) gkh 183 * (31/May/2001) gkh
184 * Switched from using spinlock to a semaphore, which fixes lots of problems. 184 * Switched from using spinlock to a semaphore, which fixes lots of problems.
185 * 185 *
@@ -188,16 +188,16 @@
188 * Cleaned up comments for 8U232 188 * Cleaned up comments for 8U232
189 * Added parity, framing and overrun error handling 189 * Added parity, framing and overrun error handling
190 * Added receive break handling. 190 * Added receive break handling.
191 * 191 *
192 * (04/08/2001) gb 192 * (04/08/2001) gb
193 * Identify version on module load. 193 * Identify version on module load.
194 * 194 *
195 * (18/March/2001) Bill Ryder 195 * (18/March/2001) Bill Ryder
196 * (Not released) 196 * (Not released)
197 * Added send break handling. (requires kernel patch too) 197 * Added send break handling. (requires kernel patch too)
198 * Fixed 8U232AM hardware RTS/CTS etc status reporting. 198 * Fixed 8U232AM hardware RTS/CTS etc status reporting.
199 * Added flipbuf fix copied from generic device 199 * Added flipbuf fix copied from generic device
200 * 200 *
201 * (12/3/2000) Bill Ryder 201 * (12/3/2000) Bill Ryder
202 * Added support for 8U232AM device. 202 * Added support for 8U232AM device.
203 * Moved PID and VIDs into header file only. 203 * Moved PID and VIDs into header file only.
@@ -211,14 +211,14 @@
211 * Cleaned up comments. Removed multiple PID/VID definitions. 211 * Cleaned up comments. Removed multiple PID/VID definitions.
212 * Factorised cts/dtr code 212 * Factorised cts/dtr code
213 * Made use of __FUNCTION__ in dbg's 213 * Made use of __FUNCTION__ in dbg's
214 * 214 *
215 * (11/01/2000) Adam J. Richter 215 * (11/01/2000) Adam J. Richter
216 * usb_device_id table support 216 * usb_device_id table support
217 * 217 *
218 * (10/05/2000) gkh 218 * (10/05/2000) gkh
219 * Fixed bug with urb->dev not being set properly, now that the usb 219 * Fixed bug with urb->dev not being set properly, now that the usb
220 * core needs it. 220 * core needs it.
221 * 221 *
222 * (09/11/2000) gkh 222 * (09/11/2000) gkh
223 * Removed DEBUG #ifdefs with call to usb_serial_debug_data 223 * Removed DEBUG #ifdefs with call to usb_serial_debug_data
224 * 224 *
@@ -226,11 +226,11 @@
226 * Added module_init and module_exit functions to handle the fact that this 226 * Added module_init and module_exit functions to handle the fact that this
227 * driver is a loadable module now. 227 * driver is a loadable module now.
228 * 228 *
229 * (04/04/2000) Bill Ryder 229 * (04/04/2000) Bill Ryder
230 * Fixed bugs in TCGET/TCSET ioctls (by removing them - they are 230 * Fixed bugs in TCGET/TCSET ioctls (by removing them - they are
231 * handled elsewhere in the tty io driver chain). 231 * handled elsewhere in the tty io driver chain).
232 * 232 *
233 * (03/30/2000) Bill Ryder 233 * (03/30/2000) Bill Ryder
234 * Implemented lots of ioctls 234 * Implemented lots of ioctls
235 * Fixed a race condition in write 235 * Fixed a race condition in write
236 * Changed some dbg's to errs 236 * Changed some dbg's to errs
@@ -311,6 +311,7 @@ static struct usb_device_id id_table_combined [] = {
311 { USB_DEVICE(FTDI_VID, FTDI_ACTZWAVE_PID) }, 311 { USB_DEVICE(FTDI_VID, FTDI_ACTZWAVE_PID) },
312 { USB_DEVICE(FTDI_VID, FTDI_IRTRANS_PID) }, 312 { USB_DEVICE(FTDI_VID, FTDI_IRTRANS_PID) },
313 { USB_DEVICE(FTDI_VID, FTDI_IPLUS_PID) }, 313 { USB_DEVICE(FTDI_VID, FTDI_IPLUS_PID) },
314 { USB_DEVICE(FTDI_VID, FTDI_DMX4ALL) },
314 { USB_DEVICE(FTDI_VID, FTDI_SIO_PID) }, 315 { USB_DEVICE(FTDI_VID, FTDI_SIO_PID) },
315 { USB_DEVICE(FTDI_VID, FTDI_8U232AM_PID) }, 316 { USB_DEVICE(FTDI_VID, FTDI_8U232AM_PID) },
316 { USB_DEVICE(FTDI_VID, FTDI_8U232AM_ALT_PID) }, 317 { USB_DEVICE(FTDI_VID, FTDI_8U232AM_ALT_PID) },
@@ -444,13 +445,13 @@ static struct usb_device_id id_table_combined [] = {
444 /* { USB_DEVICE(FTDI_VID, FTDI_ELV_WS300PC_PID) }, */ 445 /* { USB_DEVICE(FTDI_VID, FTDI_ELV_WS300PC_PID) }, */
445 /* { USB_DEVICE(FTDI_VID, FTDI_ELV_FHZ1300PC_PID) }, */ 446 /* { USB_DEVICE(FTDI_VID, FTDI_ELV_FHZ1300PC_PID) }, */
446 /* { USB_DEVICE(FTDI_VID, FTDI_ELV_WS500_PID) }, */ 447 /* { USB_DEVICE(FTDI_VID, FTDI_ELV_WS500_PID) }, */
447 { USB_DEVICE(FTDI_VID, LINX_SDMUSBQSS_PID) }, 448 { USB_DEVICE(FTDI_VID, LINX_SDMUSBQSS_PID) },
448 { USB_DEVICE(FTDI_VID, LINX_MASTERDEVEL2_PID) }, 449 { USB_DEVICE(FTDI_VID, LINX_MASTERDEVEL2_PID) },
449 { USB_DEVICE(FTDI_VID, LINX_FUTURE_0_PID) }, 450 { USB_DEVICE(FTDI_VID, LINX_FUTURE_0_PID) },
450 { USB_DEVICE(FTDI_VID, LINX_FUTURE_1_PID) }, 451 { USB_DEVICE(FTDI_VID, LINX_FUTURE_1_PID) },
451 { USB_DEVICE(FTDI_VID, LINX_FUTURE_2_PID) }, 452 { USB_DEVICE(FTDI_VID, LINX_FUTURE_2_PID) },
452 { USB_DEVICE(FTDI_VID, FTDI_CCSICDU20_0_PID) }, 453 { USB_DEVICE(FTDI_VID, FTDI_CCSICDU20_0_PID) },
453 { USB_DEVICE(FTDI_VID, FTDI_CCSICDU40_1_PID) }, 454 { USB_DEVICE(FTDI_VID, FTDI_CCSICDU40_1_PID) },
454 { USB_DEVICE(FTDI_VID, INSIDE_ACCESSO) }, 455 { USB_DEVICE(FTDI_VID, INSIDE_ACCESSO) },
455 { USB_DEVICE(INTREPID_VID, INTREPID_VALUECAN_PID) }, 456 { USB_DEVICE(INTREPID_VID, INTREPID_VALUECAN_PID) },
456 { USB_DEVICE(INTREPID_VID, INTREPID_NEOVI_PID) }, 457 { USB_DEVICE(INTREPID_VID, INTREPID_NEOVI_PID) },
@@ -511,6 +512,7 @@ static struct usb_device_id id_table_combined [] = {
511 { USB_DEVICE(FTDI_VID, FTDI_TACTRIX_OPENPORT_13M_PID) }, 512 { USB_DEVICE(FTDI_VID, FTDI_TACTRIX_OPENPORT_13M_PID) },
512 { USB_DEVICE(FTDI_VID, FTDI_TACTRIX_OPENPORT_13S_PID) }, 513 { USB_DEVICE(FTDI_VID, FTDI_TACTRIX_OPENPORT_13S_PID) },
513 { USB_DEVICE(FTDI_VID, FTDI_TACTRIX_OPENPORT_13U_PID) }, 514 { USB_DEVICE(FTDI_VID, FTDI_TACTRIX_OPENPORT_13U_PID) },
515 { USB_DEVICE(ELEKTOR_VID, ELEKTOR_FT323R_PID) },
514 { }, /* Optional parameter entry */ 516 { }, /* Optional parameter entry */
515 { } /* Terminating entry */ 517 { } /* Terminating entry */
516}; 518};
@@ -522,7 +524,7 @@ static struct usb_driver ftdi_driver = {
522 .probe = usb_serial_probe, 524 .probe = usb_serial_probe,
523 .disconnect = usb_serial_disconnect, 525 .disconnect = usb_serial_disconnect,
524 .id_table = id_table_combined, 526 .id_table = id_table_combined,
525 .no_dynamic_id = 1, 527 .no_dynamic_id = 1,
526}; 528};
527 529
528static const char *ftdi_chip_name[] = { 530static const char *ftdi_chip_name[] = {
@@ -548,13 +550,13 @@ struct ftdi_private {
548 int custom_divisor; /* custom_divisor kludge, this is for baud_base (different from what goes to the chip!) */ 550 int custom_divisor; /* custom_divisor kludge, this is for baud_base (different from what goes to the chip!) */
549 __u16 last_set_data_urb_value ; 551 __u16 last_set_data_urb_value ;
550 /* the last data state set - needed for doing a break */ 552 /* the last data state set - needed for doing a break */
551 int write_offset; /* This is the offset in the usb data block to write the serial data - 553 int write_offset; /* This is the offset in the usb data block to write the serial data -
552 * it is different between devices 554 * it is different between devices
553 */ 555 */
554 int flags; /* some ASYNC_xxxx flags are supported */ 556 int flags; /* some ASYNC_xxxx flags are supported */
555 unsigned long last_dtr_rts; /* saved modem control outputs */ 557 unsigned long last_dtr_rts; /* saved modem control outputs */
556 wait_queue_head_t delta_msr_wait; /* Used for TIOCMIWAIT */ 558 wait_queue_head_t delta_msr_wait; /* Used for TIOCMIWAIT */
557 char prev_status, diff_status; /* Used for TIOCMIWAIT */ 559 char prev_status, diff_status; /* Used for TIOCMIWAIT */
558 __u8 rx_flags; /* receive state flags (throttling) */ 560 __u8 rx_flags; /* receive state flags (throttling) */
559 spinlock_t rx_lock; /* spinlock for receive state */ 561 spinlock_t rx_lock; /* spinlock for receive state */
560 struct work_struct rx_work; 562 struct work_struct rx_work;
@@ -721,7 +723,7 @@ static int update_mctrl(struct usb_serial_port *port, unsigned int set, unsigned
721 urb_value |= FTDI_SIO_SET_RTS_HIGH; 723 urb_value |= FTDI_SIO_SET_RTS_HIGH;
722 rv = usb_control_msg(port->serial->dev, 724 rv = usb_control_msg(port->serial->dev,
723 usb_sndctrlpipe(port->serial->dev, 0), 725 usb_sndctrlpipe(port->serial->dev, 0),
724 FTDI_SIO_SET_MODEM_CTRL_REQUEST, 726 FTDI_SIO_SET_MODEM_CTRL_REQUEST,
725 FTDI_SIO_SET_MODEM_CTRL_REQUEST_TYPE, 727 FTDI_SIO_SET_MODEM_CTRL_REQUEST_TYPE,
726 urb_value, priv->interface, 728 urb_value, priv->interface,
727 buf, 0, WDR_TIMEOUT); 729 buf, 0, WDR_TIMEOUT);
@@ -768,7 +770,7 @@ static int change_speed(struct usb_serial_port *port)
768 if (priv->interface) { /* FT2232C */ 770 if (priv->interface) { /* FT2232C */
769 urb_index = (__u16)((urb_index << 8) | priv->interface); 771 urb_index = (__u16)((urb_index << 8) | priv->interface);
770 } 772 }
771 773
772 rv = usb_control_msg(port->serial->dev, 774 rv = usb_control_msg(port->serial->dev,
773 usb_sndctrlpipe(port->serial->dev, 0), 775 usb_sndctrlpipe(port->serial->dev, 0),
774 FTDI_SIO_SET_BAUDRATE_REQUEST, 776 FTDI_SIO_SET_BAUDRATE_REQUEST,
@@ -827,7 +829,7 @@ static __u32 get_ftdi_divisor(struct usb_serial_port * port)
827 829
828 /* 3. Convert baudrate to device-specific divisor */ 830 /* 3. Convert baudrate to device-specific divisor */
829 831
830 if (!baud) baud = 9600; 832 if (!baud) baud = 9600;
831 switch(priv->chip_type) { 833 switch(priv->chip_type) {
832 case SIO: /* SIO chip */ 834 case SIO: /* SIO chip */
833 switch(baud) { 835 switch(baud) {
@@ -843,7 +845,7 @@ static __u32 get_ftdi_divisor(struct usb_serial_port * port)
843 case 115200: div_value = ftdi_sio_b115200; break; 845 case 115200: div_value = ftdi_sio_b115200; break;
844 } /* baud */ 846 } /* baud */
845 if (div_value == 0) { 847 if (div_value == 0) {
846 dbg("%s - Baudrate (%d) requested is not supported", __FUNCTION__, baud); 848 dbg("%s - Baudrate (%d) requested is not supported", __FUNCTION__, baud);
847 div_value = ftdi_sio_b9600; 849 div_value = ftdi_sio_b9600;
848 div_okay = 0; 850 div_okay = 0;
849 } 851 }
@@ -925,7 +927,7 @@ static int set_serial_info(struct usb_serial_port * port, struct serial_struct _
925 /* Make the changes - these are privileged changes! */ 927 /* Make the changes - these are privileged changes! */
926 928
927 priv->flags = ((priv->flags & ~ASYNC_FLAGS) | 929 priv->flags = ((priv->flags & ~ASYNC_FLAGS) |
928 (new_serial.flags & ASYNC_FLAGS)); 930 (new_serial.flags & ASYNC_FLAGS));
929 priv->custom_divisor = new_serial.custom_divisor; 931 priv->custom_divisor = new_serial.custom_divisor;
930 932
931 port->tty->low_latency = (priv->flags & ASYNC_LOW_LATENCY) ? 1 : 0; 933 port->tty->low_latency = (priv->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
@@ -950,7 +952,7 @@ check_and_exit:
950 (old_priv.custom_divisor != priv->custom_divisor))) { 952 (old_priv.custom_divisor != priv->custom_divisor))) {
951 change_speed(port); 953 change_speed(port);
952 } 954 }
953 955
954 return (0); 956 return (0);
955 957
956} /* set_serial_info */ 958} /* set_serial_info */
@@ -1022,18 +1024,18 @@ static ssize_t show_latency_timer(struct device *dev, struct device_attribute *a
1022 struct usb_device *udev; 1024 struct usb_device *udev;
1023 unsigned short latency = 0; 1025 unsigned short latency = 0;
1024 int rv = 0; 1026 int rv = 0;
1025 1027
1026 udev = to_usb_device(dev); 1028 udev = to_usb_device(dev);
1027 1029
1028 dbg("%s",__FUNCTION__); 1030 dbg("%s",__FUNCTION__);
1029 1031
1030 rv = usb_control_msg(udev, 1032 rv = usb_control_msg(udev,
1031 usb_rcvctrlpipe(udev, 0), 1033 usb_rcvctrlpipe(udev, 0),
1032 FTDI_SIO_GET_LATENCY_TIMER_REQUEST, 1034 FTDI_SIO_GET_LATENCY_TIMER_REQUEST,
1033 FTDI_SIO_GET_LATENCY_TIMER_REQUEST_TYPE, 1035 FTDI_SIO_GET_LATENCY_TIMER_REQUEST_TYPE,
1034 0, priv->interface, 1036 0, priv->interface,
1035 (char*) &latency, 1, WDR_TIMEOUT); 1037 (char*) &latency, 1, WDR_TIMEOUT);
1036 1038
1037 if (rv < 0) { 1039 if (rv < 0) {
1038 dev_err(dev, "Unable to read latency timer: %i", rv); 1040 dev_err(dev, "Unable to read latency timer: %i", rv);
1039 return -EIO; 1041 return -EIO;
@@ -1051,23 +1053,23 @@ static ssize_t store_latency_timer(struct device *dev, struct device_attribute *
1051 char buf[1]; 1053 char buf[1];
1052 int v = simple_strtoul(valbuf, NULL, 10); 1054 int v = simple_strtoul(valbuf, NULL, 10);
1053 int rv = 0; 1055 int rv = 0;
1054 1056
1055 udev = to_usb_device(dev); 1057 udev = to_usb_device(dev);
1056 1058
1057 dbg("%s: setting latency timer = %i", __FUNCTION__, v); 1059 dbg("%s: setting latency timer = %i", __FUNCTION__, v);
1058 1060
1059 rv = usb_control_msg(udev, 1061 rv = usb_control_msg(udev,
1060 usb_sndctrlpipe(udev, 0), 1062 usb_sndctrlpipe(udev, 0),
1061 FTDI_SIO_SET_LATENCY_TIMER_REQUEST, 1063 FTDI_SIO_SET_LATENCY_TIMER_REQUEST,
1062 FTDI_SIO_SET_LATENCY_TIMER_REQUEST_TYPE, 1064 FTDI_SIO_SET_LATENCY_TIMER_REQUEST_TYPE,
1063 v, priv->interface, 1065 v, priv->interface,
1064 buf, 0, WDR_TIMEOUT); 1066 buf, 0, WDR_TIMEOUT);
1065 1067
1066 if (rv < 0) { 1068 if (rv < 0) {
1067 dev_err(dev, "Unable to write latency timer: %i", rv); 1069 dev_err(dev, "Unable to write latency timer: %i", rv);
1068 return -EIO; 1070 return -EIO;
1069 } 1071 }
1070 1072
1071 return count; 1073 return count;
1072} 1074}
1073 1075
@@ -1082,23 +1084,23 @@ static ssize_t store_event_char(struct device *dev, struct device_attribute *att
1082 char buf[1]; 1084 char buf[1];
1083 int v = simple_strtoul(valbuf, NULL, 10); 1085 int v = simple_strtoul(valbuf, NULL, 10);
1084 int rv = 0; 1086 int rv = 0;
1085 1087
1086 udev = to_usb_device(dev); 1088 udev = to_usb_device(dev);
1087 1089
1088 dbg("%s: setting event char = %i", __FUNCTION__, v); 1090 dbg("%s: setting event char = %i", __FUNCTION__, v);
1089 1091
1090 rv = usb_control_msg(udev, 1092 rv = usb_control_msg(udev,
1091 usb_sndctrlpipe(udev, 0), 1093 usb_sndctrlpipe(udev, 0),
1092 FTDI_SIO_SET_EVENT_CHAR_REQUEST, 1094 FTDI_SIO_SET_EVENT_CHAR_REQUEST,
1093 FTDI_SIO_SET_EVENT_CHAR_REQUEST_TYPE, 1095 FTDI_SIO_SET_EVENT_CHAR_REQUEST_TYPE,
1094 v, priv->interface, 1096 v, priv->interface,
1095 buf, 0, WDR_TIMEOUT); 1097 buf, 0, WDR_TIMEOUT);
1096 1098
1097 if (rv < 0) { 1099 if (rv < 0) {
1098 dbg("Unable to write event character: %i", rv); 1100 dbg("Unable to write event character: %i", rv);
1099 return -EIO; 1101 return -EIO;
1100 } 1102 }
1101 1103
1102 return count; 1104 return count;
1103} 1105}
1104 1106
@@ -1135,11 +1137,11 @@ static void remove_sysfs_attrs(struct usb_serial *serial)
1135 struct ftdi_private *priv; 1137 struct ftdi_private *priv;
1136 struct usb_device *udev; 1138 struct usb_device *udev;
1137 1139
1138 dbg("%s",__FUNCTION__); 1140 dbg("%s",__FUNCTION__);
1139 1141
1140 priv = usb_get_serial_port_data(serial->port[0]); 1142 priv = usb_get_serial_port_data(serial->port[0]);
1141 udev = serial->dev; 1143 udev = serial->dev;
1142 1144
1143 /* XXX see create_sysfs_attrs */ 1145 /* XXX see create_sysfs_attrs */
1144 if (priv->chip_type != SIO) { 1146 if (priv->chip_type != SIO) {
1145 device_remove_file(&udev->dev, &dev_attr_event_char); 1147 device_remove_file(&udev->dev, &dev_attr_event_char);
@@ -1147,7 +1149,7 @@ static void remove_sysfs_attrs(struct usb_serial *serial)
1147 device_remove_file(&udev->dev, &dev_attr_latency_timer); 1149 device_remove_file(&udev->dev, &dev_attr_latency_timer);
1148 } 1150 }
1149 } 1151 }
1150 1152
1151} 1153}
1152 1154
1153/* 1155/*
@@ -1258,7 +1260,7 @@ static void ftdi_HE_TIRA1_setup (struct usb_serial *serial)
1258} /* ftdi_HE_TIRA1_setup */ 1260} /* ftdi_HE_TIRA1_setup */
1259 1261
1260 1262
1261/* ftdi_shutdown is called from usbserial:usb_serial_disconnect 1263/* ftdi_shutdown is called from usbserial:usb_serial_disconnect
1262 * it is called when the usb device is disconnected 1264 * it is called when the usb device is disconnected
1263 * 1265 *
1264 * usbserial:usb_serial_disconnect 1266 * usbserial:usb_serial_disconnect
@@ -1269,16 +1271,16 @@ static void ftdi_HE_TIRA1_setup (struct usb_serial *serial)
1269 1271
1270static void ftdi_shutdown (struct usb_serial *serial) 1272static void ftdi_shutdown (struct usb_serial *serial)
1271{ /* ftdi_shutdown */ 1273{ /* ftdi_shutdown */
1272 1274
1273 struct usb_serial_port *port = serial->port[0]; 1275 struct usb_serial_port *port = serial->port[0];
1274 struct ftdi_private *priv = usb_get_serial_port_data(port); 1276 struct ftdi_private *priv = usb_get_serial_port_data(port);
1275 1277
1276 dbg("%s", __FUNCTION__); 1278 dbg("%s", __FUNCTION__);
1277 1279
1278 remove_sysfs_attrs(serial); 1280 remove_sysfs_attrs(serial);
1279 1281
1280 /* all open ports are closed at this point 1282 /* all open ports are closed at this point
1281 * (by usbserial.c:__serial_close, which calls ftdi_close) 1283 * (by usbserial.c:__serial_close, which calls ftdi_close)
1282 */ 1284 */
1283 1285
1284 if (priv) { 1286 if (priv) {
@@ -1293,7 +1295,7 @@ static int ftdi_open (struct usb_serial_port *port, struct file *filp)
1293 struct usb_device *dev = port->serial->dev; 1295 struct usb_device *dev = port->serial->dev;
1294 struct ftdi_private *priv = usb_get_serial_port_data(port); 1296 struct ftdi_private *priv = usb_get_serial_port_data(port);
1295 unsigned long flags; 1297 unsigned long flags;
1296 1298
1297 int result = 0; 1299 int result = 0;
1298 char buf[1]; /* Needed for the usb_control_msg I think */ 1300 char buf[1]; /* Needed for the usb_control_msg I think */
1299 1301
@@ -1312,8 +1314,8 @@ static int ftdi_open (struct usb_serial_port *port, struct file *filp)
1312 /* No error checking for this (will get errors later anyway) */ 1314 /* No error checking for this (will get errors later anyway) */
1313 /* See ftdi_sio.h for description of what is reset */ 1315 /* See ftdi_sio.h for description of what is reset */
1314 usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 1316 usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
1315 FTDI_SIO_RESET_REQUEST, FTDI_SIO_RESET_REQUEST_TYPE, 1317 FTDI_SIO_RESET_REQUEST, FTDI_SIO_RESET_REQUEST_TYPE,
1316 FTDI_SIO_RESET_SIO, 1318 FTDI_SIO_RESET_SIO,
1317 priv->interface, buf, 0, WDR_TIMEOUT); 1319 priv->interface, buf, 0, WDR_TIMEOUT);
1318 1320
1319 /* Termios defaults are set by usb_serial_init. We don't change 1321 /* Termios defaults are set by usb_serial_init. We don't change
@@ -1350,12 +1352,12 @@ static int ftdi_open (struct usb_serial_port *port, struct file *filp)
1350 1352
1351 1353
1352 1354
1353/* 1355/*
1354 * usbserial:__serial_close only calls ftdi_close if the point is open 1356 * usbserial:__serial_close only calls ftdi_close if the point is open
1355 * 1357 *
1356 * This only gets called when it is the last close 1358 * This only gets called when it is the last close
1357 * 1359 *
1358 * 1360 *
1359 */ 1361 */
1360 1362
1361static void ftdi_close (struct usb_serial_port *port, struct file *filp) 1363static void ftdi_close (struct usb_serial_port *port, struct file *filp)
@@ -1368,14 +1370,14 @@ static void ftdi_close (struct usb_serial_port *port, struct file *filp)
1368 1370
1369 if (c_cflag & HUPCL){ 1371 if (c_cflag & HUPCL){
1370 /* Disable flow control */ 1372 /* Disable flow control */
1371 if (usb_control_msg(port->serial->dev, 1373 if (usb_control_msg(port->serial->dev,
1372 usb_sndctrlpipe(port->serial->dev, 0), 1374 usb_sndctrlpipe(port->serial->dev, 0),
1373 FTDI_SIO_SET_FLOW_CTRL_REQUEST, 1375 FTDI_SIO_SET_FLOW_CTRL_REQUEST,
1374 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, 1376 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE,
1375 0, priv->interface, buf, 0, 1377 0, priv->interface, buf, 0,
1376 WDR_TIMEOUT) < 0) { 1378 WDR_TIMEOUT) < 0) {
1377 err("error from flowcontrol urb"); 1379 err("error from flowcontrol urb");
1378 } 1380 }
1379 1381
1380 /* drop RTS and DTR */ 1382 /* drop RTS and DTR */
1381 clear_mctrl(port, TIOCM_DTR | TIOCM_RTS); 1383 clear_mctrl(port, TIOCM_DTR | TIOCM_RTS);
@@ -1384,14 +1386,14 @@ static void ftdi_close (struct usb_serial_port *port, struct file *filp)
1384 /* cancel any scheduled reading */ 1386 /* cancel any scheduled reading */
1385 cancel_delayed_work(&priv->rx_work); 1387 cancel_delayed_work(&priv->rx_work);
1386 flush_scheduled_work(); 1388 flush_scheduled_work();
1387 1389
1388 /* shutdown our bulk read */ 1390 /* shutdown our bulk read */
1389 if (port->read_urb) 1391 if (port->read_urb)
1390 usb_kill_urb(port->read_urb); 1392 usb_kill_urb(port->read_urb);
1391} /* ftdi_close */ 1393} /* ftdi_close */
1392 1394
1393 1395
1394 1396
1395/* The SIO requires the first byte to have: 1397/* The SIO requires the first byte to have:
1396 * B0 1 1398 * B0 1
1397 * B1 0 1399 * B1 0
@@ -1423,7 +1425,7 @@ static int ftdi_write (struct usb_serial_port *port,
1423 return 0; 1425 return 0;
1424 } 1426 }
1425 spin_unlock_irqrestore(&priv->tx_lock, flags); 1427 spin_unlock_irqrestore(&priv->tx_lock, flags);
1426 1428
1427 data_offset = priv->write_offset; 1429 data_offset = priv->write_offset;
1428 dbg("data_offset set to %d",data_offset); 1430 dbg("data_offset set to %d",data_offset);
1429 1431
@@ -1462,7 +1464,7 @@ static int ftdi_write (struct usb_serial_port *port,
1462 user_pktsz = todo; 1464 user_pktsz = todo;
1463 } 1465 }
1464 /* Write the control byte at the front of the packet*/ 1466 /* Write the control byte at the front of the packet*/
1465 *first_byte = 1 | ((user_pktsz) << 2); 1467 *first_byte = 1 | ((user_pktsz) << 2);
1466 /* Copy data for packet */ 1468 /* Copy data for packet */
1467 memcpy (first_byte + data_offset, 1469 memcpy (first_byte + data_offset,
1468 current_position, user_pktsz); 1470 current_position, user_pktsz);
@@ -1479,7 +1481,7 @@ static int ftdi_write (struct usb_serial_port *port,
1479 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, transfer_size, buffer); 1481 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, transfer_size, buffer);
1480 1482
1481 /* fill the buffer and send it */ 1483 /* fill the buffer and send it */
1482 usb_fill_bulk_urb(urb, port->serial->dev, 1484 usb_fill_bulk_urb(urb, port->serial->dev,
1483 usb_sndbulkpipe(port->serial->dev, port->bulk_out_endpointAddress), 1485 usb_sndbulkpipe(port->serial->dev, port->bulk_out_endpointAddress),
1484 buffer, transfer_size, 1486 buffer, transfer_size,
1485 ftdi_write_bulk_callback, port); 1487 ftdi_write_bulk_callback, port);
@@ -1520,7 +1522,7 @@ static void ftdi_write_bulk_callback (struct urb *urb)
1520 kfree (urb->transfer_buffer); 1522 kfree (urb->transfer_buffer);
1521 1523
1522 dbg("%s - port %d", __FUNCTION__, port->number); 1524 dbg("%s - port %d", __FUNCTION__, port->number);
1523 1525
1524 if (urb->status) { 1526 if (urb->status) {
1525 dbg("nonzero write bulk status received: %d", urb->status); 1527 dbg("nonzero write bulk status received: %d", urb->status);
1526 return; 1528 return;
@@ -1651,7 +1653,7 @@ static void ftdi_process_read (void *param)
1651 struct tty_struct *tty; 1653 struct tty_struct *tty;
1652 struct ftdi_private *priv; 1654 struct ftdi_private *priv;
1653 char error_flag; 1655 char error_flag;
1654 unsigned char *data; 1656 unsigned char *data;
1655 1657
1656 int i; 1658 int i;
1657 int result; 1659 int result;
@@ -1759,7 +1761,7 @@ static void ftdi_process_read (void *param)
1759 } 1761 }
1760 if (length > 0) { 1762 if (length > 0) {
1761 for (i = 2; i < length+2; i++) { 1763 for (i = 2; i < length+2; i++) {
1762 /* Note that the error flag is duplicated for 1764 /* Note that the error flag is duplicated for
1763 every character received since we don't know 1765 every character received since we don't know
1764 which character it applied to */ 1766 which character it applied to */
1765 tty_insert_flip_char(tty, data[packet_offset+i], error_flag); 1767 tty_insert_flip_char(tty, data[packet_offset+i], error_flag);
@@ -1773,7 +1775,7 @@ static void ftdi_process_read (void *param)
1773 This doesn't work well since the application receives a never 1775 This doesn't work well since the application receives a never
1774 ending stream of bad data - even though new data hasn't been sent. 1776 ending stream of bad data - even though new data hasn't been sent.
1775 Therefore I (bill) have taken this out. 1777 Therefore I (bill) have taken this out.
1776 However - this might make sense for framing errors and so on 1778 However - this might make sense for framing errors and so on
1777 so I am leaving the code in for now. 1779 so I am leaving the code in for now.
1778 */ 1780 */
1779 else { 1781 else {
@@ -1827,7 +1829,7 @@ static void ftdi_process_read (void *param)
1827 /* if the port is closed stop trying to read */ 1829 /* if the port is closed stop trying to read */
1828 if (port->open_count > 0){ 1830 if (port->open_count > 0){
1829 /* Continue trying to always read */ 1831 /* Continue trying to always read */
1830 usb_fill_bulk_urb(port->read_urb, port->serial->dev, 1832 usb_fill_bulk_urb(port->read_urb, port->serial->dev,
1831 usb_rcvbulkpipe(port->serial->dev, port->bulk_in_endpointAddress), 1833 usb_rcvbulkpipe(port->serial->dev, port->bulk_in_endpointAddress),
1832 port->read_urb->transfer_buffer, port->read_urb->transfer_buffer_length, 1834 port->read_urb->transfer_buffer, port->read_urb->transfer_buffer_length,
1833 ftdi_read_bulk_callback, port); 1835 ftdi_read_bulk_callback, port);
@@ -1844,9 +1846,9 @@ static void ftdi_process_read (void *param)
1844static void ftdi_break_ctl( struct usb_serial_port *port, int break_state ) 1846static void ftdi_break_ctl( struct usb_serial_port *port, int break_state )
1845{ 1847{
1846 struct ftdi_private *priv = usb_get_serial_port_data(port); 1848 struct ftdi_private *priv = usb_get_serial_port_data(port);
1847 __u16 urb_value = 0; 1849 __u16 urb_value = 0;
1848 char buf[1]; 1850 char buf[1];
1849 1851
1850 /* break_state = -1 to turn on break, and 0 to turn off break */ 1852 /* break_state = -1 to turn on break, and 0 to turn off break */
1851 /* see drivers/char/tty_io.c to see it used */ 1853 /* see drivers/char/tty_io.c to see it used */
1852 /* last_set_data_urb_value NEVER has the break bit set in it */ 1854 /* last_set_data_urb_value NEVER has the break bit set in it */
@@ -1854,20 +1856,20 @@ static void ftdi_break_ctl( struct usb_serial_port *port, int break_state )
1854 if (break_state) { 1856 if (break_state) {
1855 urb_value = priv->last_set_data_urb_value | FTDI_SIO_SET_BREAK; 1857 urb_value = priv->last_set_data_urb_value | FTDI_SIO_SET_BREAK;
1856 } else { 1858 } else {
1857 urb_value = priv->last_set_data_urb_value; 1859 urb_value = priv->last_set_data_urb_value;
1858 } 1860 }
1859 1861
1860 1862
1861 if (usb_control_msg(port->serial->dev, usb_sndctrlpipe(port->serial->dev, 0), 1863 if (usb_control_msg(port->serial->dev, usb_sndctrlpipe(port->serial->dev, 0),
1862 FTDI_SIO_SET_DATA_REQUEST, 1864 FTDI_SIO_SET_DATA_REQUEST,
1863 FTDI_SIO_SET_DATA_REQUEST_TYPE, 1865 FTDI_SIO_SET_DATA_REQUEST_TYPE,
1864 urb_value , priv->interface, 1866 urb_value , priv->interface,
1865 buf, 0, WDR_TIMEOUT) < 0) { 1867 buf, 0, WDR_TIMEOUT) < 0) {
1866 err("%s FAILED to enable/disable break state (state was %d)", __FUNCTION__,break_state); 1868 err("%s FAILED to enable/disable break state (state was %d)", __FUNCTION__,break_state);
1867 } 1869 }
1868 1870
1869 dbg("%s break state is %d - urb is %d", __FUNCTION__,break_state, urb_value); 1871 dbg("%s break state is %d - urb is %d", __FUNCTION__,break_state, urb_value);
1870 1872
1871} 1873}
1872 1874
1873 1875
@@ -1883,12 +1885,12 @@ static void ftdi_set_termios (struct usb_serial_port *port, struct termios *old_
1883 struct ftdi_private *priv = usb_get_serial_port_data(port); 1885 struct ftdi_private *priv = usb_get_serial_port_data(port);
1884 __u16 urb_value; /* will hold the new flags */ 1886 __u16 urb_value; /* will hold the new flags */
1885 char buf[1]; /* Perhaps I should dynamically alloc this? */ 1887 char buf[1]; /* Perhaps I should dynamically alloc this? */
1886 1888
1887 // Added for xon/xoff support 1889 // Added for xon/xoff support
1888 unsigned int iflag = port->tty->termios->c_iflag; 1890 unsigned int iflag = port->tty->termios->c_iflag;
1889 unsigned char vstop; 1891 unsigned char vstop;
1890 unsigned char vstart; 1892 unsigned char vstart;
1891 1893
1892 dbg("%s", __FUNCTION__); 1894 dbg("%s", __FUNCTION__);
1893 1895
1894 /* Force baud rate if this device requires it, unless it is set to B0. */ 1896 /* Force baud rate if this device requires it, unless it is set to B0. */
@@ -1906,20 +1908,20 @@ static void ftdi_set_termios (struct usb_serial_port *port, struct termios *old_
1906 1908
1907 cflag = port->tty->termios->c_cflag; 1909 cflag = port->tty->termios->c_cflag;
1908 1910
1909 /* FIXME -For this cut I don't care if the line is really changing or 1911 /* FIXME -For this cut I don't care if the line is really changing or
1910 not - so just do the change regardless - should be able to 1912 not - so just do the change regardless - should be able to
1911 compare old_termios and tty->termios */ 1913 compare old_termios and tty->termios */
1912 /* NOTE These routines can get interrupted by 1914 /* NOTE These routines can get interrupted by
1913 ftdi_sio_read_bulk_callback - need to examine what this 1915 ftdi_sio_read_bulk_callback - need to examine what this
1914 means - don't see any problems yet */ 1916 means - don't see any problems yet */
1915 1917
1916 /* Set number of data bits, parity, stop bits */ 1918 /* Set number of data bits, parity, stop bits */
1917 1919
1918 urb_value = 0; 1920 urb_value = 0;
1919 urb_value |= (cflag & CSTOPB ? FTDI_SIO_SET_DATA_STOP_BITS_2 : 1921 urb_value |= (cflag & CSTOPB ? FTDI_SIO_SET_DATA_STOP_BITS_2 :
1920 FTDI_SIO_SET_DATA_STOP_BITS_1); 1922 FTDI_SIO_SET_DATA_STOP_BITS_1);
1921 urb_value |= (cflag & PARENB ? 1923 urb_value |= (cflag & PARENB ?
1922 (cflag & PARODD ? FTDI_SIO_SET_DATA_PARITY_ODD : 1924 (cflag & PARODD ? FTDI_SIO_SET_DATA_PARITY_ODD :
1923 FTDI_SIO_SET_DATA_PARITY_EVEN) : 1925 FTDI_SIO_SET_DATA_PARITY_EVEN) :
1924 FTDI_SIO_SET_DATA_PARITY_NONE); 1926 FTDI_SIO_SET_DATA_PARITY_NONE);
1925 if (cflag & CSIZE) { 1927 if (cflag & CSIZE) {
@@ -1936,25 +1938,25 @@ static void ftdi_set_termios (struct usb_serial_port *port, struct termios *old_
1936 /* This is needed by the break command since it uses the same command - but is 1938 /* This is needed by the break command since it uses the same command - but is
1937 * or'ed with this value */ 1939 * or'ed with this value */
1938 priv->last_set_data_urb_value = urb_value; 1940 priv->last_set_data_urb_value = urb_value;
1939 1941
1940 if (usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 1942 if (usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
1941 FTDI_SIO_SET_DATA_REQUEST, 1943 FTDI_SIO_SET_DATA_REQUEST,
1942 FTDI_SIO_SET_DATA_REQUEST_TYPE, 1944 FTDI_SIO_SET_DATA_REQUEST_TYPE,
1943 urb_value , priv->interface, 1945 urb_value , priv->interface,
1944 buf, 0, WDR_SHORT_TIMEOUT) < 0) { 1946 buf, 0, WDR_SHORT_TIMEOUT) < 0) {
1945 err("%s FAILED to set databits/stopbits/parity", __FUNCTION__); 1947 err("%s FAILED to set databits/stopbits/parity", __FUNCTION__);
1946 } 1948 }
1947 1949
1948 /* Now do the baudrate */ 1950 /* Now do the baudrate */
1949 if ((cflag & CBAUD) == B0 ) { 1951 if ((cflag & CBAUD) == B0 ) {
1950 /* Disable flow control */ 1952 /* Disable flow control */
1951 if (usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 1953 if (usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
1952 FTDI_SIO_SET_FLOW_CTRL_REQUEST, 1954 FTDI_SIO_SET_FLOW_CTRL_REQUEST,
1953 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, 1955 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE,
1954 0, priv->interface, 1956 0, priv->interface,
1955 buf, 0, WDR_TIMEOUT) < 0) { 1957 buf, 0, WDR_TIMEOUT) < 0) {
1956 err("%s error from disable flowcontrol urb", __FUNCTION__); 1958 err("%s error from disable flowcontrol urb", __FUNCTION__);
1957 } 1959 }
1958 /* Drop RTS and DTR */ 1960 /* Drop RTS and DTR */
1959 clear_mctrl(port, TIOCM_DTR | TIOCM_RTS); 1961 clear_mctrl(port, TIOCM_DTR | TIOCM_RTS);
1960 } else { 1962 } else {
@@ -1972,16 +1974,16 @@ static void ftdi_set_termios (struct usb_serial_port *port, struct termios *old_
1972 /* Note device also supports DTR/CD (ugh) and Xon/Xoff in hardware */ 1974 /* Note device also supports DTR/CD (ugh) and Xon/Xoff in hardware */
1973 if (cflag & CRTSCTS) { 1975 if (cflag & CRTSCTS) {
1974 dbg("%s Setting to CRTSCTS flow control", __FUNCTION__); 1976 dbg("%s Setting to CRTSCTS flow control", __FUNCTION__);
1975 if (usb_control_msg(dev, 1977 if (usb_control_msg(dev,
1976 usb_sndctrlpipe(dev, 0), 1978 usb_sndctrlpipe(dev, 0),
1977 FTDI_SIO_SET_FLOW_CTRL_REQUEST, 1979 FTDI_SIO_SET_FLOW_CTRL_REQUEST,
1978 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, 1980 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE,
1979 0 , (FTDI_SIO_RTS_CTS_HS | priv->interface), 1981 0 , (FTDI_SIO_RTS_CTS_HS | priv->interface),
1980 buf, 0, WDR_TIMEOUT) < 0) { 1982 buf, 0, WDR_TIMEOUT) < 0) {
1981 err("urb failed to set to rts/cts flow control"); 1983 err("urb failed to set to rts/cts flow control");
1982 } 1984 }
1983 1985
1984 } else { 1986 } else {
1985 /* 1987 /*
1986 * Xon/Xoff code 1988 * Xon/Xoff code
1987 * 1989 *
@@ -2011,16 +2013,16 @@ static void ftdi_set_termios (struct usb_serial_port *port, struct termios *old_
2011 /* else clause to only run if cfag ! CRTSCTS and iflag ! XOFF */ 2013 /* else clause to only run if cfag ! CRTSCTS and iflag ! XOFF */
2012 /* CHECKME Assuming XON/XOFF handled by tty stack - not by device */ 2014 /* CHECKME Assuming XON/XOFF handled by tty stack - not by device */
2013 dbg("%s Turning off hardware flow control", __FUNCTION__); 2015 dbg("%s Turning off hardware flow control", __FUNCTION__);
2014 if (usb_control_msg(dev, 2016 if (usb_control_msg(dev,
2015 usb_sndctrlpipe(dev, 0), 2017 usb_sndctrlpipe(dev, 0),
2016 FTDI_SIO_SET_FLOW_CTRL_REQUEST, 2018 FTDI_SIO_SET_FLOW_CTRL_REQUEST,
2017 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, 2019 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE,
2018 0, priv->interface, 2020 0, priv->interface,
2019 buf, 0, WDR_TIMEOUT) < 0) { 2021 buf, 0, WDR_TIMEOUT) < 0) {
2020 err("urb failed to clear flow control"); 2022 err("urb failed to clear flow control");
2021 } 2023 }
2022 } 2024 }
2023 2025
2024 } 2026 }
2025 return; 2027 return;
2026} /* ftdi_termios */ 2028} /* ftdi_termios */
@@ -2036,11 +2038,11 @@ static int ftdi_tiocmget (struct usb_serial_port *port, struct file *file)
2036 switch (priv->chip_type) { 2038 switch (priv->chip_type) {
2037 case SIO: 2039 case SIO:
2038 /* Request the status from the device */ 2040 /* Request the status from the device */
2039 if ((ret = usb_control_msg(port->serial->dev, 2041 if ((ret = usb_control_msg(port->serial->dev,
2040 usb_rcvctrlpipe(port->serial->dev, 0), 2042 usb_rcvctrlpipe(port->serial->dev, 0),
2041 FTDI_SIO_GET_MODEM_STATUS_REQUEST, 2043 FTDI_SIO_GET_MODEM_STATUS_REQUEST,
2042 FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE, 2044 FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE,
2043 0, 0, 2045 0, 0,
2044 buf, 1, WDR_TIMEOUT)) < 0 ) { 2046 buf, 1, WDR_TIMEOUT)) < 0 ) {
2045 err("%s Could not get modem status of device - err: %d", __FUNCTION__, 2047 err("%s Could not get modem status of device - err: %d", __FUNCTION__,
2046 ret); 2048 ret);
@@ -2052,11 +2054,11 @@ static int ftdi_tiocmget (struct usb_serial_port *port, struct file *file)
2052 case FT2232C: 2054 case FT2232C:
2053 /* the 8U232AM returns a two byte value (the sio is a 1 byte value) - in the same 2055 /* the 8U232AM returns a two byte value (the sio is a 1 byte value) - in the same
2054 format as the data returned from the in point */ 2056 format as the data returned from the in point */
2055 if ((ret = usb_control_msg(port->serial->dev, 2057 if ((ret = usb_control_msg(port->serial->dev,
2056 usb_rcvctrlpipe(port->serial->dev, 0), 2058 usb_rcvctrlpipe(port->serial->dev, 0),
2057 FTDI_SIO_GET_MODEM_STATUS_REQUEST, 2059 FTDI_SIO_GET_MODEM_STATUS_REQUEST,
2058 FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE, 2060 FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE,
2059 0, priv->interface, 2061 0, priv->interface,
2060 buf, 2, WDR_TIMEOUT)) < 0 ) { 2062 buf, 2, WDR_TIMEOUT)) < 0 ) {
2061 err("%s Could not get modem status of device - err: %d", __FUNCTION__, 2063 err("%s Could not get modem status of device - err: %d", __FUNCTION__,
2062 ret); 2064 ret);
@@ -2067,12 +2069,12 @@ static int ftdi_tiocmget (struct usb_serial_port *port, struct file *file)
2067 return -EFAULT; 2069 return -EFAULT;
2068 break; 2070 break;
2069 } 2071 }
2070 2072
2071 return (buf[0] & FTDI_SIO_DSR_MASK ? TIOCM_DSR : 0) | 2073 return (buf[0] & FTDI_SIO_DSR_MASK ? TIOCM_DSR : 0) |
2072 (buf[0] & FTDI_SIO_CTS_MASK ? TIOCM_CTS : 0) | 2074 (buf[0] & FTDI_SIO_CTS_MASK ? TIOCM_CTS : 0) |
2073 (buf[0] & FTDI_SIO_RI_MASK ? TIOCM_RI : 0) | 2075 (buf[0] & FTDI_SIO_RI_MASK ? TIOCM_RI : 0) |
2074 (buf[0] & FTDI_SIO_RLSD_MASK ? TIOCM_CD : 0) | 2076 (buf[0] & FTDI_SIO_RLSD_MASK ? TIOCM_CD : 0) |
2075 priv->last_dtr_rts; 2077 priv->last_dtr_rts;
2076} 2078}
2077 2079
2078static int ftdi_tiocmset(struct usb_serial_port *port, struct file * file, unsigned int set, unsigned int clear) 2080static int ftdi_tiocmset(struct usb_serial_port *port, struct file * file, unsigned int set, unsigned int clear)
@@ -2138,11 +2140,11 @@ static int ftdi_ioctl (struct usb_serial_port *port, struct file * file, unsigne
2138 break; 2140 break;
2139 default: 2141 default:
2140 break; 2142 break;
2141 2143
2142 } 2144 }
2143 2145
2144 2146
2145 /* This is not necessarily an error - turns out the higher layers will do 2147 /* This is not necessarily an error - turns out the higher layers will do
2146 * some ioctls itself (see comment above) 2148 * some ioctls itself (see comment above)
2147 */ 2149 */
2148 dbg("%s arg not supported - it was 0x%04x - check /usr/include/asm/ioctls.h", __FUNCTION__, cmd); 2150 dbg("%s arg not supported - it was 0x%04x - check /usr/include/asm/ioctls.h", __FUNCTION__, cmd);
@@ -2199,7 +2201,7 @@ static int __init ftdi_init (void)
2199 if (retval) 2201 if (retval)
2200 goto failed_sio_register; 2202 goto failed_sio_register;
2201 retval = usb_register(&ftdi_driver); 2203 retval = usb_register(&ftdi_driver);
2202 if (retval) 2204 if (retval)
2203 goto failed_usb_register; 2205 goto failed_usb_register;
2204 2206
2205 info(DRIVER_VERSION ":" DRIVER_DESC); 2207 info(DRIVER_VERSION ":" DRIVER_DESC);