Path: blob/master/arch/m32r/lib/csum_partial_copy.c
10817 views
/*1* INET An implementation of the TCP/IP protocol suite for the LINUX2* operating system. INET is implemented using the BSD Socket3* interface as the means of communication with the user level.4*5* M32R specific IP/TCP/UDP checksumming routines6* (Some code taken from MIPS architecture)7*8* This file is subject to the terms and conditions of the GNU General Public9* License. See the file "COPYING" in the main directory of this archive10* for more details.11*12* Copyright (C) 1994, 1995 Waldorf Electronics GmbH13* Copyright (C) 1998, 1999 Ralf Baechle14* Copyright (C) 2001-2005 Hiroyuki Kondo, Hirokazu Takata15*16*/1718#include <linux/module.h>19#include <linux/types.h>20#include <linux/string.h>2122#include <net/checksum.h>23#include <asm/byteorder.h>24#include <asm/uaccess.h>2526/*27* Copy while checksumming, otherwise like csum_partial28*/29__wsum30csum_partial_copy_nocheck (const void *src, void *dst, int len, __wsum sum)31{32sum = csum_partial(src, len, sum);33memcpy(dst, src, len);3435return sum;36}37EXPORT_SYMBOL(csum_partial_copy_nocheck);3839/*40* Copy from userspace and compute checksum. If we catch an exception41* then zero the rest of the buffer.42*/43__wsum44csum_partial_copy_from_user (const void __user *src, void *dst,45int len, __wsum sum, int *err_ptr)46{47int missing;4849missing = copy_from_user(dst, src, len);50if (missing) {51memset(dst + len - missing, 0, missing);52*err_ptr = -EFAULT;53}5455return csum_partial(dst, len-missing, sum);56}57EXPORT_SYMBOL(csum_partial_copy_from_user);58EXPORT_SYMBOL(csum_partial);596061