Skip to contentSkip to conversation

serial: speed setup failure reporting

PATCH In review Alan Cox 2 participants 3 messages Jan 3, 2008 – Jan 10, 2008

lore
Share & tools
lore

Alan Cox

author
#0 lore raw

PATCH 1/1 serial: speed setup failure reporting

Invalid speeds are forced to 9600. Update the code for this to encode new style baud rates properly.

drivers/serial/serial_core.c +3 -2
diff -u --new-file --recursive --exclude-from /usr/src/exclude linux.vanilla-2.6.24-rc6-mm1/drivers/serial/serial_core.c linux-2.6.24-rc6-mm1/drivers/serial/serial_core.c
@@ -372,7 +372,8 @@
 		 */
 		termios->c_cflag &= ~CBAUD;
 		if (old) {
-			termios->c_cflag |= old->c_cflag & CBAUD;
+			baud = tty_termios_baud_rate(old);
+			tty_termios_encode_baud_rate(termios, baud, baud);
 			old = NULL;
 			continue;
 		}
@@ -381,7 +382,7 @@
 		 * As a last resort, if the quotient is zero,
 		 * default to 9600 bps
 		 */
-		termios->c_cflag |= B9600;
+		tty_termios_encode_baud_rate(termios, 9600, 9600);
 	}
 
 	return 0;
#1 lore raw
Quoted 19 lines · On Thu, 3 Jan 2008 16:55:07 +0000 Alan Cox <[email protected]> wrote:

Invalid speeds are forced to 9600. Update the code for this to encode new style baud rates properly.

diff -u --new-file --recursive --exclude-from /usr/src/exclude linux.vanilla-2.6.24-rc6-mm1/drivers/serial/serial_core.c linux-2.6.24-rc6-mm1/drivers/serial/serial_core.c

drivers/serial/serial_core.c +2 -1
@@ -372,7 +372,8 @@
 		 */
 		termios->c_cflag &= ~CBAUD;
 		if (old) {
-			termios->c_cflag |= old->c_cflag & CBAUD;
+			baud = tty_termios_baud_rate(old);
+			tty_termios_encode_baud_rate(termios, baud, baud);
 			old = NULL;
 			continue;
 		}

drivers/serial/serial_core.c line 388

Quoted 8 lines
drivers/serial/serial_core.c +1 -1
@@ -381,7 +382,7 @@
 		 * As a last resort, if the quotient is zero,
 		 * default to 9600 bps
 		 */
-		termios->c_cflag |= B9600;
+		tty_termios_encode_baud_rate(termios, 9600, 9600);
 	}
 
 	return 0;

Is this a 2.6.24 thing?

author
#2 lore raw

It only causes a problem if you set a completely bogus baud rate (out of range) and that baud rate was not a standard one and you were using the new tty ioctls - so its fairly low priority 8)