Skip to contentSkip to conversation

spi_s3c24xx signedness fix

PATCH New David Brownell 1 participant 1 message May 1, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 spi_s3c24xx signedness fix

From: Matthew Wilcox <[email protected]>

Quoted 7 lines · Julia Lawall

I found 63 occurrences of this problem with the following semantic match
(http://www.emn.fr/x-info/coccinelle/):

@@ unsigned int i; @@

* i < 0

Since this one's always in the range 0-255, it could probably be made signed, but it's just as easy to make it work unsigned.

---
 drivers/spi/spi_s3c24xx.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/spi/spi_s3c24xx.c +3 -3
@@ -125,10 +125,10 @@ static int s3c24xx_spi_setupxfer(struct 
 	/* is clk = pclk / (2 * (pre+1)), or is it
 	 *    clk = (pclk * 2) / ( pre + 1) */
 
-	div = (div / 2) - 1;
+	div /= 2;
 
-	if (div < 0)
-		div = 1;
+	if (div > 0)
+		div -= 1;
 
 	if (div > 255)
 		div = 255;

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone