public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH][KJ] 8250: remove unnecessary variable tmout from  wait_for_xmitr()
@ 2007-12-13 14:08 Andre Haupt
  2007-12-13 14:51 ` Johannes Weiner
  0 siblings, 1 reply; 2+ messages in thread
From: Andre Haupt @ 2007-12-13 14:08 UTC (permalink / raw)
  To: kernel-janitors; +Cc: linux-serial, linux-kernel, trivial, Andre Haupt

This fixes a sparse warning about symbol tmout shadowing an earlier one.

Signed-off-by: Andre Haupt <andre@bitwigglers.org>
---
 drivers/serial/8250.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c
index f94109c..284757d 100644
--- a/drivers/serial/8250.c
+++ b/drivers/serial/8250.c
@@ -1727,7 +1727,6 @@ static inline void wait_for_xmitr(struct uart_8250_port *up, int bits)
 
 	/* Wait up to 1s for flow control if necessary */
 	if (up->port.flags & UPF_CONS_FLOW) {
-		unsigned int tmout;
 		for (tmout = 1000000; tmout; tmout--) {
 			unsigned int msr = serial_in(up, UART_MSR);
 			up->msr_saved_flags |= msr & MSR_SAVE_FLAGS;
-- 
1.4.4.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH][KJ] 8250: remove unnecessary variable tmout from  wait_for_xmitr()
  2007-12-13 14:08 [PATCH][KJ] 8250: remove unnecessary variable tmout from wait_for_xmitr() Andre Haupt
@ 2007-12-13 14:51 ` Johannes Weiner
  0 siblings, 0 replies; 2+ messages in thread
From: Johannes Weiner @ 2007-12-13 14:51 UTC (permalink / raw)
  To: Andre Haupt; +Cc: kernel-janitors, linux-serial, linux-kernel, trivial

Hi,

Andre Haupt <andre@bitwigglers.org> writes:

> This fixes a sparse warning about symbol tmout shadowing an earlier one.
>
> Signed-off-by: Andre Haupt <andre@bitwigglers.org>
> ---
>  drivers/serial/8250.c |    1 -
>  1 files changed, 0 insertions(+), 1 deletions(-)

The whole timeout loops look somewhat odd.  How about the following,
totally untested, solution?

This converts the function to use more common timeout-loop constructs,
gets rid of the shadowed variable and localises another variable even
more! Hooray!

	Hannes

Signed-off-by: Johannes Weiner <hannes@saeurebad.de>
---

 drivers/serial/8250.c |   18 +++++++++---------
 1 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c
index f94109c..7215f6a 100644
--- a/drivers/serial/8250.c
+++ b/drivers/serial/8250.c
@@ -1712,30 +1712,30 @@ static void serial8250_break_ctl(struct uart_port *port, int break_state)
  */
 static inline void wait_for_xmitr(struct uart_8250_port *up, int bits)
 {
-	unsigned int status, tmout = 10000;
+	unsigned int tmout;
 
 	/* Wait up to 10ms for the character(s) to be sent. */
+	tmout = jiffies + jiffies_to_msecs(10);
 	do {
-		status = serial_in(up, UART_LSR);
+		unsigned int status = serial_in(up, UART_LSR);
 
-		up->lsr_saved_flags |= status & LSR_SAVE_FLAGS;
-
-		if (--tmout == 0)
+		up->lsr_saved_flags |= (status & LSR_SAVE_FLAGS);
+		if ((status & bits) == bits)
 			break;
 		udelay(1);
-	} while ((status & bits) != bits);
+	} while (time_after_eq(tmout, jiffies));
 
 	/* Wait up to 1s for flow control if necessary */
 	if (up->port.flags & UPF_CONS_FLOW) {
-		unsigned int tmout;
-		for (tmout = 1000000; tmout; tmout--) {
+		tmout = jiffies + jiffies_to_msecs(1000);
+		do {
 			unsigned int msr = serial_in(up, UART_MSR);
 			up->msr_saved_flags |= msr & MSR_SAVE_FLAGS;
 			if (msr & UART_MSR_CTS)
 				break;
 			udelay(1);
 			touch_nmi_watchdog();
-		}
+		} while (time_after_eq(tmout, jiffies));
 	}
 }
 

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-12-13 14:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-13 14:08 [PATCH][KJ] 8250: remove unnecessary variable tmout from wait_for_xmitr() Andre Haupt
2007-12-13 14:51 ` Johannes Weiner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox