blob: 70c8268d3b2bdda6dac53cbcbf66d731ff51716f [file] [log] [blame]
Guo Ren013de2d2018-09-05 14:25:12 +08001// SPDX-License-Identifier: GPL-2.0
2// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
3
4#include <linux/export.h>
5#include <linux/mm.h>
Guo Ren013de2d2018-09-05 14:25:12 +08006#include <linux/io.h>
7
Guo Ren76d21d12019-01-30 20:13:11 +08008pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn,
9 unsigned long size, pgprot_t vma_prot)
10{
11 if (!pfn_valid(pfn)) {
Guo Ren76d21d12019-01-30 20:13:11 +080012 return pgprot_noncached(vma_prot);
13 } else if (file->f_flags & O_SYNC) {
Guo Ren7f80fe22019-07-30 14:43:22 +080014 return pgprot_writecombine(vma_prot);
Guo Ren76d21d12019-01-30 20:13:11 +080015 }
16
17 return vma_prot;
18}
19EXPORT_SYMBOL(phys_mem_access_prot);