Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

fbdev: Remove default file-I/O implementations

Drop the default implementations for file read, write and mmap
operations. Each fbdev driver must now provide an implementation
and select any necessary helpers. If no implementation has been
set, fbdev returns an errno code to user space. The code is the
same as if the operation had not been set in the file_operations
struct.

This change makes the fbdev helpers for I/O memory optional. Most
systems only use system-memory framebuffers via DRM's fbdev emulation.

v2:
* warn once if I/O callbacks are missing (Javier)

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20231127131655.4020-33-tzimmermann@suse.de

+17 -26
-1
drivers/video/fbdev/core/Kconfig
··· 4 4 # 5 5 6 6 config FB_CORE 7 - select FB_IOMEM_FOPS 8 7 select VIDEO_CMDLINE 9 8 tristate 10 9
+12 -25
drivers/video/fbdev/core/fb_chrdev.c
··· 34 34 if (!info) 35 35 return -ENODEV; 36 36 37 + if (fb_WARN_ON_ONCE(info, !info->fbops->fb_read)) 38 + return -EINVAL; 39 + 37 40 if (info->state != FBINFO_STATE_RUNNING) 38 41 return -EPERM; 39 42 40 - if (info->fbops->fb_read) 41 - return info->fbops->fb_read(info, buf, count, ppos); 42 - 43 - return fb_io_read(info, buf, count, ppos); 43 + return info->fbops->fb_read(info, buf, count, ppos); 44 44 } 45 45 46 46 static ssize_t fb_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) ··· 50 50 if (!info) 51 51 return -ENODEV; 52 52 53 + if (fb_WARN_ON_ONCE(info, !info->fbops->fb_write)) 54 + return -EINVAL; 55 + 53 56 if (info->state != FBINFO_STATE_RUNNING) 54 57 return -EPERM; 55 58 56 - if (info->fbops->fb_write) 57 - return info->fbops->fb_write(info, buf, count, ppos); 58 - 59 - return fb_io_write(info, buf, count, ppos); 59 + return info->fbops->fb_write(info, buf, count, ppos); 60 60 } 61 61 62 62 static long do_fb_ioctl(struct fb_info *info, unsigned int cmd, ··· 319 319 if (!info) 320 320 return -ENODEV; 321 321 322 + if (fb_WARN_ON_ONCE(info, !info->fbops->fb_mmap)) 323 + return -ENODEV; 324 + 322 325 mutex_lock(&info->mm_lock); 323 - 324 - if (info->fbops->fb_mmap) { 325 - 326 - res = info->fbops->fb_mmap(info, vma); 327 - #if IS_ENABLED(CONFIG_FB_DEFERRED_IO) 328 - } else if (info->fbdefio) { 329 - /* 330 - * FB deferred I/O wants you to handle mmap in your drivers. At a 331 - * minimum, point struct fb_ops.fb_mmap to fb_deferred_io_mmap(). 332 - */ 333 - dev_warn_once(info->dev, "fbdev mmap not set up for deferred I/O.\n"); 334 - res = -ENODEV; 335 - #endif 336 - } else { 337 - res = fb_io_mmap(info, vma); 338 - } 339 - 326 + res = info->fbops->fb_mmap(info, vma); 340 327 mutex_unlock(&info->mm_lock); 341 328 342 329 return res;
+5
include/linux/fb.h
··· 867 867 #define fb_warn_once(fb_info, fmt, ...) \ 868 868 pr_warn_once("fb%d: " fmt, (fb_info)->node, ##__VA_ARGS__) 869 869 870 + #define fb_WARN_ONCE(fb_info, condition, fmt, ...) \ 871 + WARN_ONCE(condition, "fb%d: " fmt, (fb_info)->node, ##__VA_ARGS__) 872 + #define fb_WARN_ON_ONCE(fb_info, x) \ 873 + fb_WARN_ONCE(fb_info, (x), "%s", "fb_WARN_ON_ONCE(" __stringify(x) ")") 874 + 870 875 #endif /* _LINUX_FB_H */