* pxa2xx_spi: spi_bfin5xx: limit reaches -1 rather than 0
@ 2009-02-08 15:53 ` Roel Kluin
0 siblings, 0 replies; 8+ messages in thread
From: Roel Kluin @ 2009-02-08 15:53 UTC (permalink / raw)
To: dbrownell-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f
Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, lkml
vi drivers/spi/pxa2xx_spi.c +919
vi drivers/spi/spi_bfin5xx.c +645
if (flush(drv_data) == 0) {
dev_err(&drv_data->pdev->dev, "pump_transfers: flush failed\n");
message->status = -EIO;
giveback(drv_data);
return;
}
But with a postfix decrement limit reaches -1 rather than 0.
Signed-off-by: Roel Kluin <roel.kluin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
drivers/spi/pxa2xx_spi.c | 2 +-
drivers/spi/spi_bfin5xx.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/spi/pxa2xx_spi.c b/drivers/spi/pxa2xx_spi.c
index d0fc4ca..3164741 100644
--- a/drivers/spi/pxa2xx_spi.c
+++ b/drivers/spi/pxa2xx_spi.c
@@ -185,7 +185,7 @@ static int flush(struct driver_data *drv_data)
while (read_SSSR(reg) & SSSR_RNE) {
read_SSDR(reg);
}
- } while ((read_SSSR(reg) & SSSR_BSY) && limit--);
+ } while ((read_SSSR(reg) & SSSR_BSY) && --limit);
write_SSSR(SSSR_ROR, reg);
return limit;
diff --git a/drivers/spi/spi_bfin5xx.c b/drivers/spi/spi_bfin5xx.c
index 7fea3cf..ea94567 100644
--- a/drivers/spi/spi_bfin5xx.c
+++ b/drivers/spi/spi_bfin5xx.c
@@ -162,7 +162,7 @@ static int flush(struct driver_data *drv_data)
unsigned long limit = loops_per_jiffy << 1;
/* wait for stop and clear stat */
- while (!(read_STAT(drv_data) & BIT_STAT_SPIF) && limit--)
+ while (!(read_STAT(drv_data) & BIT_STAT_SPIF) && --limit)
cpu_relax();
write_STAT(drv_data, BIT_STAT_CLR);
------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
^ permalink raw reply related [flat|nested] 8+ messages in thread
* pxa2xx_spi: spi_bfin5xx: limit reaches -1 rather than 0
@ 2009-02-08 15:53 ` Roel Kluin
0 siblings, 0 replies; 8+ messages in thread
From: Roel Kluin @ 2009-02-08 15:53 UTC (permalink / raw)
To: dbrownell; +Cc: spi-devel-general, lkml
vi drivers/spi/pxa2xx_spi.c +919
vi drivers/spi/spi_bfin5xx.c +645
if (flush(drv_data) == 0) {
dev_err(&drv_data->pdev->dev, "pump_transfers: flush failed\n");
message->status = -EIO;
giveback(drv_data);
return;
}
But with a postfix decrement limit reaches -1 rather than 0.
Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
drivers/spi/pxa2xx_spi.c | 2 +-
drivers/spi/spi_bfin5xx.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/spi/pxa2xx_spi.c b/drivers/spi/pxa2xx_spi.c
index d0fc4ca..3164741 100644
--- a/drivers/spi/pxa2xx_spi.c
+++ b/drivers/spi/pxa2xx_spi.c
@@ -185,7 +185,7 @@ static int flush(struct driver_data *drv_data)
while (read_SSSR(reg) & SSSR_RNE) {
read_SSDR(reg);
}
- } while ((read_SSSR(reg) & SSSR_BSY) && limit--);
+ } while ((read_SSSR(reg) & SSSR_BSY) && --limit);
write_SSSR(SSSR_ROR, reg);
return limit;
diff --git a/drivers/spi/spi_bfin5xx.c b/drivers/spi/spi_bfin5xx.c
index 7fea3cf..ea94567 100644
--- a/drivers/spi/spi_bfin5xx.c
+++ b/drivers/spi/spi_bfin5xx.c
@@ -162,7 +162,7 @@ static int flush(struct driver_data *drv_data)
unsigned long limit = loops_per_jiffy << 1;
/* wait for stop and clear stat */
- while (!(read_STAT(drv_data) & BIT_STAT_SPIF) && limit--)
+ while (!(read_STAT(drv_data) & BIT_STAT_SPIF) && --limit)
cpu_relax();
write_STAT(drv_data, BIT_STAT_CLR);
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2] pxa2xx_spi: spi_bfin5xx: limit reaches -1 rather than 0
2009-02-08 15:53 ` Roel Kluin
@ 2009-02-08 16:02 ` Roel Kluin
-1 siblings, 0 replies; 8+ messages in thread
From: Roel Kluin @ 2009-02-08 16:02 UTC (permalink / raw)
To: dbrownell-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f
Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, lkml
vi drivers/spi/pxa2xx_spi.c +919
vi drivers/spi/spi_bfin5xx.c +645
if (flush(drv_data) == 0) {
dev_err(&drv_data->pdev->dev, "pump_transfers: flush failed\n");
message->status = -EIO;
giveback(drv_data);
return;
}
and:
drivers/spi/pxa2xx_spi.c:515: if (wait_ssp_rx_stall(drv_data->ioaddr) == 0)
drivers/spi/pxa2xx_spi.c:569: if (wait_ssp_rx_stall(drv_data->ioaddr) == 0)
drivers/spi/pxa2xx_spi.c:695: if (!wait_ssp_rx_stall(reg))
drivers/spi/pxa2xx_spi.c:511: if (wait_dma_channel_stop(drv_data->rx_channel) == 0)
But with a postfix decrement limit reaches -1 rather than 0.
Signed-off-by: Roel Kluin <roel.kluin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
Sorry, I didn't catch two the first time
drivers/spi/pxa2xx_spi.c | 6 +++---
drivers/spi/spi_bfin5xx.c | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/spi/pxa2xx_spi.c b/drivers/spi/pxa2xx_spi.c
index d0fc4ca..318e568 100644
--- a/drivers/spi/pxa2xx_spi.c
+++ b/drivers/spi/pxa2xx_spi.c
@@ -185,7 +185,7 @@ static int flush(struct driver_data *drv_data)
while (read_SSSR(reg) & SSSR_RNE) {
read_SSDR(reg);
}
- } while ((read_SSSR(reg) & SSSR_BSY) && limit--);
+ } while ((read_SSSR(reg) & SSSR_BSY) && --limit);
write_SSSR(SSSR_ROR, reg);
return limit;
@@ -459,7 +459,7 @@ static int wait_ssp_rx_stall(void const __iomem *ioaddr)
{
unsigned long limit = loops_per_jiffy << 1;
- while ((read_SSSR(ioaddr) & SSSR_BSY) && limit--)
+ while ((read_SSSR(ioaddr) & SSSR_BSY) && --limit)
cpu_relax();
return limit;
@@ -469,7 +469,7 @@ static int wait_dma_channel_stop(int channel)
{
unsigned long limit = loops_per_jiffy << 1;
- while (!(DCSR(channel) & DCSR_STOPSTATE) && limit--)
+ while (!(DCSR(channel) & DCSR_STOPSTATE) && --limit)
cpu_relax();
return limit;
diff --git a/drivers/spi/spi_bfin5xx.c b/drivers/spi/spi_bfin5xx.c
index 7fea3cf..ea94567 100644
--- a/drivers/spi/spi_bfin5xx.c
+++ b/drivers/spi/spi_bfin5xx.c
@@ -162,7 +162,7 @@ static int flush(struct driver_data *drv_data)
unsigned long limit = loops_per_jiffy << 1;
/* wait for stop and clear stat */
- while (!(read_STAT(drv_data) & BIT_STAT_SPIF) && limit--)
+ while (!(read_STAT(drv_data) & BIT_STAT_SPIF) && --limit)
cpu_relax();
write_STAT(drv_data, BIT_STAT_CLR);
------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2] pxa2xx_spi: spi_bfin5xx: limit reaches -1 rather than 0
@ 2009-02-08 16:02 ` Roel Kluin
0 siblings, 0 replies; 8+ messages in thread
From: Roel Kluin @ 2009-02-08 16:02 UTC (permalink / raw)
To: dbrownell; +Cc: spi-devel-general, lkml
vi drivers/spi/pxa2xx_spi.c +919
vi drivers/spi/spi_bfin5xx.c +645
if (flush(drv_data) == 0) {
dev_err(&drv_data->pdev->dev, "pump_transfers: flush failed\n");
message->status = -EIO;
giveback(drv_data);
return;
}
and:
drivers/spi/pxa2xx_spi.c:515: if (wait_ssp_rx_stall(drv_data->ioaddr) == 0)
drivers/spi/pxa2xx_spi.c:569: if (wait_ssp_rx_stall(drv_data->ioaddr) == 0)
drivers/spi/pxa2xx_spi.c:695: if (!wait_ssp_rx_stall(reg))
drivers/spi/pxa2xx_spi.c:511: if (wait_dma_channel_stop(drv_data->rx_channel) == 0)
But with a postfix decrement limit reaches -1 rather than 0.
Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
Sorry, I didn't catch two the first time
drivers/spi/pxa2xx_spi.c | 6 +++---
drivers/spi/spi_bfin5xx.c | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/spi/pxa2xx_spi.c b/drivers/spi/pxa2xx_spi.c
index d0fc4ca..318e568 100644
--- a/drivers/spi/pxa2xx_spi.c
+++ b/drivers/spi/pxa2xx_spi.c
@@ -185,7 +185,7 @@ static int flush(struct driver_data *drv_data)
while (read_SSSR(reg) & SSSR_RNE) {
read_SSDR(reg);
}
- } while ((read_SSSR(reg) & SSSR_BSY) && limit--);
+ } while ((read_SSSR(reg) & SSSR_BSY) && --limit);
write_SSSR(SSSR_ROR, reg);
return limit;
@@ -459,7 +459,7 @@ static int wait_ssp_rx_stall(void const __iomem *ioaddr)
{
unsigned long limit = loops_per_jiffy << 1;
- while ((read_SSSR(ioaddr) & SSSR_BSY) && limit--)
+ while ((read_SSSR(ioaddr) & SSSR_BSY) && --limit)
cpu_relax();
return limit;
@@ -469,7 +469,7 @@ static int wait_dma_channel_stop(int channel)
{
unsigned long limit = loops_per_jiffy << 1;
- while (!(DCSR(channel) & DCSR_STOPSTATE) && limit--)
+ while (!(DCSR(channel) & DCSR_STOPSTATE) && --limit)
cpu_relax();
return limit;
diff --git a/drivers/spi/spi_bfin5xx.c b/drivers/spi/spi_bfin5xx.c
index 7fea3cf..ea94567 100644
--- a/drivers/spi/spi_bfin5xx.c
+++ b/drivers/spi/spi_bfin5xx.c
@@ -162,7 +162,7 @@ static int flush(struct driver_data *drv_data)
unsigned long limit = loops_per_jiffy << 1;
/* wait for stop and clear stat */
- while (!(read_STAT(drv_data) & BIT_STAT_SPIF) && limit--)
+ while (!(read_STAT(drv_data) & BIT_STAT_SPIF) && --limit)
cpu_relax();
write_STAT(drv_data, BIT_STAT_CLR);
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: pxa2xx_spi: spi_bfin5xx: limit reaches -1 rather than 0
2009-02-08 15:53 ` Roel Kluin
@ 2009-02-08 16:07 ` David Brownell
-1 siblings, 0 replies; 8+ messages in thread
From: David Brownell @ 2009-02-08 16:07 UTC (permalink / raw)
To: Roel Kluin
Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, Andrew Morton,
lkml
On Sunday 08 February 2009, Roel Kluin wrote:
> vi drivers/spi/pxa2xx_spi.c +919
> vi drivers/spi/spi_bfin5xx.c +645
>
> if (flush(drv_data) == 0) {
> dev_err(&drv_data->pdev->dev, "pump_transfers: flush failed\n");
> message->status = -EIO;
> giveback(drv_data);
> return;
> }
>
> But with a postfix decrement limit reaches -1 rather than 0.
>
> Signed-off-by: Roel Kluin <roel.kluin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Acked-by: David Brownell <dbrownell-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Although, note that if the *actual* count mattered here,
the correect patch would be to test "flush() < 0)" ...
except when using a "do {...} while (--limit)" idiom.
Try the thought experiment of starting with "limit = 1";
not all of these patches of your would go through the
loop even once. Fortunately in all these cases, the
limit is an arbitrary "don't loop forever" thing.
> ---
> drivers/spi/pxa2xx_spi.c | 2 +-
> drivers/spi/spi_bfin5xx.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/spi/pxa2xx_spi.c b/drivers/spi/pxa2xx_spi.c
> index d0fc4ca..3164741 100644
> --- a/drivers/spi/pxa2xx_spi.c
> +++ b/drivers/spi/pxa2xx_spi.c
> @@ -185,7 +185,7 @@ static int flush(struct driver_data *drv_data)
> while (read_SSSR(reg) & SSSR_RNE) {
> read_SSDR(reg);
> }
> - } while ((read_SSSR(reg) & SSSR_BSY) && limit--);
> + } while ((read_SSSR(reg) & SSSR_BSY) && --limit);
> write_SSSR(SSSR_ROR, reg);
>
> return limit;
> diff --git a/drivers/spi/spi_bfin5xx.c b/drivers/spi/spi_bfin5xx.c
> index 7fea3cf..ea94567 100644
> --- a/drivers/spi/spi_bfin5xx.c
> +++ b/drivers/spi/spi_bfin5xx.c
> @@ -162,7 +162,7 @@ static int flush(struct driver_data *drv_data)
> unsigned long limit = loops_per_jiffy << 1;
>
> /* wait for stop and clear stat */
> - while (!(read_STAT(drv_data) & BIT_STAT_SPIF) && limit--)
> + while (!(read_STAT(drv_data) & BIT_STAT_SPIF) && --limit)
> cpu_relax();
>
> write_STAT(drv_data, BIT_STAT_CLR);
>
>
------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: pxa2xx_spi: spi_bfin5xx: limit reaches -1 rather than 0
@ 2009-02-08 16:07 ` David Brownell
0 siblings, 0 replies; 8+ messages in thread
From: David Brownell @ 2009-02-08 16:07 UTC (permalink / raw)
To: Roel Kluin; +Cc: spi-devel-general, lkml, Andrew Morton
On Sunday 08 February 2009, Roel Kluin wrote:
> vi drivers/spi/pxa2xx_spi.c +919
> vi drivers/spi/spi_bfin5xx.c +645
>
> if (flush(drv_data) == 0) {
> dev_err(&drv_data->pdev->dev, "pump_transfers: flush failed\n");
> message->status = -EIO;
> giveback(drv_data);
> return;
> }
>
> But with a postfix decrement limit reaches -1 rather than 0.
>
> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
Acked-by: David Brownell <dbrownell@users.sourceforge.net>
Although, note that if the *actual* count mattered here,
the correect patch would be to test "flush() < 0)" ...
except when using a "do {...} while (--limit)" idiom.
Try the thought experiment of starting with "limit = 1";
not all of these patches of your would go through the
loop even once. Fortunately in all these cases, the
limit is an arbitrary "don't loop forever" thing.
> ---
> drivers/spi/pxa2xx_spi.c | 2 +-
> drivers/spi/spi_bfin5xx.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/spi/pxa2xx_spi.c b/drivers/spi/pxa2xx_spi.c
> index d0fc4ca..3164741 100644
> --- a/drivers/spi/pxa2xx_spi.c
> +++ b/drivers/spi/pxa2xx_spi.c
> @@ -185,7 +185,7 @@ static int flush(struct driver_data *drv_data)
> while (read_SSSR(reg) & SSSR_RNE) {
> read_SSDR(reg);
> }
> - } while ((read_SSSR(reg) & SSSR_BSY) && limit--);
> + } while ((read_SSSR(reg) & SSSR_BSY) && --limit);
> write_SSSR(SSSR_ROR, reg);
>
> return limit;
> diff --git a/drivers/spi/spi_bfin5xx.c b/drivers/spi/spi_bfin5xx.c
> index 7fea3cf..ea94567 100644
> --- a/drivers/spi/spi_bfin5xx.c
> +++ b/drivers/spi/spi_bfin5xx.c
> @@ -162,7 +162,7 @@ static int flush(struct driver_data *drv_data)
> unsigned long limit = loops_per_jiffy << 1;
>
> /* wait for stop and clear stat */
> - while (!(read_STAT(drv_data) & BIT_STAT_SPIF) && limit--)
> + while (!(read_STAT(drv_data) & BIT_STAT_SPIF) && --limit)
> cpu_relax();
>
> write_STAT(drv_data, BIT_STAT_CLR);
>
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: pxa2xx_spi: spi_bfin5xx: limit reaches -1 rather than 0
2009-02-08 16:07 ` David Brownell
@ 2009-02-08 16:59 ` roel kluin
-1 siblings, 0 replies; 8+ messages in thread
From: roel kluin @ 2009-02-08 16:59 UTC (permalink / raw)
To: David Brownell
Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, Andrew Morton,
lkml
2009/2/8 David Brownell <david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>:
> On Sunday 08 February 2009, Roel Kluin wrote:
>> vi drivers/spi/pxa2xx_spi.c +919
>> vi drivers/spi/spi_bfin5xx.c +645
>>
>> if (flush(drv_data) == 0) {
>> dev_err(&drv_data->pdev->dev, "pump_transfers: flush failed\n");
>> message->status = -EIO;
>> giveback(drv_data);
>> return;
>> }
>>
>> But with a postfix decrement limit reaches -1 rather than 0.
>>
>> Signed-off-by: Roel Kluin <roel.kluin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>
> Acked-by: David Brownell <dbrownell-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
could you please review the patch at http://lkml.org/lkml/2009/2/8/72
instead? I initially overlooked two similar issues in the same file.
> Although, note that if the *actual* count mattered here,
> the correect patch would be to test "flush() < 0)" ...
> except when using a "do {...} while (--limit)" idiom.
True. You can also increase the limit with 1 when changing post- to
prefix for the while (--limit) {...} idiom.
------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: pxa2xx_spi: spi_bfin5xx: limit reaches -1 rather than 0
@ 2009-02-08 16:59 ` roel kluin
0 siblings, 0 replies; 8+ messages in thread
From: roel kluin @ 2009-02-08 16:59 UTC (permalink / raw)
To: David Brownell; +Cc: spi-devel-general, lkml, Andrew Morton
2009/2/8 David Brownell <david-b@pacbell.net>:
> On Sunday 08 February 2009, Roel Kluin wrote:
>> vi drivers/spi/pxa2xx_spi.c +919
>> vi drivers/spi/spi_bfin5xx.c +645
>>
>> if (flush(drv_data) == 0) {
>> dev_err(&drv_data->pdev->dev, "pump_transfers: flush failed\n");
>> message->status = -EIO;
>> giveback(drv_data);
>> return;
>> }
>>
>> But with a postfix decrement limit reaches -1 rather than 0.
>>
>> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
>
> Acked-by: David Brownell <dbrownell@users.sourceforge.net>
could you please review the patch at http://lkml.org/lkml/2009/2/8/72
instead? I initially overlooked two similar issues in the same file.
> Although, note that if the *actual* count mattered here,
> the correect patch would be to test "flush() < 0)" ...
> except when using a "do {...} while (--limit)" idiom.
True. You can also increase the limit with 1 when changing post- to
prefix for the while (--limit) {...} idiom.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2009-02-08 16:59 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-08 15:53 pxa2xx_spi: spi_bfin5xx: limit reaches -1 rather than 0 Roel Kluin
2009-02-08 15:53 ` Roel Kluin
[not found] ` <498F0004.1030709-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2009-02-08 16:02 ` [PATCH v2] " Roel Kluin
2009-02-08 16:02 ` Roel Kluin
2009-02-08 16:07 ` David Brownell
2009-02-08 16:07 ` David Brownell
[not found] ` <200902080807.29237.david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>
2009-02-08 16:59 ` roel kluin
2009-02-08 16:59 ` roel kluin
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.