From: Matthew Wilcox Date: Thu, 1 May 2008 11:35:04 +0000 (-0700) Subject: spi_s3c24xx signedness fix X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=0d34aa4d5a3e5d141bb4d07ed5d4bf02d4d4998a;p=GitHub%2Fexynos8895%2Fandroid_kernel_samsung_universal8895.git spi_s3c24xx signedness fix On Fri, Apr 18, 2008 at 09:08:55PM +0200, Julia Lawall wrote: > 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. Reported-by: Julia Lawall Signed-off-by: Matthew Wilcox Signed-off-by: David Brownell Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/drivers/spi/spi_s3c24xx.c b/drivers/spi/spi_s3c24xx.c index 34bfb7dd7764..0885cc357a37 100644 --- a/drivers/spi/spi_s3c24xx.c +++ b/drivers/spi/spi_s3c24xx.c @@ -125,10 +125,10 @@ static int s3c24xx_spi_setupxfer(struct spi_device *spi, /* 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;