public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] spi: limit reaches -1, tested 0
@ 2009-02-08 14:18 Roel Kluin
  2009-02-08 15:55 ` David Brownell
  0 siblings, 1 reply; 7+ messages in thread
From: Roel Kluin @ 2009-02-08 14:18 UTC (permalink / raw)
  To: dbrownell; +Cc: spi-devel-general, lkml

With a postfix decrement limit will reach -1 rather than 0,
so the warning will not be issued.

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
diff --git a/drivers/spi/spi_imx.c b/drivers/spi/spi_imx.c
index 269a55e..a4652f1 100644
--- a/drivers/spi/spi_imx.c
+++ b/drivers/spi/spi_imx.c
@@ -779,7 +779,7 @@ static irqreturn_t interrupt_transfer(struct driver_data *drv_data)
 
 			/* Read trailing bytes */
 			limit = loops_per_jiffy << 1;
-			while ((read(drv_data) == 0) && limit--);
+			while ((read(drv_data) == 0) && --limit);
 
 			if (limit == 0)
 				dev_err(&drv_data->pdev->dev,


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

* Re: [PATCH] spi: limit reaches -1, tested 0
  2009-02-08 14:18 [PATCH] spi: limit reaches -1, tested 0 Roel Kluin
@ 2009-02-08 15:55 ` David Brownell
  2009-02-08 16:28   ` David Brownell
  0 siblings, 1 reply; 7+ messages in thread
From: David Brownell @ 2009-02-08 15:55 UTC (permalink / raw)
  To: Roel Kluin; +Cc: spi-devel-general, lkml, Andrew Morton

On Sunday 08 February 2009, Roel Kluin wrote:
> With a postfix decrement limit will reach -1 rather than 0,
> so the warning will not be issued.
> 
> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>

Acked-by: David Brownell <dbrownell@users.sourceforge.net>



> ---
> diff --git a/drivers/spi/spi_imx.c b/drivers/spi/spi_imx.c
> index 269a55e..a4652f1 100644
> --- a/drivers/spi/spi_imx.c
> +++ b/drivers/spi/spi_imx.c
> @@ -779,7 +779,7 @@ static irqreturn_t interrupt_transfer(struct driver_data *drv_data)
>  
>  			/* Read trailing bytes */
>  			limit = loops_per_jiffy << 1;
> -			while ((read(drv_data) == 0) && limit--);
> +			while ((read(drv_data) == 0) && --limit);
>  
>  			if (limit == 0)
>  				dev_err(&drv_data->pdev->dev,
> 
> 



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

* Re: [PATCH] spi: limit reaches -1, tested 0
  2009-02-08 15:55 ` David Brownell
@ 2009-02-08 16:28   ` David Brownell
  2009-02-08 16:50     ` Roel Kluin
  0 siblings, 1 reply; 7+ messages in thread
From: David Brownell @ 2009-02-08 16:28 UTC (permalink / raw)
  To: Roel Kluin; +Cc: spi-devel-general, lkml, Andrew Morton

On Sunday 08 February 2009, David Brownell wrote:
> On Sunday 08 February 2009, Roel Kluin wrote:
> > With a postfix decrement limit will reach -1 rather than 0,
> > so the warning will not be issued.
> > 
> > Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
> 
> Acked-by: David Brownell <dbrownell@users.sourceforge.net>
> 
> 
> 
> > ---
> > diff --git a/drivers/spi/spi_imx.c b/drivers/spi/spi_imx.c
> > index 269a55e..a4652f1 100644
> > --- a/drivers/spi/spi_imx.c
> > +++ b/drivers/spi/spi_imx.c
> > @@ -779,7 +779,7 @@ static irqreturn_t interrupt_transfer(struct driver_data *drv_data)
> >  
> >  			/* Read trailing bytes */
> >  			limit = loops_per_jiffy << 1;
> > -			while ((read(drv_data) == 0) && limit--);
> > +			while ((read(drv_data) == 0) && --limit);

... although I wouldn't have resisted the urge to make the
loop body be "cpu_relax();" instead of an empty statement.


> >  
> >  			if (limit == 0)
> >  				dev_err(&drv_data->pdev->dev,
> > 
> > 
> 
> 
> 



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

* Re: [PATCH] spi: limit reaches -1, tested 0
  2009-02-08 16:28   ` David Brownell
@ 2009-02-08 16:50     ` Roel Kluin
  2009-02-08 17:26       ` David Brownell
  2009-02-08 17:42       ` Mariusz Ceier
  0 siblings, 2 replies; 7+ messages in thread
From: Roel Kluin @ 2009-02-08 16:50 UTC (permalink / raw)
  To: David Brownell; +Cc: spi-devel-general, lkml, Andrew Morton

>>> -			while ((read(drv_data) == 0) && limit--);
>>> +			while ((read(drv_data) == 0) && --limit);
> 
> ... although I wouldn't have resisted the urge to make the
> loop body be "cpu_relax();" instead of an empty statement.

Ok,
---------------------------->8-------------------8<-----------------------------
With a postfix decrement limit will reach -1 rather than 0, so the warning will
not be issued.

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
diff --git a/drivers/spi/spi_imx.c b/drivers/spi/spi_imx.c
index 269a55e..15abe61 100644
--- a/drivers/spi/spi_imx.c
+++ b/drivers/spi/spi_imx.c
@@ -779,7 +779,8 @@ static irqreturn_t interrupt_transfer(struct driver_data *drv_data)
 
 			/* Read trailing bytes */
 			limit = loops_per_jiffy << 1;
-			while ((read(drv_data) == 0) && limit--);
+			while ((read(drv_data) == 0) && limit--)
+				cpu_relax();
 
 			if (limit == 0)
 				dev_err(&drv_data->pdev->dev,

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

* Re: [PATCH] spi: limit reaches -1, tested 0
  2009-02-08 16:50     ` Roel Kluin
@ 2009-02-08 17:26       ` David Brownell
  2009-02-08 17:42       ` Mariusz Ceier
  1 sibling, 0 replies; 7+ messages in thread
From: David Brownell @ 2009-02-08 17:26 UTC (permalink / raw)
  To: Roel Kluin; +Cc: spi-devel-general, lkml, Andrew Morton

On Sunday 08 February 2009, Roel Kluin wrote:
> >>> -			while ((read(drv_data) == 0) && limit--);
> >>> +			while ((read(drv_data) == 0) && --limit);
> > 
> > ... although I wouldn't have resisted the urge to make the
> > loop body be "cpu_relax();" instead of an empty statement.
> 
> Ok,
> ---------------------------->8-------------------8<-----------------------------
> With a postfix decrement limit will reach -1 rather than 0, so the warning will
> not be issued.
> 
> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>

Still:

Acked-by: David Brownell <dbrownell@users.sourceforge.net>


> ---
> diff --git a/drivers/spi/spi_imx.c b/drivers/spi/spi_imx.c
> index 269a55e..15abe61 100644
> --- a/drivers/spi/spi_imx.c
> +++ b/drivers/spi/spi_imx.c
> @@ -779,7 +779,8 @@ static irqreturn_t interrupt_transfer(struct driver_data *drv_data)
>  
>  			/* Read trailing bytes */
>  			limit = loops_per_jiffy << 1;
> -			while ((read(drv_data) == 0) && limit--);
> +			while ((read(drv_data) == 0) && limit--)
> +				cpu_relax();
>  
>  			if (limit == 0)
>  				dev_err(&drv_data->pdev->dev,
> 
> 



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

* Re: [PATCH] spi: limit reaches -1, tested 0
  2009-02-08 16:50     ` Roel Kluin
  2009-02-08 17:26       ` David Brownell
@ 2009-02-08 17:42       ` Mariusz Ceier
  2009-02-08 17:46         ` Roel Kluin
  1 sibling, 1 reply; 7+ messages in thread
From: Mariusz Ceier @ 2009-02-08 17:42 UTC (permalink / raw)
  To: Roel Kluin; +Cc: David Brownell, spi-devel-general, lkml, Andrew Morton

Roel Kluin writes in first post:
> -			while ((read(drv_data) == 0) && limit--);
> +			while ((read(drv_data) == 0) && --limit);

Roel Kluin writes in last post:
> -			while ((read(drv_data) == 0) && limit--);
> +			while ((read(drv_data) == 0) && limit--)
> +				cpu_relax();

so should there be postfix or prefix decrement ? :)

Mariusz Ceier



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

* Re: [PATCH] spi: limit reaches -1, tested 0
  2009-02-08 17:42       ` Mariusz Ceier
@ 2009-02-08 17:46         ` Roel Kluin
  0 siblings, 0 replies; 7+ messages in thread
From: Roel Kluin @ 2009-02-08 17:46 UTC (permalink / raw)
  To: Mariusz Ceier; +Cc: David Brownell, spi-devel-general, lkml, Andrew Morton

Mariusz Ceier wrote:
> Roel Kluin writes in first post:
>> -			while ((read(drv_data) == 0) && limit--);
>> +			while ((read(drv_data) == 0) && --limit);
> 
> Roel Kluin writes in last post:
>> -			while ((read(drv_data) == 0) && limit--);
>> +			while ((read(drv_data) == 0) && limit--)
>> +				cpu_relax();
> 
> so should there be postfix or prefix decrement ? :)

Thanks for spotting, I took the liberty to add David Brownell's Acked-by
in this case.
----------------------->8------------------8<---------------------------
With a postfix decrement limit will reach -1 rather than 0,
so the warning will not be issued.

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
Acked-by: David Brownell <dbrownell@users.sourceforge.net>
---
diff --git a/drivers/spi/spi_imx.c b/drivers/spi/spi_imx.c
index 269a55e..b143e8c 100644
--- a/drivers/spi/spi_imx.c
+++ b/drivers/spi/spi_imx.c
@@ -779,7 +779,8 @@ static irqreturn_t interrupt_transfer(struct driver_data *drv_data)
 
 			/* Read trailing bytes */
 			limit = loops_per_jiffy << 1;
-			while ((read(drv_data) == 0) && limit--);
+			while ((read(drv_data) == 0) && --limit)
+				cpu_relax();
 
 			if (limit == 0)
 				dev_err(&drv_data->pdev->dev,

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

end of thread, other threads:[~2009-02-08 17:46 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-08 14:18 [PATCH] spi: limit reaches -1, tested 0 Roel Kluin
2009-02-08 15:55 ` David Brownell
2009-02-08 16:28   ` David Brownell
2009-02-08 16:50     ` Roel Kluin
2009-02-08 17:26       ` David Brownell
2009-02-08 17:42       ` Mariusz Ceier
2009-02-08 17:46         ` Roel Kluin

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