Re: 2.1.66 serial driver broken -- baud rates..

Theodore Y. Ts'o (tytso@MIT.EDU)
Sat, 29 Nov 1997 10:59:37 -0500


From: Michael Nelson <nelson@seahunt.imat.com>
Date: Thu, 27 Nov 1997 18:16:07 -0800 (PST)

Use "spd_normal", and feed the real desired baud rate from your
application. For instance, I used to use spd_vhi with ppp, and
had 38400 in my ppp options. That resulted in 115200 comm port
speed. With spd_normal, I put 115200 in my ppp options file,
and I am back to getting consistent 33.6 connections on my ppp
link.

My understanding is that the spd_hi and spd_vhi were a kludge for
the old kernels and serial drivers that didn't understand speeds
higher than 38400.

This is true. spd_hi and spd_vhi haven't been needed since the 1.2
kernels, actually, although some distributions where shipping libc's
which didn't support the higher baudrates with 1.2. Just about anyone
using 2.0 doesn't need to use spd_hi or spd_vhi.

In any case, while I do want to phase out support for spd_hi and
spd_vhi, breaking support in 2.1 isn't the best way to do this (sorry
about the oversight; I forgot to add some code to rs_open to set
tty->alt_speed). The right way to phase out support, of course, is to
add annoying messages to your syslog if you try to use spd_hi and
spd_vhi.

This patch should fix spd_hi and spd_vhi, while sysloging a warning
message if you use it.

- Ted

Patch generated: on Sat Nov 29 10:56:03 EST 1997 by tytso@rsts-11
against Linux version 2.1.66

===================================================================
RCS file: drivers/char/RCS/serial.c,v
retrieving revision 1.1
diff -u -r1.1 drivers/char/serial.c
--- drivers/char/serial.c 1997/11/28 15:08:24 1.1
+++ drivers/char/serial.c 1997/11/29 02:51:22
@@ -1210,6 +1210,20 @@
timer_active |= 1 << RS_TIMER;

/*
+ * Set up the tty->alt_speed kludge
+ */
+ if (info->tty) {
+ if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
+ info->tty->alt_speed = 57600;
+ if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
+ info->tty->alt_speed = 115200;
+ if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
+ info->tty->alt_speed = 230400;
+ if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
+ info->tty->alt_speed = 460800;
+ }
+
+ /*
* and set the speed of the serial port
*/
change_speed(info);
@@ -1376,7 +1390,8 @@
/* Determine divisor based on baud rate */
baud = tty_get_baud_rate(info->tty);
baud_base = info->state->baud_base;
- if (baud == 38400)
+ if (baud == 38400 &&
+ ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST))
quot = info->state->custom_divisor;
else {
if (baud == 134)
===================================================================
RCS file: drivers/char/RCS/tty_io.c,v
retrieving revision 1.1
diff -u -r1.1 drivers/char/tty_io.c
--- drivers/char/tty_io.c 1997/11/29 02:52:02 1.1
+++ drivers/char/tty_io.c 1997/11/29 03:03:36
@@ -1760,8 +1760,13 @@
else
i += 15;
}
- if (i==15 && tty->alt_speed)
+ if (i==15 && tty->alt_speed) {
+ if (!tty->warned) {
+ printk("Use of setserial/setrocket or TIOCSSERIAL ioctl is deprecated\n");
+ tty->warned = 1;
+ }
return(tty->alt_speed);
+ }

return baud_table[i];
}
===================================================================
RCS file: include/linux/RCS/tty.h,v
retrieving revision 1.1
diff -u -r1.1 include/linux/tty.h
--- include/linux/tty.h 1997/11/29 02:54:06 1.1
+++ include/linux/tty.h 1997/11/29 02:58:04
@@ -224,7 +224,7 @@
int count;
struct winsize winsize;
unsigned char stopped:1, hw_stopped:1, flow_stopped:1, packet:1;
- unsigned char low_latency:1;
+ unsigned char low_latency:1, warned:1;
unsigned char ctrl_status;

struct tty_struct *link;