diff options
author | Alan Cox <alan@lxorguk.ukuu.org.uk> | 2007-12-13 19:15:29 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2008-02-01 17:34:56 -0500 |
commit | d0fab0ddf3fca22f73b95d2e15b598fa17876c69 (patch) | |
tree | 3ed6724b67161a46407172963cf87c5490e902cf | |
parent | e7806e366bcab561a6ecc1a6c4a5337f1714ece1 (diff) |
USB: mct232: speed, new termios and compliance cleanups
Signed-off-by: Alan Cox <alan@redhat.com>
Cc: Pete Zaitcev <zaitcev@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/mct_u232.c | 26 | ||||
-rw-r--r-- | drivers/usb/serial/mct_u232.h | 2 |
2 files changed, 18 insertions, 10 deletions
diff --git a/drivers/usb/serial/mct_u232.c b/drivers/usb/serial/mct_u232.c index 0dc99f75bb09..88b2074867c5 100644 --- a/drivers/usb/serial/mct_u232.c +++ b/drivers/usb/serial/mct_u232.c | |||
@@ -182,10 +182,11 @@ struct mct_u232_private { | |||
182 | /* | 182 | /* |
183 | * Later day 2.6.0-test kernels have new baud rates like B230400 which | 183 | * Later day 2.6.0-test kernels have new baud rates like B230400 which |
184 | * we do not know how to support. We ignore them for the moment. | 184 | * we do not know how to support. We ignore them for the moment. |
185 | * XXX Rate-limit the error message, it's user triggerable. | ||
186 | */ | 185 | */ |
187 | static int mct_u232_calculate_baud_rate(struct usb_serial *serial, speed_t value) | 186 | static int mct_u232_calculate_baud_rate(struct usb_serial *serial, speed_t value, speed_t *result) |
188 | { | 187 | { |
188 | *result = value; | ||
189 | |||
189 | if (le16_to_cpu(serial->dev->descriptor.idProduct) == MCT_U232_SITECOM_PID | 190 | if (le16_to_cpu(serial->dev->descriptor.idProduct) == MCT_U232_SITECOM_PID |
190 | || le16_to_cpu(serial->dev->descriptor.idProduct) == MCT_U232_BELKIN_F5U109_PID) { | 191 | || le16_to_cpu(serial->dev->descriptor.idProduct) == MCT_U232_BELKIN_F5U109_PID) { |
191 | switch (value) { | 192 | switch (value) { |
@@ -200,11 +201,13 @@ static int mct_u232_calculate_baud_rate(struct usb_serial *serial, speed_t value | |||
200 | case 57600: return 0x0b; | 201 | case 57600: return 0x0b; |
201 | case 115200: return 0x0c; | 202 | case 115200: return 0x0c; |
202 | default: | 203 | default: |
203 | err("MCT USB-RS232: unsupported baudrate request 0x%x," | 204 | *result = 9600; |
204 | " using default of B9600", value); | ||
205 | return 0x08; | 205 | return 0x08; |
206 | } | 206 | } |
207 | } else { | 207 | } else { |
208 | /* FIXME: Can we use any divider - should we do | ||
209 | divider = 115200/value; | ||
210 | real baud = 115200/divider */ | ||
208 | switch (value) { | 211 | switch (value) { |
209 | case 300: break; | 212 | case 300: break; |
210 | case 600: break; | 213 | case 600: break; |
@@ -217,9 +220,8 @@ static int mct_u232_calculate_baud_rate(struct usb_serial *serial, speed_t value | |||
217 | case 57600: break; | 220 | case 57600: break; |
218 | case 115200: break; | 221 | case 115200: break; |
219 | default: | 222 | default: |
220 | err("MCT USB-RS232: unsupported baudrate request 0x%x," | ||
221 | " using default of B9600", value); | ||
222 | value = 9600; | 223 | value = 9600; |
224 | *result = 9600; | ||
223 | } | 225 | } |
224 | return 115200/value; | 226 | return 115200/value; |
225 | } | 227 | } |
@@ -232,16 +234,19 @@ static int mct_u232_set_baud_rate(struct usb_serial *serial, struct usb_serial_p | |||
232 | int rc; | 234 | int rc; |
233 | unsigned char zero_byte = 0; | 235 | unsigned char zero_byte = 0; |
234 | unsigned char cts_enable_byte = 0; | 236 | unsigned char cts_enable_byte = 0; |
237 | speed_t speed; | ||
235 | 238 | ||
236 | divisor = cpu_to_le32(mct_u232_calculate_baud_rate(serial, value)); | 239 | divisor = cpu_to_le32(mct_u232_calculate_baud_rate(serial, value, &speed)); |
237 | 240 | ||
238 | rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), | 241 | rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), |
239 | MCT_U232_SET_BAUD_RATE_REQUEST, | 242 | MCT_U232_SET_BAUD_RATE_REQUEST, |
240 | MCT_U232_SET_REQUEST_TYPE, | 243 | MCT_U232_SET_REQUEST_TYPE, |
241 | 0, 0, &divisor, MCT_U232_SET_BAUD_RATE_SIZE, | 244 | 0, 0, &divisor, MCT_U232_SET_BAUD_RATE_SIZE, |
242 | WDR_TIMEOUT); | 245 | WDR_TIMEOUT); |
243 | if (rc < 0) | 246 | if (rc < 0) /*FIXME: What value speed results */ |
244 | err("Set BAUD RATE %d failed (error = %d)", value, rc); | 247 | err("Set BAUD RATE %d failed (error = %d)", value, rc); |
248 | else | ||
249 | tty_encode_baud_rate(port->tty, speed, speed); | ||
245 | dbg("set_baud_rate: value: 0x%x, divisor: 0x%x", value, divisor); | 250 | dbg("set_baud_rate: value: 0x%x, divisor: 0x%x", value, divisor); |
246 | 251 | ||
247 | /* Mimic the MCT-supplied Windows driver (version 1.21P.0104), which | 252 | /* Mimic the MCT-supplied Windows driver (version 1.21P.0104), which |
@@ -608,7 +613,8 @@ static void mct_u232_set_termios (struct usb_serial_port *port, | |||
608 | { | 613 | { |
609 | struct usb_serial *serial = port->serial; | 614 | struct usb_serial *serial = port->serial; |
610 | struct mct_u232_private *priv = usb_get_serial_port_data(port); | 615 | struct mct_u232_private *priv = usb_get_serial_port_data(port); |
611 | unsigned int cflag = port->tty->termios->c_cflag; | 616 | struct ktermios *termios = port->tty->termios; |
617 | unsigned int cflag = termios->c_cflag; | ||
612 | unsigned int old_cflag = old_termios->c_cflag; | 618 | unsigned int old_cflag = old_termios->c_cflag; |
613 | unsigned long flags; | 619 | unsigned long flags; |
614 | unsigned int control_state; | 620 | unsigned int control_state; |
@@ -670,6 +676,8 @@ static void mct_u232_set_termios (struct usb_serial_port *port, | |||
670 | break; | 676 | break; |
671 | } | 677 | } |
672 | 678 | ||
679 | termios->c_cflag &= ~CMSPAR; | ||
680 | |||
673 | /* set the number of stop bits */ | 681 | /* set the number of stop bits */ |
674 | last_lcr |= (cflag & CSTOPB) ? | 682 | last_lcr |= (cflag & CSTOPB) ? |
675 | MCT_U232_STOP_BITS_2 : MCT_U232_STOP_BITS_1; | 683 | MCT_U232_STOP_BITS_2 : MCT_U232_STOP_BITS_1; |
diff --git a/drivers/usb/serial/mct_u232.h b/drivers/usb/serial/mct_u232.h index aae10c8174d6..07b6bec31dc8 100644 --- a/drivers/usb/serial/mct_u232.h +++ b/drivers/usb/serial/mct_u232.h | |||
@@ -79,7 +79,7 @@ | |||
79 | * and "Intel solution". They are the regular MCT and "Sitecom" for us. | 79 | * and "Intel solution". They are the regular MCT and "Sitecom" for us. |
80 | * This is pointless to document in the header, see the code for the bits. | 80 | * This is pointless to document in the header, see the code for the bits. |
81 | */ | 81 | */ |
82 | static int mct_u232_calculate_baud_rate(struct usb_serial *serial, speed_t value); | 82 | static int mct_u232_calculate_baud_rate(struct usb_serial *serial, speed_t value, speed_t *result); |
83 | 83 | ||
84 | /* | 84 | /* |
85 | * Line Control Register (LCR) | 85 | * Line Control Register (LCR) |