diff options
author | Alan Cox <alan@lxorguk.ukuu.org.uk> | 2007-10-18 04:24:24 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2007-10-25 15:18:42 -0400 |
commit | 669a6db1037efeb064dd6620f69384f99fb45584 (patch) | |
tree | 4eec77059d14193554a4312e9910601e7bde10c0 | |
parent | 9ab0f202e6a700d1362a1eb990ac3054f2cd15ea (diff) |
USB: ftd_sio: cleanups and updates for new termios work
- Remove can't happen tests
- Rework speed validation in terms of baud rates not CBAUD bits
- Report speed set (or chosen)
- Minor termios correctness
Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | drivers/usb/serial/ftdi_sio.c | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index 8a8a6b9fb05b..a63c0aac0d04 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c | |||
@@ -294,7 +294,7 @@ struct ftdi_private { | |||
294 | 294 | ||
295 | __u16 interface; /* FT2232C port interface (0 for FT232/245) */ | 295 | __u16 interface; /* FT2232C port interface (0 for FT232/245) */ |
296 | 296 | ||
297 | int force_baud; /* if non-zero, force the baud rate to this value */ | 297 | speed_t force_baud; /* if non-zero, force the baud rate to this value */ |
298 | int force_rtscts; /* if non-zero, force RTS-CTS to always be enabled */ | 298 | int force_rtscts; /* if non-zero, force RTS-CTS to always be enabled */ |
299 | 299 | ||
300 | spinlock_t tx_lock; /* spinlock for transmit state */ | 300 | spinlock_t tx_lock; /* spinlock for transmit state */ |
@@ -878,6 +878,7 @@ static __u32 get_ftdi_divisor(struct usb_serial_port * port) | |||
878 | if (div_value == 0) { | 878 | if (div_value == 0) { |
879 | dbg("%s - Baudrate (%d) requested is not supported", __FUNCTION__, baud); | 879 | dbg("%s - Baudrate (%d) requested is not supported", __FUNCTION__, baud); |
880 | div_value = ftdi_sio_b9600; | 880 | div_value = ftdi_sio_b9600; |
881 | baud = 9600; | ||
881 | div_okay = 0; | 882 | div_okay = 0; |
882 | } | 883 | } |
883 | break; | 884 | break; |
@@ -886,6 +887,7 @@ static __u32 get_ftdi_divisor(struct usb_serial_port * port) | |||
886 | div_value = ftdi_232am_baud_to_divisor(baud); | 887 | div_value = ftdi_232am_baud_to_divisor(baud); |
887 | } else { | 888 | } else { |
888 | dbg("%s - Baud rate too high!", __FUNCTION__); | 889 | dbg("%s - Baud rate too high!", __FUNCTION__); |
890 | baud = 9600; | ||
889 | div_value = ftdi_232am_baud_to_divisor(9600); | 891 | div_value = ftdi_232am_baud_to_divisor(9600); |
890 | div_okay = 0; | 892 | div_okay = 0; |
891 | } | 893 | } |
@@ -899,6 +901,7 @@ static __u32 get_ftdi_divisor(struct usb_serial_port * port) | |||
899 | dbg("%s - Baud rate too high!", __FUNCTION__); | 901 | dbg("%s - Baud rate too high!", __FUNCTION__); |
900 | div_value = ftdi_232bm_baud_to_divisor(9600); | 902 | div_value = ftdi_232bm_baud_to_divisor(9600); |
901 | div_okay = 0; | 903 | div_okay = 0; |
904 | baud = 9600; | ||
902 | } | 905 | } |
903 | break; | 906 | break; |
904 | } /* priv->chip_type */ | 907 | } /* priv->chip_type */ |
@@ -909,6 +912,7 @@ static __u32 get_ftdi_divisor(struct usb_serial_port * port) | |||
909 | ftdi_chip_name[priv->chip_type]); | 912 | ftdi_chip_name[priv->chip_type]); |
910 | } | 913 | } |
911 | 914 | ||
915 | tty_encode_baud_rate(port->tty, baud, baud); | ||
912 | return(div_value); | 916 | return(div_value); |
913 | } | 917 | } |
914 | 918 | ||
@@ -1263,7 +1267,7 @@ static void ftdi_USB_UIRT_setup (struct ftdi_private *priv) | |||
1263 | 1267 | ||
1264 | priv->flags |= ASYNC_SPD_CUST; | 1268 | priv->flags |= ASYNC_SPD_CUST; |
1265 | priv->custom_divisor = 77; | 1269 | priv->custom_divisor = 77; |
1266 | priv->force_baud = B38400; | 1270 | priv->force_baud = 38400; |
1267 | } /* ftdi_USB_UIRT_setup */ | 1271 | } /* ftdi_USB_UIRT_setup */ |
1268 | 1272 | ||
1269 | /* Setup for the HE-TIRA1 device, which requires hardwired | 1273 | /* Setup for the HE-TIRA1 device, which requires hardwired |
@@ -1274,7 +1278,7 @@ static void ftdi_HE_TIRA1_setup (struct ftdi_private *priv) | |||
1274 | 1278 | ||
1275 | priv->flags |= ASYNC_SPD_CUST; | 1279 | priv->flags |= ASYNC_SPD_CUST; |
1276 | priv->custom_divisor = 240; | 1280 | priv->custom_divisor = 240; |
1277 | priv->force_baud = B38400; | 1281 | priv->force_baud = 38400; |
1278 | priv->force_rtscts = 1; | 1282 | priv->force_rtscts = 1; |
1279 | } /* ftdi_HE_TIRA1_setup */ | 1283 | } /* ftdi_HE_TIRA1_setup */ |
1280 | 1284 | ||
@@ -1363,7 +1367,7 @@ static int ftdi_open (struct usb_serial_port *port, struct file *filp) | |||
1363 | 1367 | ||
1364 | /* ftdi_set_termios will send usb control messages */ | 1368 | /* ftdi_set_termios will send usb control messages */ |
1365 | if (port->tty) | 1369 | if (port->tty) |
1366 | ftdi_set_termios(port, NULL); | 1370 | ftdi_set_termios(port, port->tty->termios); |
1367 | 1371 | ||
1368 | /* FIXME: Flow control might be enabled, so it should be checked - | 1372 | /* FIXME: Flow control might be enabled, so it should be checked - |
1369 | we have no control of defaults! */ | 1373 | we have no control of defaults! */ |
@@ -1933,32 +1937,32 @@ static void ftdi_break_ctl( struct usb_serial_port *port, int break_state ) | |||
1933 | static void ftdi_set_termios (struct usb_serial_port *port, struct ktermios *old_termios) | 1937 | static void ftdi_set_termios (struct usb_serial_port *port, struct ktermios *old_termios) |
1934 | { /* ftdi_termios */ | 1938 | { /* ftdi_termios */ |
1935 | struct usb_device *dev = port->serial->dev; | 1939 | struct usb_device *dev = port->serial->dev; |
1936 | unsigned int cflag = port->tty->termios->c_cflag; | ||
1937 | struct ftdi_private *priv = usb_get_serial_port_data(port); | 1940 | struct ftdi_private *priv = usb_get_serial_port_data(port); |
1941 | struct ktermios *termios = port->tty->termios; | ||
1942 | unsigned int cflag = termios->c_cflag; | ||
1938 | __u16 urb_value; /* will hold the new flags */ | 1943 | __u16 urb_value; /* will hold the new flags */ |
1939 | char buf[1]; /* Perhaps I should dynamically alloc this? */ | 1944 | char buf[1]; /* Perhaps I should dynamically alloc this? */ |
1940 | 1945 | ||
1941 | // Added for xon/xoff support | 1946 | // Added for xon/xoff support |
1942 | unsigned int iflag = port->tty->termios->c_iflag; | 1947 | unsigned int iflag = termios->c_iflag; |
1943 | unsigned char vstop; | 1948 | unsigned char vstop; |
1944 | unsigned char vstart; | 1949 | unsigned char vstart; |
1945 | 1950 | ||
1946 | dbg("%s", __FUNCTION__); | 1951 | dbg("%s", __FUNCTION__); |
1947 | 1952 | ||
1948 | /* Force baud rate if this device requires it, unless it is set to B0. */ | 1953 | /* Force baud rate if this device requires it, unless it is set to B0. */ |
1949 | if (priv->force_baud && ((port->tty->termios->c_cflag & CBAUD) != B0)) { | 1954 | if (priv->force_baud && ((termios->c_cflag & CBAUD) != B0)) { |
1950 | dbg("%s: forcing baud rate for this device", __FUNCTION__); | 1955 | dbg("%s: forcing baud rate for this device", __FUNCTION__); |
1951 | port->tty->termios->c_cflag &= ~CBAUD; | 1956 | tty_encode_baud_rate(port->tty, priv->force_baud, priv->force_baud); |
1952 | port->tty->termios->c_cflag |= priv->force_baud; | ||
1953 | } | 1957 | } |
1954 | 1958 | ||
1955 | /* Force RTS-CTS if this device requires it. */ | 1959 | /* Force RTS-CTS if this device requires it. */ |
1956 | if (priv->force_rtscts) { | 1960 | if (priv->force_rtscts) { |
1957 | dbg("%s: forcing rtscts for this device", __FUNCTION__); | 1961 | dbg("%s: forcing rtscts for this device", __FUNCTION__); |
1958 | port->tty->termios->c_cflag |= CRTSCTS; | 1962 | termios->c_cflag |= CRTSCTS; |
1959 | } | 1963 | } |
1960 | 1964 | ||
1961 | cflag = port->tty->termios->c_cflag; | 1965 | cflag = termios->c_cflag; |
1962 | 1966 | ||
1963 | /* FIXME -For this cut I don't care if the line is really changing or | 1967 | /* FIXME -For this cut I don't care if the line is really changing or |
1964 | not - so just do the change regardless - should be able to | 1968 | not - so just do the change regardless - should be able to |
@@ -1969,6 +1973,8 @@ static void ftdi_set_termios (struct usb_serial_port *port, struct ktermios *old | |||
1969 | 1973 | ||
1970 | /* Set number of data bits, parity, stop bits */ | 1974 | /* Set number of data bits, parity, stop bits */ |
1971 | 1975 | ||
1976 | termios->c_cflag &= ~CMSPAR; | ||
1977 | |||
1972 | urb_value = 0; | 1978 | urb_value = 0; |
1973 | urb_value |= (cflag & CSTOPB ? FTDI_SIO_SET_DATA_STOP_BITS_2 : | 1979 | urb_value |= (cflag & CSTOPB ? FTDI_SIO_SET_DATA_STOP_BITS_2 : |
1974 | FTDI_SIO_SET_DATA_STOP_BITS_1); | 1980 | FTDI_SIO_SET_DATA_STOP_BITS_1); |
@@ -2048,8 +2054,8 @@ static void ftdi_set_termios (struct usb_serial_port *port, struct ktermios *old | |||
2048 | // Set the vstart and vstop -- could have been done up above where | 2054 | // Set the vstart and vstop -- could have been done up above where |
2049 | // a lot of other dereferencing is done but that would be very | 2055 | // a lot of other dereferencing is done but that would be very |
2050 | // inefficient as vstart and vstop are not always needed | 2056 | // inefficient as vstart and vstop are not always needed |
2051 | vstart=port->tty->termios->c_cc[VSTART]; | 2057 | vstart = termios->c_cc[VSTART]; |
2052 | vstop=port->tty->termios->c_cc[VSTOP]; | 2058 | vstop = termios->c_cc[VSTOP]; |
2053 | urb_value=(vstop << 8) | (vstart); | 2059 | urb_value=(vstop << 8) | (vstart); |
2054 | 2060 | ||
2055 | if (usb_control_msg(dev, | 2061 | if (usb_control_msg(dev, |