summaryrefslogtreecommitdiffstats
path: root/arch/h8300/include/asm/uaccess.h
blob: c156a416a279ca31fbca4c0e1668781fecd38336 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#ifndef _ASM_UACCESS_H
#define _ASM_UACCESS_H

#include <linux/string.h>

static inline __must_check long __copy_from_user(void *to,
		const void __user * from, unsigned long n)
{
	if (__builtin_constant_p(n)) {
		switch(n) {
		case 1:
			*(u8 *)to = *(u8 __force *)from;
			return 0;
		case 2:
			*(u16 *)to = *(u16 __force *)from;
			return 0;
		case 4:
			*(u32 *)to = *(u32 __force *)from;
			return 0;
		}
	}

	memcpy(to, (const void __force *)from, n);
	return 0;
}

static inline __must_check long __copy_to_user(void __user *to,
		const void *from, unsigned long n)
{
	if (__builtin_constant_p(n)) {
		switch(n) {
		case 1:
			*(u8 __force *)to = *(u8 *)from;
			return 0;
		case 2:
			*(u16 __force *)to = *(u16 *)from;
			return 0;
		case 4:
			*(u32 __force *)to = *(u32 *)from;
			return 0;
		default:
			break;
		}
	}

	memcpy((void __force *)to, from, n);
	return 0;
}

#include <asm-generic/uaccess.h>

#endif
OpenPOWER on IntegriCloud