[PATCH] cp2101: Remove broken termios optimisation, use proper speed API

Alan Cox <[email protected]>
Newsgroups gmane.linux.usb.devel
Organization Red Hat UK Cyf., Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SL4 1TE, Y Deyrnas Gyfunol. Cofrestrwyd yng Nghymru a Lloegr o'r rhif cofrestru 3798903
Message-ID <[email protected]>
I've also enabled the commented out support for 7200, 14400, 55854,
127117 and 3686400 baud as you can now set such rates in the kernel.

Signed-off-by: Alan Cox <[email protected]>

diff -u --new-file --recursive --exclude-from /usr/src/exclude linux.vanilla-2.6.23rc1-mm1/drivers/usb/serial/cp2101.c linux-2.6.23rc1-mm1/drivers/usb/serial/cp2101.c
--- linux.vanilla-2.6.23rc1-mm1/drivers/usb/serial/cp2101.c	2007-07-26 15:01:51.000000000 +0100
+++ linux-2.6.23rc1-mm1/drivers/usb/serial/cp2101.c	2007-07-26 15:30:20.000000000 +0100
@@ -356,7 +356,7 @@
 
 	dbg("%s - port %d", __FUNCTION__, port->number);
 
-	if ((!port->tty) || (!port->tty->termios)) {
+	if (!port->tty || !port->tty->termios) {
 		dbg("%s - no tty structures", __FUNCTION__);
 		return;
 	}
@@ -526,50 +526,35 @@
 		return;
 	}
 	cflag = port->tty->termios->c_cflag;
-
-	/* Check that they really want us to change something */
-	if (old_termios) {
-		if ((cflag == old_termios->c_cflag) &&
-				(RELEVANT_IFLAG(port->tty->termios->c_iflag)
-				== RELEVANT_IFLAG(old_termios->c_iflag))) {
-			dbg("%s - nothing to change...", __FUNCTION__);
-			return;
-		}
-
-		old_cflag = old_termios->c_cflag;
-	}
-
+	old_cflag = old_termios->c_cflag;
+	baud = tty_get_baud_rate(port->tty);
+	
 	/* If the baud rate is to be updated*/
-	if ((cflag & CBAUD) != (old_cflag & CBAUD)) {
-		switch (cflag & CBAUD) {
-			/*
-			 * The baud rates which are commented out below
-			 * appear to be supported by the device
-			 * but are non-standard
-			 */
-			case B0:	baud = 0;	break;
-			case B600:	baud = 600;	break;
-			case B1200:	baud = 1200;	break;
-			case B1800:	baud = 1800;	break;
-			case B2400:	baud = 2400;	break;
-			case B4800:	baud = 4800;	break;
-			/*case B7200:	baud = 7200;	break;*/
-			case B9600:	baud = 9600;	break;
-			/*ase B14400:	baud = 14400;	break;*/
-			case B19200:	baud = 19200;	break;
-			/*case B28800:	baud = 28800;	break;*/
-			case B38400:	baud = 38400;	break;
-			/*case B55854:	baud = 55054;	break;*/
-			case B57600:	baud = 57600;	break;
-			case B115200:	baud = 115200;	break;
-			/*case B127117:	baud = 127117;	break;*/
-			case B230400:	baud = 230400;	break;
-			case B460800:	baud = 460800;	break;
-			case B921600:	baud = 921600;	break;
-			/*case B3686400:	baud = 3686400;	break;*/
+	if (baud != tty_termios_baud_rate(old_termios)) {
+		switch (baud) {
+			case 0:
+			case 600:
+			case 1200:
+			case 1800:
+			case 2400:
+			case 4800:
+			case 7200:
+			case 9600:
+			case 14400:
+			case 19200:
+			case 28800:
+			case 38400:
+			case 55854:
+			case 57600:
+			case 115200:
+			case 127117:
+			case 230400:
+			case 460800:
+			case 921600:
+			case 3686400:
+				break;
 			default:
-				dev_err(&port->dev, "cp2101 driver does not "
-					"support the baudrate requested\n");
+				baud = 9600;
 				break;
 		}
 

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
[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.