Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <julia@diku.dk>
Signed-off-by: Matthew Wilcox <willy@linux.intel.com>
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Matthew Wilcox and committed by
Linus Torvalds
0d34aa4d 8eeb12e5

+3 -3
+3 -3
drivers/spi/spi_s3c24xx.c
··· 125 125 /* is clk = pclk / (2 * (pre+1)), or is it 126 126 * clk = (pclk * 2) / ( pre + 1) */ 127 127 128 - div = (div / 2) - 1; 128 + div /= 2; 129 129 130 - if (div < 0) 131 - div = 1; 130 + if (div > 0) 131 + div -= 1; 132 132 133 133 if (div > 255) 134 134 div = 255;