diff options
author | Alan Cox <alan@lxorguk.ukuu.org.uk> | 2007-12-13 19:15:26 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2008-02-01 17:34:56 -0500 |
commit | 3ec466b49636c89866f7681813443c3abcefcbc2 (patch) | |
tree | f7404dde2d8117d7cb7d62e351568e4ed8f89910 /drivers/usb/serial | |
parent | fcf9e55e066d12c18add7c8a292bf879b45b1d55 (diff) |
USB: belkin_sa: clean up for new style termios and speed handling, plus style
A tester with actual hardware would be useful
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/usb/serial')
-rw-r--r-- | drivers/usb/serial/belkin_sa.c | 37 |
1 files changed, 16 insertions, 21 deletions
diff --git a/drivers/usb/serial/belkin_sa.c b/drivers/usb/serial/belkin_sa.c index 86724e88570..df0a2b3b029 100644 --- a/drivers/usb/serial/belkin_sa.c +++ b/drivers/usb/serial/belkin_sa.c | |||
@@ -350,14 +350,12 @@ static void belkin_sa_set_termios (struct usb_serial_port *port, struct ktermios | |||
350 | unsigned long control_state; | 350 | unsigned long control_state; |
351 | int bad_flow_control; | 351 | int bad_flow_control; |
352 | speed_t baud; | 352 | speed_t baud; |
353 | struct ktermios *termios = port->tty->termios; | ||
353 | 354 | ||
354 | if ((!port->tty) || (!port->tty->termios)) { | 355 | iflag = termios->c_iflag; |
355 | dbg ("%s - no tty or termios structure", __FUNCTION__); | 356 | cflag = termios->c_cflag; |
356 | return; | ||
357 | } | ||
358 | 357 | ||
359 | iflag = port->tty->termios->c_iflag; | 358 | termios->c_cflag &= ~CMSPAR; |
360 | cflag = port->tty->termios->c_cflag; | ||
361 | 359 | ||
362 | /* get a local copy of the current port settings */ | 360 | /* get a local copy of the current port settings */ |
363 | spin_lock_irqsave(&priv->lock, flags); | 361 | spin_lock_irqsave(&priv->lock, flags); |
@@ -369,33 +367,30 @@ static void belkin_sa_set_termios (struct usb_serial_port *port, struct ktermios | |||
369 | old_cflag = old_termios->c_cflag; | 367 | old_cflag = old_termios->c_cflag; |
370 | 368 | ||
371 | /* Set the baud rate */ | 369 | /* Set the baud rate */ |
372 | if( (cflag&CBAUD) != (old_cflag&CBAUD) ) { | 370 | if ((cflag & CBAUD) != (old_cflag & CBAUD)) { |
373 | /* reassert DTR and (maybe) RTS on transition from B0 */ | 371 | /* reassert DTR and (maybe) RTS on transition from B0 */ |
374 | if( (old_cflag&CBAUD) == B0 ) { | 372 | if( (old_cflag&CBAUD) == B0 ) { |
375 | control_state |= (TIOCM_DTR|TIOCM_RTS); | 373 | control_state |= (TIOCM_DTR|TIOCM_RTS); |
376 | if (BSA_USB_CMD(BELKIN_SA_SET_DTR_REQUEST, 1) < 0) | 374 | if (BSA_USB_CMD(BELKIN_SA_SET_DTR_REQUEST, 1) < 0) |
377 | err("Set DTR error"); | 375 | err("Set DTR error"); |
378 | /* don't set RTS if using hardware flow control */ | 376 | /* don't set RTS if using hardware flow control */ |
379 | if (!(old_cflag&CRTSCTS) ) | 377 | if (!(old_cflag & CRTSCTS)) |
380 | if (BSA_USB_CMD(BELKIN_SA_SET_RTS_REQUEST, 1) < 0) | 378 | if (BSA_USB_CMD(BELKIN_SA_SET_RTS_REQUEST, 1) < 0) |
381 | err("Set RTS error"); | 379 | err("Set RTS error"); |
382 | } | 380 | } |
383 | } | 381 | } |
384 | 382 | ||
385 | baud = tty_get_baud_rate(port->tty); | 383 | baud = tty_get_baud_rate(port->tty); |
386 | if (baud == 0) { | 384 | if (baud) { |
387 | dbg("%s - tty_get_baud_rate says 0 baud", __FUNCTION__); | 385 | urb_value = BELKIN_SA_BAUD(baud); |
388 | return; | 386 | /* Clip to maximum speed */ |
389 | } | 387 | if (urb_value == 0) |
390 | urb_value = BELKIN_SA_BAUD(baud); | 388 | urb_value = 1; |
391 | /* Clip to maximum speed */ | 389 | /* Turn it back into a resulting real baud rate */ |
392 | if (urb_value == 0) | 390 | baud = BELKIN_SA_BAUD(urb_value); |
393 | urb_value = 1; | 391 | |
394 | /* Turn it back into a resulting real baud rate */ | 392 | /* Report the actual baud rate back to the caller */ |
395 | baud = BELKIN_SA_BAUD(urb_value); | 393 | tty_encode_baud_rate(port->tty, baud, baud); |
396 | /* FIXME: Once the tty updates are done then push this back to the tty */ | ||
397 | |||
398 | if ((cflag & CBAUD) != B0 ) { | ||
399 | if (BSA_USB_CMD(BELKIN_SA_SET_BAUDRATE_REQUEST, urb_value) < 0) | 394 | if (BSA_USB_CMD(BELKIN_SA_SET_BAUDRATE_REQUEST, urb_value) < 0) |
400 | err("Set baudrate error"); | 395 | err("Set baudrate error"); |
401 | } else { | 396 | } else { |