Skip to contentSkip to conversation

spi: limit reaches -1, tested 0

PATCH In review Roel Kluin 3 participants 7 messages Feb 8, 2009

Subsystems (2)
lore
Share & tools
lore

Roel Kluin

author
#0 lore raw

PATCH 1/1 spi: limit reaches -1, tested 0

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

---

drivers/spi/spi_imx.c +1 -1
index 269a55e..a4652f1 100644
@@ -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,
Acked-by on v1 1/1
#1 lore raw
Quoted 4 lines · Roel Kluin

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

Quoted 8 lines

---

drivers/spi/spi_imx.c +0 -0
index 269a55e..a4652f1 100644

drivers/spi/spi_imx.c static irqreturn_t interrupt_transfer(struct driver_data *drv_data) · line 785

Quoted 8 lines
drivers/spi/spi_imx.c +1 -1
@@ -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,

------------------------------------------------------------------------------
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

#2 lore raw
Quoted 17 lines · David Brownell
Quoted 4 lines · Roel Kluin

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

Quoted 7 lines

---

drivers/spi/spi_imx.c +0 -0
index 269a55e..a4652f1 100644
@@ -779,7 +779,7 @@ static irqreturn_t interrupt_transfer(struct driver_data *drv_data)
 
Quoted 4 lines

drivers/spi/spi_imx.c static irqreturn_t interrupt_transfer(struct driver_data *drv_data) · line 782

Quoted 4 lines
drivers/spi/spi_imx.c +1 -1
 			/* 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.

Quoted 8 lines

drivers/spi/spi_imx.c static irqreturn_t interrupt_transfer(struct driver_data *drv_data)

Quoted 5 lines
drivers/spi/spi_imx.c +0 -0
 			if (limit == 0)
 				dev_err(&drv_data->pdev->dev,
 

------------------------------------------------------------------------------
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

author
#3 lore raw
Quoted 5 lines
Quoted 2 lines

Review

Quoted 2 lines
(quoted diff) +1 -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.

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

---

drivers/spi/spi_imx.c +2 -1
index 269a55e..15abe61 100644
@@ -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,

------------------------------------------------------------------------------
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

#4 lore raw
Quoted 6 lines · Roel Kluin
Quoted 5 lines
Quoted 2 lines

Review

Quoted 2 lines
(quoted diff) +1 -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.

Quoted 6 lines

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

Still:

Quoted 8 lines

---

drivers/spi/spi_imx.c +0 -0
index 269a55e..15abe61 100644

drivers/spi/spi_imx.c static irqreturn_t interrupt_transfer(struct driver_data *drv_data) · line 786

Quoted 9 lines
drivers/spi/spi_imx.c +2 -1
@@ -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,

------------------------------------------------------------------------------
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

#5 lore raw
In reply to Roel Kluin

Roel Kluin writes in first post:

Review

Quoted 2 lines
(quoted diff) +1 -1
-			while ((read(drv_data) == 0) && limit--);
+			while ((read(drv_data) == 0) && --limit);

Roel Kluin writes in last post:

drivers/spi/spi_imx.c static irqreturn_t interrupt_transfer(struct driver_data *drv_data) · line 783

Quoted 3 lines
drivers/spi/spi_imx.c +2 -1
-			while ((read(drv_data) == 0) && limit--);
+			while ((read(drv_data) == 0) && limit--)
+				cpu_relax();

so should there be postfix or prefix decrement ? :)

Mariusz Ceier

author Acked-by David Brownell
#6 lore raw
Quoted 10 lines · Mariusz Ceier

Roel Kluin writes in first post:

Review

Quoted 2 lines
(quoted diff) +1 -1
-			while ((read(drv_data) == 0) && limit--);
+			while ((read(drv_data) == 0) && --limit);

Roel Kluin writes in last post:

Review

Quoted 3 lines
(quoted diff) +2 -1
-			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.

---

drivers/spi/spi_imx.c +2 -1
index 269a55e..b143e8c 100644
@@ -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,

------------------------------------------------------------------------------
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