Changing the speed of the serial driver

Dag Brattli (dagb@cs.uit.no)
02 Jan 1998 16:48:09 +0100


Hi, just wanted some comments on how to change the speed of the serial
driver from within the Linux kernel.

To change the speed I have used the tty->driver.set_termios() function
which works quite well.

The problem is that the speed change seems to be immediate, which is a
problem to me. After negotiating the speed in the IrDA driver (
http://www.cs.uit.no/~dagb/irda/irda.html) I must change the speed after
sending an ack frame. Since the driver has no threads it is impossible for
me to just wait for the frame to be sent, so the last frame sent will be
sent partially in different speeds :-).

To avoid this I tried to change the speed after the write_wakeup() call,
but that only tells me that the serial driver can accept more data, not
that all the data has been sent. I now use a todo-timer and the
tty->driver.chars_in_buffer() to check if all data has been sent. This
works quit well, but I still get problems if I set the timer to short,
since I may get a situation where the serial driver has sent all its data,
but the fifo still contains data. I want to set the timer as short as
possible so the speed has changed before the next frame is received which
may be a problem, since the timing is critical.

Have I missed something? Is there a more "right" way to do this?

-- Dag