From f597c2089da4dd55133546b1255493579a295bff Mon Sep 17 00:00:00 2001 From: Thomas Zimmermann Date: Thu, 14 Nov 2019 13:51:06 +0100 Subject: fbdev: Unexport unlink_framebuffer() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There are no external callers of unlink_framebuffer() left. Make the function an internal interface. Signed-off-by: Thomas Zimmermann Reviewed-by: Noralf Trønnes Link: https://patchwork.freedesktop.org/patch/msgid/20191114125106.28347-4-tzimmermann@suse.de --- drivers/video/fbdev/core/fbmem.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/video/fbdev/core') diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c index 95c32952fa8a..86b06a599f96 100644 --- a/drivers/video/fbdev/core/fbmem.c +++ b/drivers/video/fbdev/core/fbmem.c @@ -1673,7 +1673,7 @@ static void unbind_console(struct fb_info *fb_info) console_unlock(); } -void unlink_framebuffer(struct fb_info *fb_info) +static void unlink_framebuffer(struct fb_info *fb_info) { int i; @@ -1692,7 +1692,6 @@ void unlink_framebuffer(struct fb_info *fb_info) fb_info->dev = NULL; } -EXPORT_SYMBOL(unlink_framebuffer); static void do_unregister_framebuffer(struct fb_info *fb_info) { -- cgit v1.2.3 From 12281c8dda5a3b47008bd6a6db6645995234b4e1 Mon Sep 17 00:00:00 2001 From: Jani Nikula Date: Fri, 29 Nov 2019 12:29:31 +0200 Subject: video: fb_defio: preserve user fb_ops MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Modifying fb_ops directly to override fb_mmap with fb_deferred_io_mmap and then resetting it to NULL afterwards causes problems all over the place. First, it prevents making the fbops member of struct fb_info a const pointer, which means we can't make struct fb_ops const anywhere. Second, a few places have to go out of their way to restore the original fb_mmap pointer that gets reset to NULL. Since the only user of the fbops->fb_mmap hook is fb_mmap() in fbmem.c, call fb_deferred_io_mmap() directly when deferred IO is enabled, and avoid modifying fb_ops altogether. Simply use info->fbdefio to determine whether deferred IO should be used or not. This should be accurate enough for all use cases, although perhaps not pedantically correct. v2: Simplify considerably by calling fb_deferred_io_mmap() directly (Daniel, Ville) Cc: Jaya Kumar Cc: linux-fbdev@vger.kernel.org Cc: Daniel Vetter Cc: Ville Syrjälä Acked-by: Noralf Trønnes Reviewed-by: Daniel Vetter Signed-off-by: Jani Nikula Link: https://patchwork.freedesktop.org/patch/msgid/022c82429da15d6450ff9ac1a897322ec3124db4.1575022735.git.jani.nikula@intel.com --- drivers/video/fbdev/core/fb_defio.c | 3 --- drivers/video/fbdev/core/fbmem.c | 15 +++++++++++---- 2 files changed, 11 insertions(+), 7 deletions(-) (limited to 'drivers/video/fbdev/core') diff --git a/drivers/video/fbdev/core/fb_defio.c b/drivers/video/fbdev/core/fb_defio.c index 82c20c6047b0..a591d291b231 100644 --- a/drivers/video/fbdev/core/fb_defio.c +++ b/drivers/video/fbdev/core/fb_defio.c @@ -171,7 +171,6 @@ int fb_deferred_io_mmap(struct fb_info *info, struct vm_area_struct *vma) vma->vm_private_data = info; return 0; } -EXPORT_SYMBOL(fb_deferred_io_mmap); /* workqueue callback */ static void fb_deferred_io_work(struct work_struct *work) @@ -206,7 +205,6 @@ void fb_deferred_io_init(struct fb_info *info) BUG_ON(!fbdefio); mutex_init(&fbdefio->lock); - info->fbops->fb_mmap = fb_deferred_io_mmap; INIT_DELAYED_WORK(&info->deferred_work, fb_deferred_io_work); INIT_LIST_HEAD(&fbdefio->pagelist); if (fbdefio->delay == 0) /* set a default of 1 s */ @@ -237,7 +235,6 @@ void fb_deferred_io_cleanup(struct fb_info *info) page->mapping = NULL; } - info->fbops->fb_mmap = NULL; mutex_destroy(&fbdefio->lock); } EXPORT_SYMBOL_GPL(fb_deferred_io_cleanup); diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c index 86b06a599f96..990550930a8e 100644 --- a/drivers/video/fbdev/core/fbmem.c +++ b/drivers/video/fbdev/core/fbmem.c @@ -1332,16 +1332,23 @@ static int fb_mmap(struct file *file, struct vm_area_struct * vma) { struct fb_info *info = file_fb_info(file); - struct fb_ops *fb; + int (*fb_mmap_fn)(struct fb_info *info, struct vm_area_struct *vma); unsigned long mmio_pgoff; unsigned long start; u32 len; if (!info) return -ENODEV; - fb = info->fbops; mutex_lock(&info->mm_lock); - if (fb->fb_mmap) { + + fb_mmap_fn = info->fbops->fb_mmap; + +#if IS_ENABLED(CONFIG_FB_DEFERRED_IO) + if (info->fbdefio) + fb_mmap_fn = fb_deferred_io_mmap; +#endif + + if (fb_mmap_fn) { int res; /* @@ -1349,7 +1356,7 @@ fb_mmap(struct file *file, struct vm_area_struct * vma) * SME protection is removed ahead of the call */ vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot); - res = fb->fb_mmap(info, vma); + res = fb_mmap_fn(info, vma); mutex_unlock(&info->mm_lock); return res; } -- cgit v1.2.3 From f23c57e290774cd4f721801061345d351b9b601f Mon Sep 17 00:00:00 2001 From: Jani Nikula Date: Fri, 29 Nov 2019 12:29:36 +0200 Subject: video: fbmem: use const pointer for fb_ops Use const for fb_ops to let us make the info->fbops pointer const in the future. v2: rebase Cc: linux-fbdev@vger.kernel.org Reviewed-by: Daniel Vetter Signed-off-by: Jani Nikula Link: https://patchwork.freedesktop.org/patch/msgid/3a27f95b424a67b3542b5906c660741daf1d4ea6.1575022735.git.jani.nikula@intel.com --- drivers/video/fbdev/core/fbmem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/video/fbdev/core') diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c index 990550930a8e..7ddeb90337bc 100644 --- a/drivers/video/fbdev/core/fbmem.c +++ b/drivers/video/fbdev/core/fbmem.c @@ -1079,7 +1079,7 @@ EXPORT_SYMBOL(fb_blank); static long do_fb_ioctl(struct fb_info *info, unsigned int cmd, unsigned long arg) { - struct fb_ops *fb; + const struct fb_ops *fb; struct fb_var_screeninfo var; struct fb_fix_screeninfo fix; struct fb_cmap cmap_from; @@ -1292,7 +1292,7 @@ static long fb_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { struct fb_info *info = file_fb_info(file); - struct fb_ops *fb; + const struct fb_ops *fb; long ret = -ENOIOCTLCMD; if (!info) -- cgit v1.2.3