This commit was manufactured by cvs2svn to create branch 'vserver'.
[linux-2.6.git] / arch / m32r / lib / csum_partial_copy.c
1 /*
2  * INET         An implementation of the TCP/IP protocol suite for the LINUX
3  *              operating system.  INET is implemented using the  BSD Socket
4  *              interface as the means of communication with the user level.
5  *
6  *              MIPS specific IP/TCP/UDP checksumming routines
7  *
8  * Authors:     Ralf Baechle, <ralf@waldorf-gmbh.de>
9  *              Lots of code moved from tcp.c and ip.c; see those files
10  *              for more names.
11  *
12  *              This program is free software; you can redistribute it and/or
13  *              modify it under the terms of the GNU General Public License
14  *              as published by the Free Software Foundation; either version
15  *              2 of the License, or (at your option) any later version.
16  *
17  */
18
19 #include <linux/module.h>
20 #include <linux/types.h>
21
22 #include <net/checksum.h>
23 #include <asm/byteorder.h>
24 #include <asm/string.h>
25 #include <asm/uaccess.h>
26
27 /*
28  * Copy while checksumming, otherwise like csum_partial
29  */
30 unsigned int csum_partial_copy_nocheck (const char *src, char *dst,
31                                         int len, unsigned int sum)
32 {
33         sum = csum_partial(src, len, sum);
34         memcpy(dst, src, len);
35
36         return sum;
37 }
38 EXPORT_SYMBOL(csum_partial_copy_nocheck);
39
40 /*
41  * Copy from userspace and compute checksum.  If we catch an exception
42  * then zero the rest of the buffer.
43  */
44 unsigned int csum_partial_copy_from_user (const char __user *src, char *dst,
45                                           int len, unsigned int sum,
46                                           int *err_ptr)
47 {
48         int missing;
49
50         missing = copy_from_user(dst, src, len);
51         if (missing) {
52                 memset(dst + len - missing, 0, missing);
53                 *err_ptr = -EFAULT;
54         }
55
56         return csum_partial(dst, len-missing, sum);
57 }
58 EXPORT_SYMBOL(csum_partial_copy_from_user);