Assume struct uart_state closing times are in centiseconds
PATCH 1/1 Assume struct uart_state closing times are in centiseconds
Hi,
The current use of close_delay and closing_wait within serial_core.c is a little messed up for the following reasons:
* The values are scaled by uart_set_info() but not scaled back by uart_get_info(), so the values are different unless HZ==100.
* The closing_wait value is scaled by uart_set_info() and compared to an unscaled magic value USF_CLOSING_WAIT_NONE in uart_close().
As uart_set_info already assumes that the new values are in centisecond units and scaling could mess up the comparison with magic values (even if the magic values are scaled), I propose to store the raw centisecond values in struct uart_state and scale them at the point of use. Here is a patch to do that.
drivers/serial/serial_core.c +6 -6
@@ -751,8 +751,8 @@ port->flags = (port->flags & ~UPF_CHANGE_MASK ) | (new_serial.flags &UPF_CHANGE_MASK ); port->custom_divisor = new_serial.custom_divisor; - state->close_delay = new_serial.close_delay *HZ /100 ; - state->closing_wait = new_serial.closing_wait *HZ /100 ; + state->close_delay = new_serial.close_delay; + state->closing_wait = new_serial.closing_wait; port->fifosize = new_serial.xmit_fifo_size;if (state->info->tty) state->info->tty->low_latency =
@@ -1191,7 +1191,7 @@ tty->closing =1 ;if (state->closing_wait !=USF_CLOSING_WAIT_NONE ) -tty_wait_until_sent (tty, state->closing_wait); +tty_wait_until_sent (tty, state->closing_wait *HZ /100 );/* * At this point, we stop accepting input. To do this, we
@@ -1220,7 +1220,7 @@if (state->info->blocked_open) {if (state->close_delay) { -msleep_interruptible (jiffies_to_msecs (state->close_delay)); +msleep_interruptible (10 * state->close_delay); } }else if (!uart_console (port)) {uart_change_pm (state,3 );
@@ -2082,8 +2082,8 @@for (i =0 ; i < drv->nr; i++) {struct uart_state *state = drv->state + i; - state->close_delay =5 *HZ /10 ; - state->closing_wait =30 *HZ ; + state->close_delay =50 ;/* .5 seconds */ + state->closing_wait =3000 ;/* 30 seconds */ init_MUTEX (&state->sem); }
include/linux/serial_core.h +2 -2
@@ -241,8 +241,8 @@* within. */ struct uart_state { -unsigned int close_delay; -unsigned int closing_wait; +unsigned int close_delay;/* units: centiseconds */ +unsigned int closing_wait;/* units: centiseconds */ #define USF_CLOSING_WAIT_INF (0)#define USF_CLOSING_WAIT_NONE (65535)