Skip to content

Commit 8813e86

Browse files
author
Thomas Zimmermann
committed
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 <[email protected]> Reviewed-by: Javier Martinez Canillas <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent b3e8813 commit 8813e86

File tree

3 files changed

+17
-26
lines changed

3 files changed

+17
-26
lines changed

drivers/video/fbdev/core/Kconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#
55

66
config FB_CORE
7-
select FB_IOMEM_FOPS
87
select VIDEO_CMDLINE
98
tristate
109

drivers/video/fbdev/core/fb_chrdev.c

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ static ssize_t fb_read(struct file *file, char __user *buf, size_t count, loff_t
3434
if (!info)
3535
return -ENODEV;
3636

37+
if (fb_WARN_ON_ONCE(info, !info->fbops->fb_read))
38+
return -EINVAL;
39+
3740
if (info->state != FBINFO_STATE_RUNNING)
3841
return -EPERM;
3942

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);
4444
}
4545

4646
static ssize_t fb_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
@@ -50,13 +50,13 @@ static ssize_t fb_write(struct file *file, const char __user *buf, size_t count,
5050
if (!info)
5151
return -ENODEV;
5252

53+
if (fb_WARN_ON_ONCE(info, !info->fbops->fb_write))
54+
return -EINVAL;
55+
5356
if (info->state != FBINFO_STATE_RUNNING)
5457
return -EPERM;
5558

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);
6060
}
6161

6262
static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
@@ -319,24 +319,11 @@ static int fb_mmap(struct file *file, struct vm_area_struct *vma)
319319
if (!info)
320320
return -ENODEV;
321321

322-
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-
}
322+
if (fb_WARN_ON_ONCE(info, !info->fbops->fb_mmap))
323+
return -ENODEV;
339324

325+
mutex_lock(&info->mm_lock);
326+
res = info->fbops->fb_mmap(info, vma);
340327
mutex_unlock(&info->mm_lock);
341328

342329
return res;

include/linux/fb.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -867,4 +867,9 @@ static inline bool fb_modesetting_disabled(const char *drvname)
867867
#define fb_warn_once(fb_info, fmt, ...) \
868868
pr_warn_once("fb%d: " fmt, (fb_info)->node, ##__VA_ARGS__)
869869

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+
870875
#endif /* _LINUX_FB_H */

0 commit comments

Comments
 (0)