All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dz: test after postfix decrement fails in dz_console_putchar()
@ 2008-04-09 10:00 Roel Kluin
  2008-04-09 13:37 ` Maciej W. Rozycki
  2008-04-09 13:41 ` Johannes Weiner
  0 siblings, 2 replies; 4+ messages in thread
From: Roel Kluin @ 2008-04-09 10:00 UTC (permalink / raw)
  To: Maciej W. Rozycki; +Cc: lkml

When loops reaches 0 the postfix decrement still subtracts, so the test fails

Signed-off-by: Roel Kluin <12o3l@tiscali.nl>
---
diff --git a/drivers/serial/dz.c b/drivers/serial/dz.c
index 116211f..0dddd68 100644
--- a/drivers/serial/dz.c
+++ b/drivers/serial/dz.c
@@ -819,7 +819,7 @@ static void dz_console_putchar(struct uart_port *uport, int ch)
 		dz_out(dport, DZ_TCR, mask);
 		iob();
 		udelay(2);
-	} while (loops--);
+	} while (--loops);
 
 	if (loops)				/* Cannot send otherwise. */
 		dz_out(dport, DZ_TDR, ch);

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

* Re: [PATCH] dz: test after postfix decrement fails in dz_console_putchar()
  2008-04-09 10:00 [PATCH] dz: test after postfix decrement fails in dz_console_putchar() Roel Kluin
@ 2008-04-09 13:37 ` Maciej W. Rozycki
  2008-04-09 13:41 ` Johannes Weiner
  1 sibling, 0 replies; 4+ messages in thread
From: Maciej W. Rozycki @ 2008-04-09 13:37 UTC (permalink / raw)
  To: Roel Kluin; +Cc: lkml

On Wed, 9 Apr 2008, Roel Kluin wrote:

> When loops reaches 0 the postfix decrement still subtracts, so the test 
> fails

 You are right -- thanks for spotting it!

Acked-by: Maciej W. Rozycki <macro@linux-mips.org>

  Maciej


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

* Re: [PATCH] dz: test after postfix decrement fails in dz_console_putchar()
  2008-04-09 10:00 [PATCH] dz: test after postfix decrement fails in dz_console_putchar() Roel Kluin
  2008-04-09 13:37 ` Maciej W. Rozycki
@ 2008-04-09 13:41 ` Johannes Weiner
  2008-04-09 14:35   ` Maciej W. Rozycki
  1 sibling, 1 reply; 4+ messages in thread
From: Johannes Weiner @ 2008-04-09 13:41 UTC (permalink / raw)
  To: Roel Kluin; +Cc: Maciej W. Rozycki, lkml

Hi,

Roel Kluin <12o3l@tiscali.nl> writes:

> When loops reaches 0 the postfix decrement still subtracts, so the test fails
>
> Signed-off-by: Roel Kluin <12o3l@tiscali.nl>
> ---
> diff --git a/drivers/serial/dz.c b/drivers/serial/dz.c
> index 116211f..0dddd68 100644
> --- a/drivers/serial/dz.c
> +++ b/drivers/serial/dz.c
> @@ -819,7 +819,7 @@ static void dz_console_putchar(struct uart_port *uport, int ch)
>  		dz_out(dport, DZ_TCR, mask);
>  		iob();
>  		udelay(2);
> -	} while (loops--);
> +	} while (--loops);

It will run loops + 1 times.  After your change it does run loops times.

>  	if (loops)				/* Cannot send otherwise. */
>  		dz_out(dport, DZ_TDR, ch);

The intention was probably that this gets executed if the break in the
loop (trdy == dport->port.line) is reached.  Without your fix, this
branch is also taken if the while-loop terminates with loops == -1
because of the postfix dec.

Your fix is correct but your changelog entry is wrong.

	Hannes

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

* Re: [PATCH] dz: test after postfix decrement fails in dz_console_putchar()
  2008-04-09 13:41 ` Johannes Weiner
@ 2008-04-09 14:35   ` Maciej W. Rozycki
  0 siblings, 0 replies; 4+ messages in thread
From: Maciej W. Rozycki @ 2008-04-09 14:35 UTC (permalink / raw)
  To: Johannes Weiner; +Cc: Roel Kluin, lkml

On Wed, 9 Apr 2008, Johannes Weiner wrote:

> The intention was probably that this gets executed if the break in the
> loop (trdy == dport->port.line) is reached.  Without your fix, this
> branch is also taken if the while-loop terminates with loops == -1
> because of the postfix dec.

 You are right about the intention -- you cannot send a character to the 
transmitter unless the intended line has been reported as selected for 
transmission by the serial controller.  Otherwise it will go to the wrong 
line -- this is a serial multiplexer that selects transmission lines by 
itself.

 It used to be the other kind of a "while" loop.  This is a cut & paste 
bug -- I noticed the problem with the terminating condition of the loop 
and correctly moved it to the end, but forgot to adjust the 
decrementation.

> Your fix is correct but your changelog entry is wrong.

 s/fails/incorrectly succeeds/

  Maciej

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

end of thread, other threads:[~2008-04-09 14:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-09 10:00 [PATCH] dz: test after postfix decrement fails in dz_console_putchar() Roel Kluin
2008-04-09 13:37 ` Maciej W. Rozycki
2008-04-09 13:41 ` Johannes Weiner
2008-04-09 14:35   ` Maciej W. Rozycki

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.