[NET]: IA64 checksum annotations and cleanups.

* sanitize prototypes, annotate
* ntohs -> shift in checksum calculations
* kill access_ok() in csum_partial_copy_from_user
* collapse do_csum_partial_copy_from_user

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Al Viro
2006-11-14 21:16:30 -08:00
committed by David S. Miller
parent db521083bc
commit 322529961e
3 changed files with 41 additions and 59 deletions

View File

@@ -104,9 +104,9 @@ out:
*/
extern unsigned long do_csum(const unsigned char *, long);
static unsigned int
do_csum_partial_copy_from_user (const unsigned char __user *src, unsigned char *dst,
int len, unsigned int psum, int *errp)
__wsum
csum_partial_copy_from_user(const void __user *src, void *dst,
int len, __wsum psum, int *errp)
{
unsigned long result;
@@ -122,30 +122,17 @@ do_csum_partial_copy_from_user (const unsigned char __user *src, unsigned char *
result = do_csum(dst, len);
/* add in old sum, and carry.. */
result += psum;
result += (__force u32)psum;
/* 32+c bits -> 32 bits */
result = (result & 0xffffffff) + (result >> 32);
return result;
return (__force __wsum)result;
}
unsigned int
csum_partial_copy_from_user (const unsigned char __user *src, unsigned char *dst,
int len, unsigned int sum, int *errp)
__wsum
csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum)
{
if (!access_ok(VERIFY_READ, src, len)) {
*errp = -EFAULT;
memset(dst, 0, len);
return sum;
}
return do_csum_partial_copy_from_user(src, dst, len, sum, errp);
}
unsigned int
csum_partial_copy_nocheck(const unsigned char __user *src, unsigned char *dst,
int len, unsigned int sum)
{
return do_csum_partial_copy_from_user(src, dst, len, sum, NULL);
return csum_partial_copy_from_user((__force const void __user *)src,
dst, len, sum, NULL);
}
EXPORT_SYMBOL(csum_partial_copy_nocheck);