treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 294
[linux-block.git] / arch / powerpc / lib / pmem.c
CommitLineData
32ce3862
OH
1/*
2 * Copyright(c) 2017 IBM Corporation. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of version 2 of the GNU General Public License as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
12 */
13
14#include <linux/string.h>
15#include <linux/export.h>
6c44741d 16#include <linux/uaccess.h>
32ce3862
OH
17
18#include <asm/cacheflush.h>
19
20/*
21 * CONFIG_ARCH_HAS_PMEM_API symbols
22 */
23void arch_wb_cache_pmem(void *addr, size_t size)
24{
25 unsigned long start = (unsigned long) addr;
26 flush_inval_dcache_range(start, start + size);
27}
28EXPORT_SYMBOL(arch_wb_cache_pmem);
29
30void arch_invalidate_pmem(void *addr, size_t size)
31{
32 unsigned long start = (unsigned long) addr;
33 flush_inval_dcache_range(start, start + size);
34}
35EXPORT_SYMBOL(arch_invalidate_pmem);
6c44741d
OH
36
37/*
38 * CONFIG_ARCH_HAS_UACCESS_FLUSHCACHE symbols
39 */
40long __copy_from_user_flushcache(void *dest, const void __user *src,
41 unsigned size)
42{
43 unsigned long copied, start = (unsigned long) dest;
44
45 copied = __copy_from_user(dest, src, size);
46 flush_inval_dcache_range(start, start + size);
47
48 return copied;
49}
50
51void *memcpy_flushcache(void *dest, const void *src, size_t size)
52{
53 unsigned long start = (unsigned long) dest;
54
55 memcpy(dest, src, size);
56 flush_inval_dcache_range(start, start + size);
57
58 return dest;
59}
60EXPORT_SYMBOL(memcpy_flushcache);
61
62void memcpy_page_flushcache(char *to, struct page *page, size_t offset,
63 size_t len)
64{
65 memcpy_flushcache(to, page_to_virt(page) + offset, len);
66}
67EXPORT_SYMBOL(memcpy_page_flushcache);