Commit | Line | Data |
---|---|---|
1a59d1b8 | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
fdd374b6 | 2 | /* |
fdd374b6 AB |
3 | * |
4 | * Copyright (C) IBM Corporation, 2010 | |
5 | * | |
6 | * Author: Anton Blanchard <anton@au.ibm.com> | |
7 | */ | |
4b16f8e2 | 8 | #include <linux/export.h> |
fdd374b6 AB |
9 | #include <linux/compiler.h> |
10 | #include <linux/types.h> | |
11 | #include <asm/checksum.h> | |
7c0f6ba6 | 12 | #include <linux/uaccess.h> |
fdd374b6 AB |
13 | |
14 | __wsum csum_and_copy_from_user(const void __user *src, void *dst, | |
c693cc46 | 15 | int len) |
fdd374b6 | 16 | { |
70d65cd5 | 17 | __wsum csum; |
fdd374b6 | 18 | |
164dc6ce | 19 | if (unlikely(!user_read_access_begin(src, len))) |
c693cc46 | 20 | return 0; |
fdd374b6 | 21 | |
70d65cd5 | 22 | csum = csum_partial_copy_generic((void __force *)src, dst, len); |
fdd374b6 | 23 | |
164dc6ce | 24 | user_read_access_end(); |
70d65cd5 | 25 | return csum; |
fdd374b6 | 26 | } |
8c773914 | 27 | |
c693cc46 | 28 | __wsum csum_and_copy_to_user(const void *src, void __user *dst, int len) |
8c773914 | 29 | { |
70d65cd5 | 30 | __wsum csum; |
8c773914 | 31 | |
164dc6ce | 32 | if (unlikely(!user_write_access_begin(dst, len))) |
c693cc46 | 33 | return 0; |
8c773914 | 34 | |
70d65cd5 | 35 | csum = csum_partial_copy_generic(src, (void __force *)dst, len); |
8c773914 | 36 | |
164dc6ce | 37 | user_write_access_end(); |
70d65cd5 | 38 | return csum; |
8c773914 | 39 | } |