From: hyvatti@klaava.Helsinki.FI (Jaakko Hyvatti) Subject: 0.96c pl 2 bug prevents serial reconfiguration (solved) Date: 19 Jul 1992 06:40:02 GMT
For us having exotic serial hardware there is a bug in patch 2.
Opening a serial line that has invalid configuration, that is, there is
no hardware where it should be, results in an infinite loop in kernel.
Therefore we cannot reconfigure them with programs like setserial.c
(one of them posted by Rick Sladkey (jrs@world.std.com)).
Here is my quick patch to assure we won't loop more than 16 times
in flushing characters from serial chip FIFO that might not be there.
--
Jaakko Hyv{tti Jaakko.Hyvatti@Helsinki.FI
Karstulantie 8 B 30 hyvatti@plootu.Helsinki.FI
00550 Helsinki, Finland +358-0-701 7810, -692 7466 (work)
*** linux/kernel/chr_drv/serial.c.OLD Sun Jul 19 08:45:41 1992
--- linux/kernel/chr_drv/serial.c Sun Jul 19 08:45:44 1992
***************
*** 313,318 ****
--- 313,320 ----
static void startup(unsigned short port)
{
+ int count = 0;
+
outb_p(0x03,port+3); /* reset DLAB */
outb_p(0x0f,port+4); /* set DTR,RTS, OUT_2 */
outb_p(0x0f,port+1); /* enable all intrs */
***************
*** 322,328 ****
inb_p(port+5);
do { /* drain all of the stuck characters out of the port */
inb_p(port+0);
! } while (inb_p(port+5) & 1 == 1);
inb_p(port+2);
inb_p(port+5);
}
--- 324,330 ----
inb_p(port+5);
do { /* drain all of the stuck characters out of the port */
inb_p(port+0);
! } while (++count < 16 && inb_p(port+5) & 1 == 1);
inb_p(port+2);
inb_p(port+5);
}