All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ian Abbott <abbotti@mev.co.uk>
To: linux-serial@vger.kernel.org
Cc: Russell King <rmk+serial@vger.kernel.org>
Subject: [PATCH][2.6.10-rc2-bk9] Assume struct uart_state closing times are in centiseconds
Date: Fri, 26 Nov 2004 18:16:43 +0000	[thread overview]
Message-ID: <41A7730B.4080004@mev.co.uk> (raw)

[-- Attachment #1: Type: text/plain, Size: 748 bytes --]

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.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>

[-- Attachment #2: serial_closing_time.patch --]
[-- Type: text/x-patch, Size: 2276 bytes --]

diff -urN linux-2.6.10-rc2-bk9/drivers/serial/serial_core.c linux-2.6.10-rc2-bk9-ia/drivers/serial/serial_core.c
--- linux-2.6.10-rc2-bk9/drivers/serial/serial_core.c	2004-11-26 17:26:07.750667256 +0000
+++ linux-2.6.10-rc2-bk9-ia/drivers/serial/serial_core.c	2004-11-26 17:46:32.523473488 +0000
@@ -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);
 	}
diff -urN linux-2.6.10-rc2-bk9/include/linux/serial_core.h linux-2.6.10-rc2-bk9-ia/include/linux/serial_core.h
--- linux-2.6.10-rc2-bk9/include/linux/serial_core.h	2004-11-26 17:26:14.787597480 +0000
+++ linux-2.6.10-rc2-bk9-ia/include/linux/serial_core.h	2004-11-26 17:49:09.499609488 +0000
@@ -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)

             reply	other threads:[~2004-11-26 19:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-11-26 18:16 Ian Abbott [this message]
  -- strict thread matches above, loose matches on Subject: below --
2004-11-26 21:29 [PATCH][2.6.10-rc2-bk9] Assume struct uart_state closing times are in centiseconds Ian Abbott

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=41A7730B.4080004@mev.co.uk \
    --to=abbotti@mev.co.uk \
    --cc=linux-serial@vger.kernel.org \
    --cc=rmk+serial@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.