* Christoph Hellwig <hch@xxxxxx> wrote: > follow_phys is only used by two allers in arch/x86/mm/pat/memtype.c. > Move it there and hardcode the two arguments that get the same values > passed by both caller. s/aller /caller s/both caller. /both callers. > > Signed-off-by: Christoph Hellwig <hch@xxxxxx> > --- > arch/x86/mm/pat/memtype.c | 22 ++++++++++++++++++++-- > include/linux/mm.h | 2 -- > mm/memory.c | 28 ---------------------------- > 3 files changed, 20 insertions(+), 32 deletions(-) > > diff --git a/arch/x86/mm/pat/memtype.c b/arch/x86/mm/pat/memtype.c > index 0d72183b5dd028..bad99eb5c95b0d 100644 > --- a/arch/x86/mm/pat/memtype.c > +++ b/arch/x86/mm/pat/memtype.c > @@ -947,6 +947,24 @@ static void free_pfn_range(u64 paddr, unsigned long size) > memtype_free(paddr, paddr + size); > } > > +static int follow_phys(struct vm_area_struct *vma, unsigned long *prot, > + resource_size_t *phys) > +{ > + pte_t *ptep, pte; > + spinlock_t *ptl; > + > + if (!(vma->vm_flags & (VM_IO | VM_PFNMAP))) > + return -EINVAL; > + > + if (follow_pte(vma->vm_mm, vma->vm_start, &ptep, &ptl)) > + return -EINVAL; > + pte = ptep_get(ptep); > + *prot = pgprot_val(pte_pgprot(pte)); > + *phys = (resource_size_t)pte_pfn(pte) << PAGE_SHIFT; > + pte_unmap_unlock(ptep, ptl); > + return 0; > +} Please keep the readability newlines as the original had, ie.: + if (follow_pte(vma->vm_mm, vma->vm_start, &ptep, &ptl)) + return -EINVAL; + + pte = ptep_get(ptep); + *prot = pgprot_val(pte_pgprot(pte)); + *phys = (resource_size_t)pte_pfn(pte) << PAGE_SHIFT; + pte_unmap_unlock(ptep, ptl); + + return 0; Thanks, Ingo