]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - arch/hexagon/mm/uaccess.c
Replace <asm/uaccess.h> with <linux/uaccess.h> globally
[mirror_ubuntu-bionic-kernel.git] / arch / hexagon / mm / uaccess.c
CommitLineData
7567746e 1/*
e1858b2a 2 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
7567746e
RK
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 and
6 * only version 2 as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16 * 02110-1301, USA.
17 */
18
19/*
20 * Support for user memory access from kernel. This will
21 * probably be inlined for performance at some point, but
22 * for ease of debug, and to a lesser degree for code size,
23 * we implement here as subroutines.
24 */
25#include <linux/types.h>
7c0f6ba6 26#include <linux/uaccess.h>
7567746e
RK
27#include <asm/pgtable.h>
28
29/*
30 * For clear_user(), exploit previously defined copy_to_user function
31 * and the fact that we've got a handy zero page defined in kernel/head.S
32 *
33 * dczero here would be even faster.
34 */
35__kernel_size_t __clear_user_hexagon(void __user *dest, unsigned long count)
36{
37 long uncleared;
38
39 while (count > PAGE_SIZE) {
40 uncleared = __copy_to_user_hexagon(dest, &empty_zero_page,
41 PAGE_SIZE);
42 if (uncleared)
43 return count - (PAGE_SIZE - uncleared);
44 count -= PAGE_SIZE;
45 dest += PAGE_SIZE;
46 }
47 if (count)
48 count = __copy_to_user_hexagon(dest, &empty_zero_page, count);
49
50 return count;
51}
52
53unsigned long clear_user_hexagon(void __user *dest, unsigned long count)
54{
55 if (!access_ok(VERIFY_WRITE, dest, count))
56 return count;
57 else
58 return __clear_user_hexagon(dest, count);
59}