Re: [patch 1/8] belkin_sa: clean up for new style termios and speed handling, plus style

Gene Heskett <[email protected]>
Newsgroups gmane.linux.usb.devel
Organization Organization? Not detectable
Message-ID <[email protected]>
On Thursday 13 December 2007, [email protected] wrote:
>From: Alan Cox <[email protected]>
>
>A tester with actual hardware would be useful
>
What hardware, Alan?  I have one of their ups's, and my pci usb card is a 
belkin.  But an lsmod does not show belkin_sa as being loaded.  Running 
2.6.24-rc5 ATM.

>Signed-off-by: Alan Cox <[email protected]>
>Cc: Greg KH <[email protected]>
>Signed-off-by: Andrew Morton <[email protected]>
>---
>
> drivers/usb/serial/belkin_sa.c |   35 +++++++++++++------------------
> 1 file changed, 15 insertions(+), 20 deletions(-)
>
>diff -puN
> drivers/usb/serial/belkin_sa.c~belkin_sa-clean-up-for-new-style-termios-and
>-speed drivers/usb/serial/belkin_sa.c ---
> a/drivers/usb/serial/belkin_sa.c~belkin_sa-clean-up-for-new-style-termios-a
>nd-speed +++ a/drivers/usb/serial/belkin_sa.c
>@@ -350,14 +350,12 @@ static void belkin_sa_set_termios (struc
> 	unsigned long control_state;
> 	int bad_flow_control;
> 	speed_t baud;
>+	struct ktermios *termios = port->tty->termios;
>
>-	if ((!port->tty) || (!port->tty->termios)) {
>-		dbg ("%s - no tty or termios structure", __FUNCTION__);
>-		return;
>-	}
>+	iflag = termios->c_iflag;
>+	cflag = termios->c_cflag;
>
>-	iflag = port->tty->termios->c_iflag;
>-	cflag = port->tty->termios->c_cflag;
>+	termios->c_cflag &= ~CMSPAR;
>
> 	/* get a local copy of the current port settings */
> 	spin_lock_irqsave(&priv->lock, flags);
>@@ -369,33 +367,30 @@ static void belkin_sa_set_termios (struc
> 	old_cflag = old_termios->c_cflag;
>
> 	/* Set the baud rate */
>-	if( (cflag&CBAUD) != (old_cflag&CBAUD) ) {
>+	if ((cflag & CBAUD) != (old_cflag & CBAUD)) {
> 		/* reassert DTR and (maybe) RTS on transition from B0 */
> 		if( (old_cflag&CBAUD) == B0 ) {
> 			control_state |= (TIOCM_DTR|TIOCM_RTS);
> 			if (BSA_USB_CMD(BELKIN_SA_SET_DTR_REQUEST, 1) < 0)
> 				err("Set DTR error");
> 			/* don't set RTS if using hardware flow control */
>-			if (!(old_cflag&CRTSCTS) )
>+			if (!(old_cflag & CRTSCTS))
> 				if (BSA_USB_CMD(BELKIN_SA_SET_RTS_REQUEST, 1) < 0)
> 					err("Set RTS error");
> 		}
> 	}
>
> 	baud = tty_get_baud_rate(port->tty);
>-	if (baud == 0) {
>-		dbg("%s - tty_get_baud_rate says 0 baud", __FUNCTION__);
>-		return;
>-	}
>-	urb_value = BELKIN_SA_BAUD(baud);
>-	/* Clip to maximum speed */
>-	if (urb_value == 0)
>-		urb_value = 1;
>-	/* Turn it back into a resulting real baud rate */
>-	baud = BELKIN_SA_BAUD(urb_value);
>-	/* FIXME: Once the tty updates are done then push this back to the tty */
>+	if (baud) {
>+		urb_value = BELKIN_SA_BAUD(baud);
>+		/* Clip to maximum speed */
>+		if (urb_value == 0)
>+			urb_value = 1;
>+		/* Turn it back into a resulting real baud rate */
>+		baud = BELKIN_SA_BAUD(urb_value);
>
>-	if ((cflag & CBAUD) != B0 ) {
>+		/* Report the actual baud rate back to the caller */
>+		tty_encode_baud_rate(port->tty, baud, baud);
> 		if (BSA_USB_CMD(BELKIN_SA_SET_BAUDRATE_REQUEST, urb_value) < 0)
> 			err("Set baudrate error");
> 	} else {
>_
>
>-------------------------------------------------------------------------
>SF.Net email is sponsored by:
>Check out the new SourceForge.net Marketplace.
>It's the best place to buy or sell services
>for just about anything Open Source.
>http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
>_______________________________________________
>[email protected]
>To unsubscribe, use the last form field at:
>https://lists.sourceforge.net/lists/listinfo/linux-usb-devel



-- 
Cheers, Gene
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
Electricians made popcorn in the power supply

-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.