diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2009-12-11 20:57:31 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-12-11 20:57:31 -0800 |
commit | a1c36e52068a59374e127d60e4d8f4377072fc98 (patch) | |
tree | 1f17d2bc113286f60fc4922910fbd252e77326ba /lib | |
parent | 3070f27d6ecb69364e7cffe16c8b15e1b8ef41dd (diff) | |
parent | 3d7703870633dd454f6554e6d8d7f70441d0fd2d (diff) | |
download | op-kernel-dev-a1c36e52068a59374e127d60e4d8f4377072fc98.zip op-kernel-dev-a1c36e52068a59374e127d60e4d8f4377072fc98.tar.gz |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/arnd/asm-generic
* git://git.kernel.org/pub/scm/linux/kernel/git/arnd/asm-generic:
asm-generic: add sys_recvmmsg to unistd.h
asm-generic: add sys_accept4 to unistd.h
asm-generic/gpio.h: add some forward decls of the device struct
asm-generic: Fix typo in asm-generic/unistd.h.
lib/checksum: fix one more thinko
lib/checksum.c: make do_csum optional
lib/checksum.c: use 32-bit arithmetic consistently
Diffstat (limited to 'lib')
-rw-r--r-- | lib/checksum.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/checksum.c b/lib/checksum.c index b2e2fd4..0975087 100644 --- a/lib/checksum.c +++ b/lib/checksum.c @@ -37,7 +37,8 @@ #include <asm/byteorder.h> -static inline unsigned short from32to16(unsigned long x) +#ifndef do_csum +static inline unsigned short from32to16(unsigned int x) { /* add up 16-bit and 16-bit for 16+c bit */ x = (x & 0xffff) + (x >> 16); @@ -49,16 +50,16 @@ static inline unsigned short from32to16(unsigned long x) static unsigned int do_csum(const unsigned char *buff, int len) { int odd, count; - unsigned long result = 0; + unsigned int result = 0; if (len <= 0) goto out; odd = 1 & (unsigned long) buff; if (odd) { #ifdef __LITTLE_ENDIAN - result = *buff; -#else result += (*buff << 8); +#else + result = *buff; #endif len--; buff++; @@ -73,9 +74,9 @@ static unsigned int do_csum(const unsigned char *buff, int len) } count >>= 1; /* nr of 32-bit words.. */ if (count) { - unsigned long carry = 0; + unsigned int carry = 0; do { - unsigned long w = *(unsigned int *) buff; + unsigned int w = *(unsigned int *) buff; count--; buff += 4; result += carry; @@ -102,6 +103,7 @@ static unsigned int do_csum(const unsigned char *buff, int len) out: return result; } +#endif /* * This is a version of ip_compute_csum() optimized for IP headers, |