]>
Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
3fb50075 AV |
2 | #ifndef _ASM_UACCESS_H |
3 | #define _ASM_UACCESS_H | |
4 | ||
5 | #include <linux/string.h> | |
6 | ||
33ab2da8 AV |
7 | static inline __must_check unsigned long |
8 | raw_copy_from_user(void *to, const void __user * from, unsigned long n) | |
3fb50075 AV |
9 | { |
10 | if (__builtin_constant_p(n)) { | |
11 | switch(n) { | |
12 | case 1: | |
13 | *(u8 *)to = *(u8 __force *)from; | |
14 | return 0; | |
15 | case 2: | |
16 | *(u16 *)to = *(u16 __force *)from; | |
17 | return 0; | |
18 | case 4: | |
19 | *(u32 *)to = *(u32 __force *)from; | |
20 | return 0; | |
21 | } | |
22 | } | |
23 | ||
24 | memcpy(to, (const void __force *)from, n); | |
25 | return 0; | |
26 | } | |
27 | ||
33ab2da8 AV |
28 | static inline __must_check unsigned long |
29 | raw_copy_to_user(void __user *to, const void *from, unsigned long n) | |
3fb50075 AV |
30 | { |
31 | if (__builtin_constant_p(n)) { | |
32 | switch(n) { | |
33 | case 1: | |
34 | *(u8 __force *)to = *(u8 *)from; | |
35 | return 0; | |
36 | case 2: | |
37 | *(u16 __force *)to = *(u16 *)from; | |
38 | return 0; | |
39 | case 4: | |
40 | *(u32 __force *)to = *(u32 *)from; | |
41 | return 0; | |
42 | default: | |
43 | break; | |
44 | } | |
45 | } | |
46 | ||
47 | memcpy((void __force *)to, from, n); | |
48 | return 0; | |
49 | } | |
33ab2da8 AV |
50 | #define INLINE_COPY_FROM_USER |
51 | #define INLINE_COPY_TO_USER | |
3fb50075 AV |
52 | |
53 | #include <asm-generic/uaccess.h> | |
54 | ||
55 | #endif |