Re: [PATCH] spi: limit reaches -1, tested 0

From: Roel Kluin
Date: Sun Feb 08 2009 - 11:51:11 EST


>>> - 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@xxxxxxxxx>
---
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,
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/