diff options
author | Uwe Kleine-König <u.kleine-koenig@pengutronix.de> | 2013-11-18 11:40:16 +0100 |
---|---|---|
committer | Uwe Kleine-König <u.kleine-koenig@pengutronix.de> | 2014-10-05 10:29:42 +0200 |
commit | 8d0977811d6741b8600886736712387aa8c434a9 (patch) | |
tree | 174a58198e45be7086422790e5fb39e406284d95 | |
parent | 81c7e84f08e2fcf7c9464359240430122a8be924 (diff) | |
download | linux-8d0977811d6741b8600886736712387aa8c434a9.tar.gz linux-8d0977811d6741b8600886736712387aa8c434a9.tar.xz |
RFC: framebuffer: provide generic get_fb_unmapped_area
This patch makes mmapping the simple-framebuffer device work on a no-MMU
ARM target. The code is mostly taken from
arch/blackfin/kernel/sys_bfin.c.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
Note this is only tested on this no-MMU machine and I don't know enough
about framebuffers and mm to decide if this patch is sane. Also I'm
a bit unsure about the size check, I just believed Geert that
PAGE_ALIGN(info->fix.smem_len) is the right value to check against.
-rw-r--r-- | drivers/video/fbdev/core/fbmem.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c index b5e85f6c1c26..7e09f8bc36ac 100644 --- a/drivers/video/fbdev/core/fbmem.c +++ b/drivers/video/fbdev/core/fbmem.c @@ -1492,6 +1492,22 @@ __releases(&info->lock) return 0; } +#ifdef HAVE_ARCH_FB_UNMAPPED_AREA +#define fb_get_unmapped_area get_fb_unmapped_area +#else +unsigned long fb_get_unmapped_area(struct file *filp, unsigned long orig_addr, + unsigned long len, unsigned long pgoff, unsigned long flags) +{ + struct fb_info * const info = filp->private_data; + unsigned long fb_size = PAGE_ALIGN(info->fix.smem_len); + + if (pgoff > fb_size || len > fb_size - pgoff) + return -EINVAL; + + return (unsigned long)info->screen_base + pgoff; +} +#endif + static const struct file_operations fb_fops = { .owner = THIS_MODULE, .read = fb_read, @@ -1503,9 +1519,7 @@ static const struct file_operations fb_fops = { .mmap = fb_mmap, .open = fb_open, .release = fb_release, -#ifdef HAVE_ARCH_FB_UNMAPPED_AREA - .get_unmapped_area = get_fb_unmapped_area, -#endif + .get_unmapped_area = fb_get_unmapped_area, #ifdef CONFIG_FB_DEFERRED_IO .fsync = fb_deferred_io_fsync, #endif |