diff options
author | Alan Cox <alan@lxorguk.ukuu.org.uk> | 2007-12-13 19:15:28 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2008-02-01 17:34:56 -0500 |
commit | e7806e366bcab561a6ecc1a6c4a5337f1714ece1 (patch) | |
tree | 41e6dfb6244c6b09b47ce51ae29513932b79254e /drivers | |
parent | 3ec466b49636c89866f7681813443c3abcefcbc2 (diff) |
USB: keyspan_pda: clean up speed handling
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>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/usb/serial/keyspan_pda.c | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c index be9ac20a8f10..b1fa5a376e96 100644 --- a/drivers/usb/serial/keyspan_pda.c +++ b/drivers/usb/serial/keyspan_pda.c | |||
@@ -303,7 +303,7 @@ static void keyspan_pda_rx_unthrottle (struct usb_serial_port *port) | |||
303 | } | 303 | } |
304 | 304 | ||
305 | 305 | ||
306 | static int keyspan_pda_setbaud (struct usb_serial *serial, int baud) | 306 | static speed_t keyspan_pda_setbaud (struct usb_serial *serial, speed_t baud) |
307 | { | 307 | { |
308 | int rc; | 308 | int rc; |
309 | int bindex; | 309 | int bindex; |
@@ -319,7 +319,9 @@ static int keyspan_pda_setbaud (struct usb_serial *serial, int baud) | |||
319 | case 38400: bindex = 7; break; | 319 | case 38400: bindex = 7; break; |
320 | case 57600: bindex = 8; break; | 320 | case 57600: bindex = 8; break; |
321 | case 115200: bindex = 9; break; | 321 | case 115200: bindex = 9; break; |
322 | default: return -EINVAL; | 322 | default: |
323 | bindex = 5; /* Default to 9600 */ | ||
324 | baud = 9600; | ||
323 | } | 325 | } |
324 | 326 | ||
325 | /* rather than figure out how to sleep while waiting for this | 327 | /* rather than figure out how to sleep while waiting for this |
@@ -334,7 +336,9 @@ static int keyspan_pda_setbaud (struct usb_serial *serial, int baud) | |||
334 | NULL, /* &data */ | 336 | NULL, /* &data */ |
335 | 0, /* size */ | 337 | 0, /* size */ |
336 | 2000); /* timeout */ | 338 | 2000); /* timeout */ |
337 | return(rc); | 339 | if (rc < 0) |
340 | return 0; | ||
341 | return baud; | ||
338 | } | 342 | } |
339 | 343 | ||
340 | 344 | ||
@@ -366,7 +370,7 @@ static void keyspan_pda_set_termios (struct usb_serial_port *port, | |||
366 | struct ktermios *old_termios) | 370 | struct ktermios *old_termios) |
367 | { | 371 | { |
368 | struct usb_serial *serial = port->serial; | 372 | struct usb_serial *serial = port->serial; |
369 | unsigned int cflag = port->tty->termios->c_cflag; | 373 | speed_t speed; |
370 | 374 | ||
371 | /* cflag specifies lots of stuff: number of stop bits, parity, number | 375 | /* cflag specifies lots of stuff: number of stop bits, parity, number |
372 | of data bits, baud. What can the device actually handle?: | 376 | of data bits, baud. What can the device actually handle?: |
@@ -388,22 +392,18 @@ static void keyspan_pda_set_termios (struct usb_serial_port *port, | |||
388 | 392 | ||
389 | For now, just do baud. */ | 393 | For now, just do baud. */ |
390 | 394 | ||
391 | switch (cflag & CBAUD) { | 395 | speed = tty_get_baud_rate(port->tty); |
392 | /* we could support more values here, just need to calculate | 396 | speed = keyspan_pda_setbaud(serial, speed); |
393 | the necessary divisors in the firmware. <asm/termbits.h> | 397 | |
394 | has the Bnnn constants. */ | 398 | if (speed == 0) { |
395 | case B110: keyspan_pda_setbaud(serial, 110); break; | 399 | dbg("can't handle requested baud rate"); |
396 | case B300: keyspan_pda_setbaud(serial, 300); break; | 400 | /* It hasn't changed so.. */ |
397 | case B1200: keyspan_pda_setbaud(serial, 1200); break; | 401 | speed = tty_termios_baud_rate(old_termios); |
398 | case B2400: keyspan_pda_setbaud(serial, 2400); break; | ||
399 | case B4800: keyspan_pda_setbaud(serial, 4800); break; | ||
400 | case B9600: keyspan_pda_setbaud(serial, 9600); break; | ||
401 | case B19200: keyspan_pda_setbaud(serial, 19200); break; | ||
402 | case B38400: keyspan_pda_setbaud(serial, 38400); break; | ||
403 | case B57600: keyspan_pda_setbaud(serial, 57600); break; | ||
404 | case B115200: keyspan_pda_setbaud(serial, 115200); break; | ||
405 | default: dbg("can't handle requested baud rate"); break; | ||
406 | } | 402 | } |
403 | /* Only speed can change so copy the old h/w parameters | ||
404 | then encode the new speed */ | ||
405 | tty_termios_copy_hw(port->tty->termios, old_termios); | ||
406 | tty_encode_baud_rate(port->tty, speed, speed); | ||
407 | } | 407 | } |
408 | 408 | ||
409 | 409 | ||