1*4882a593Smuzhiyun // SPDX-License-Identifier: GPL-2.0 2*4882a593Smuzhiyun // Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd. 3*4882a593Smuzhiyun 4*4882a593Smuzhiyun #include <linux/export.h> 5*4882a593Smuzhiyun #include <linux/mm.h> 6*4882a593Smuzhiyun #include <linux/io.h> 7*4882a593Smuzhiyun phys_mem_access_prot(struct file * file,unsigned long pfn,unsigned long size,pgprot_t vma_prot)8*4882a593Smuzhiyunpgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn, 9*4882a593Smuzhiyun unsigned long size, pgprot_t vma_prot) 10*4882a593Smuzhiyun { 11*4882a593Smuzhiyun if (!pfn_valid(pfn)) { 12*4882a593Smuzhiyun return pgprot_noncached(vma_prot); 13*4882a593Smuzhiyun } else if (file->f_flags & O_SYNC) { 14*4882a593Smuzhiyun return pgprot_writecombine(vma_prot); 15*4882a593Smuzhiyun } 16*4882a593Smuzhiyun 17*4882a593Smuzhiyun return vma_prot; 18*4882a593Smuzhiyun } 19*4882a593Smuzhiyun EXPORT_SYMBOL(phys_mem_access_prot); 20