Skip to content

Commit 052ddf7

Browse files
author
Thomas Zimmermann
committed
fbdev: Replace fb_pgprotect() with pgprot_framebuffer()
Rename the fbdev mmap helper fb_pgprotect() to pgprot_framebuffer(). The helper sets VMA page-access flags for framebuffers in device I/O memory. Also clean up the helper's parameters and return value. Instead of the VMA instance, pass the individial parameters separately: existing page-access flags, the VMAs start and end addresses and the offset in the underlying device memory rsp file. Return the new page-access flags. These changes align pgprot_framebuffer() with other pgprot_() functions. v4: * fix commit message (Christophe) v3: * rename fb_pgprotect() to pgprot_framebuffer() (Arnd) Signed-off-by: Thomas Zimmermann <[email protected]> Reviewed-by: Arnd Bergmann <[email protected]> Acked-by: Geert Uytterhoeven <[email protected]> # m68k Reviewed-by: Javier Martinez Canillas <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent c205a67 commit 052ddf7

File tree

9 files changed

+58
-55
lines changed

9 files changed

+58
-55
lines changed

arch/ia64/include/asm/fb.h

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,16 @@
88

99
#include <asm/page.h>
1010

11-
struct file;
12-
13-
static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
14-
unsigned long off)
11+
static inline pgprot_t pgprot_framebuffer(pgprot_t prot,
12+
unsigned long vm_start, unsigned long vm_end,
13+
unsigned long offset)
1514
{
16-
if (efi_range_is_wc(vma->vm_start, vma->vm_end - vma->vm_start))
17-
vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
15+
if (efi_range_is_wc(vm_start, vm_end - vm_start))
16+
return pgprot_writecombine(prot);
1817
else
19-
vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
18+
return pgprot_noncached(prot);
2019
}
21-
#define fb_pgprotect fb_pgprotect
20+
#define pgprot_framebuffer pgprot_framebuffer
2221

2322
static inline void fb_memcpy_fromio(void *to, const volatile void __iomem *from, size_t n)
2423
{

arch/m68k/include/asm/fb.h

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,27 @@
55
#include <asm/page.h>
66
#include <asm/setup.h>
77

8-
struct file;
9-
10-
static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
11-
unsigned long off)
8+
static inline pgprot_t pgprot_framebuffer(pgprot_t prot,
9+
unsigned long vm_start, unsigned long vm_end,
10+
unsigned long offset)
1211
{
1312
#ifdef CONFIG_MMU
1413
#ifdef CONFIG_SUN3
15-
pgprot_val(vma->vm_page_prot) |= SUN3_PAGE_NOCACHE;
14+
pgprot_val(prot) |= SUN3_PAGE_NOCACHE;
1615
#else
1716
if (CPU_IS_020_OR_030)
18-
pgprot_val(vma->vm_page_prot) |= _PAGE_NOCACHE030;
17+
pgprot_val(prot) |= _PAGE_NOCACHE030;
1918
if (CPU_IS_040_OR_060) {
20-
pgprot_val(vma->vm_page_prot) &= _CACHEMASK040;
19+
pgprot_val(prot) &= _CACHEMASK040;
2120
/* Use no-cache mode, serialized */
22-
pgprot_val(vma->vm_page_prot) |= _PAGE_NOCACHE_S;
21+
pgprot_val(prot) |= _PAGE_NOCACHE_S;
2322
}
2423
#endif /* CONFIG_SUN3 */
2524
#endif /* CONFIG_MMU */
25+
26+
return prot;
2627
}
27-
#define fb_pgprotect fb_pgprotect
28+
#define pgprot_framebuffer pgprot_framebuffer
2829

2930
#include <asm-generic/fb.h>
3031

arch/mips/include/asm/fb.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@
33

44
#include <asm/page.h>
55

6-
struct file;
7-
8-
static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
9-
unsigned long off)
6+
static inline pgprot_t pgprot_framebuffer(pgprot_t prot,
7+
unsigned long vm_start, unsigned long vm_end,
8+
unsigned long offset)
109
{
11-
vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
10+
return pgprot_noncached(prot);
1211
}
13-
#define fb_pgprotect fb_pgprotect
12+
#define pgprot_framebuffer pgprot_framebuffer
1413

1514
/*
1615
* MIPS doesn't define __raw_ I/O macros, so the helpers

arch/powerpc/include/asm/fb.h

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,20 @@
22
#ifndef _ASM_FB_H_
33
#define _ASM_FB_H_
44

5-
#include <linux/fs.h>
6-
75
#include <asm/page.h>
86

9-
static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
10-
unsigned long off)
7+
static inline pgprot_t pgprot_framebuffer(pgprot_t prot,
8+
unsigned long vm_start, unsigned long vm_end,
9+
unsigned long offset)
1110
{
1211
/*
1312
* PowerPC's implementation of phys_mem_access_prot() does
1413
* not use the file argument. Set it to NULL in preparation
1514
* of later updates to the interface.
1615
*/
17-
vma->vm_page_prot = phys_mem_access_prot(NULL, PHYS_PFN(off),
18-
vma->vm_end - vma->vm_start,
19-
vma->vm_page_prot);
16+
return phys_mem_access_prot(NULL, PHYS_PFN(offset), vm_end - vm_start, prot);
2017
}
21-
#define fb_pgprotect fb_pgprotect
18+
#define pgprot_framebuffer pgprot_framebuffer
2219

2320
#include <asm-generic/fb.h>
2421

arch/sparc/include/asm/fb.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,18 @@
44

55
#include <linux/io.h>
66

7+
#include <asm/page.h>
8+
79
struct fb_info;
8-
struct file;
9-
struct vm_area_struct;
1010

1111
#ifdef CONFIG_SPARC32
12-
static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
13-
unsigned long off)
14-
{ }
15-
#define fb_pgprotect fb_pgprotect
12+
static inline pgprot_t pgprot_framebuffer(pgprot_t prot,
13+
unsigned long vm_start, unsigned long vm_end,
14+
unsigned long offset)
15+
{
16+
return prot;
17+
}
18+
#define pgprot_framebuffer pgprot_framebuffer
1619
#endif
1720

1821
int fb_is_primary_device(struct fb_info *info);

arch/x86/include/asm/fb.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22
#ifndef _ASM_X86_FB_H
33
#define _ASM_X86_FB_H
44

5+
#include <asm/page.h>
6+
57
struct fb_info;
6-
struct file;
7-
struct vm_area_struct;
88

9-
void fb_pgprotect(struct file *file, struct vm_area_struct *vma, unsigned long off);
10-
#define fb_pgprotect fb_pgprotect
9+
pgprot_t pgprot_framebuffer(pgprot_t prot,
10+
unsigned long vm_start, unsigned long vm_end,
11+
unsigned long offset);
12+
#define pgprot_framebuffer pgprot_framebuffer
1113

1214
int fb_is_primary_device(struct fb_info *info);
1315
#define fb_is_primary_device fb_is_primary_device

arch/x86/video/fbdev.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,17 @@
1313
#include <linux/vgaarb.h>
1414
#include <asm/fb.h>
1515

16-
void fb_pgprotect(struct file *file, struct vm_area_struct *vma, unsigned long off)
16+
pgprot_t pgprot_framebuffer(pgprot_t prot,
17+
unsigned long vm_start, unsigned long vm_end,
18+
unsigned long offset)
1719
{
18-
unsigned long prot;
19-
20-
prot = pgprot_val(vma->vm_page_prot) & ~_PAGE_CACHE_MASK;
20+
pgprot_val(prot) &= ~_PAGE_CACHE_MASK;
2121
if (boot_cpu_data.x86 > 3)
22-
pgprot_val(vma->vm_page_prot) =
23-
prot | cachemode2protval(_PAGE_CACHE_MODE_UC_MINUS);
22+
pgprot_val(prot) |= cachemode2protval(_PAGE_CACHE_MODE_UC_MINUS);
23+
24+
return prot;
2425
}
25-
EXPORT_SYMBOL(fb_pgprotect);
26+
EXPORT_SYMBOL(pgprot_framebuffer);
2627

2728
int fb_is_primary_device(struct fb_info *info)
2829
{

drivers/video/fbdev/core/fb_chrdev.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,8 @@ static int fb_mmap(struct file *file, struct vm_area_struct *vma)
365365
mutex_unlock(&info->mm_lock);
366366

367367
vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
368-
fb_pgprotect(file, vma, start);
368+
vma->vm_page_prot = pgprot_framebuffer(vma->vm_page_prot, vma->vm_start,
369+
vma->vm_end, start);
369370

370371
return vm_iomap_memory(vma, start, len);
371372
}

include/asm-generic/fb.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212
#include <linux/pgtable.h>
1313

1414
struct fb_info;
15-
struct file;
1615

17-
#ifndef fb_pgprotect
18-
#define fb_pgprotect fb_pgprotect
19-
static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
20-
unsigned long off)
16+
#ifndef pgprot_framebuffer
17+
#define pgprot_framebuffer pgprot_framebuffer
18+
static inline pgprot_t pgprot_framebuffer(pgprot_t prot,
19+
unsigned long vm_start, unsigned long vm_end,
20+
unsigned long offset)
2121
{
22-
vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
22+
return pgprot_writecombine(prot);
2323
}
2424
#endif
2525

0 commit comments

Comments
 (0)