From: Thomas Zimmermann <tzimmermann@suse.de>
To: javierm@redhat.com, deller@gmx.de
Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org,
Thomas Zimmermann <tzimmermann@suse.de>
Subject: [PATCH v2 32/32] fbdev: Remove default file-I/O implementations
Date: Mon, 27 Nov 2023 14:16:01 +0100 [thread overview]
Message-ID: <20231127131655.4020-33-tzimmermann@suse.de> (raw)
In-Reply-To: <20231127131655.4020-1-tzimmermann@suse.de>
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>
---
drivers/video/fbdev/core/Kconfig | 1 -
drivers/video/fbdev/core/fb_chrdev.c | 37 +++++++++-------------------
include/linux/fb.h | 5 ++++
3 files changed, 17 insertions(+), 26 deletions(-)
diff --git a/drivers/video/fbdev/core/Kconfig b/drivers/video/fbdev/core/Kconfig
index faab5d50cac3c..21053bf00dc58 100644
--- a/drivers/video/fbdev/core/Kconfig
+++ b/drivers/video/fbdev/core/Kconfig
@@ -4,7 +4,6 @@
#
config FB_CORE
- select FB_IOMEM_FOPS
select VIDEO_CMDLINE
tristate
diff --git a/drivers/video/fbdev/core/fb_chrdev.c b/drivers/video/fbdev/core/fb_chrdev.c
index 089441c9d810f..4ebd16b7e3b8d 100644
--- a/drivers/video/fbdev/core/fb_chrdev.c
+++ b/drivers/video/fbdev/core/fb_chrdev.c
@@ -34,13 +34,13 @@ static ssize_t fb_read(struct file *file, char __user *buf, size_t count, loff_t
if (!info)
return -ENODEV;
+ if (fb_WARN_ON_ONCE(info, !info->fbops->fb_read))
+ return -EINVAL;
+
if (info->state != FBINFO_STATE_RUNNING)
return -EPERM;
- if (info->fbops->fb_read)
- return info->fbops->fb_read(info, buf, count, ppos);
-
- return fb_io_read(info, buf, count, ppos);
+ return info->fbops->fb_read(info, buf, count, ppos);
}
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,
if (!info)
return -ENODEV;
+ if (fb_WARN_ON_ONCE(info, !info->fbops->fb_write))
+ return -EINVAL;
+
if (info->state != FBINFO_STATE_RUNNING)
return -EPERM;
- if (info->fbops->fb_write)
- return info->fbops->fb_write(info, buf, count, ppos);
-
- return fb_io_write(info, buf, count, ppos);
+ return info->fbops->fb_write(info, buf, count, ppos);
}
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)
if (!info)
return -ENODEV;
- mutex_lock(&info->mm_lock);
-
- if (info->fbops->fb_mmap) {
-
- res = info->fbops->fb_mmap(info, vma);
-#if IS_ENABLED(CONFIG_FB_DEFERRED_IO)
- } else if (info->fbdefio) {
- /*
- * FB deferred I/O wants you to handle mmap in your drivers. At a
- * minimum, point struct fb_ops.fb_mmap to fb_deferred_io_mmap().
- */
- dev_warn_once(info->dev, "fbdev mmap not set up for deferred I/O.\n");
- res = -ENODEV;
-#endif
- } else {
- res = fb_io_mmap(info, vma);
- }
+ if (fb_WARN_ON_ONCE(info, !info->fbops->fb_mmap))
+ return -ENODEV;
+ mutex_lock(&info->mm_lock);
+ res = info->fbops->fb_mmap(info, vma);
mutex_unlock(&info->mm_lock);
return res;
diff --git a/include/linux/fb.h b/include/linux/fb.h
index 24f0ec3662352..05dc9624897df 100644
--- a/include/linux/fb.h
+++ b/include/linux/fb.h
@@ -867,4 +867,9 @@ static inline bool fb_modesetting_disabled(const char *drvname)
#define fb_warn_once(fb_info, fmt, ...) \
pr_warn_once("fb%d: " fmt, (fb_info)->node, ##__VA_ARGS__)
+#define fb_WARN_ONCE(fb_info, condition, fmt, ...) \
+ WARN_ONCE(condition, "fb%d: " fmt, (fb_info)->node, ##__VA_ARGS__)
+#define fb_WARN_ON_ONCE(fb_info, x) \
+ fb_WARN_ONCE(fb_info, (x), "%s", "fb_WARN_ON_ONCE(" __stringify(x) ")")
+
#endif /* _LINUX_FB_H */
--
2.43.0
prev parent reply other threads:[~2023-11-27 13:17 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-27 13:15 [PATCH v2 00/32] fbdev: Modularize helpers for struct fb_ops Thomas Zimmermann
2023-11-27 13:15 ` [PATCH v2 01/32] fbdev/acornfb: Fix name of fb_ops initializer macro Thomas Zimmermann
2023-11-27 13:15 ` [PATCH v2 02/32] fbdev/sm712fb: Use correct initializer macros for struct fb_ops Thomas Zimmermann
2023-11-27 13:15 ` [PATCH v2 03/32] fbdev/vfb: Set FBINFO_VIRTFB flag Thomas Zimmermann
2023-11-27 13:15 ` [PATCH v2 04/32] fbdev/vfb: Initialize fb_ops with fbdev macros Thomas Zimmermann
2023-11-27 13:15 ` [PATCH v2 05/32] fbdev/arcfb: Set FBINFO_VIRTFB flag Thomas Zimmermann
2023-11-27 13:15 ` [PATCH v2 06/32] fbdev/arcfb: Use generator macros for deferred I/O Thomas Zimmermann
2023-11-27 13:15 ` [PATCH v2 07/32] auxdisplay/cfag12864bfb: Set FBINFO_VIRTFB flag Thomas Zimmermann
2023-11-27 13:15 ` [PATCH v2 08/32] auxdisplay/cfag12864bfb: Initialize fb_ops with fbdev macros Thomas Zimmermann
2023-11-27 13:15 ` [PATCH v2 09/32] auxdisplay/ht16k33: Set FBINFO_VIRTFB flag Thomas Zimmermann
2023-11-27 13:15 ` [PATCH v2 10/32] auxdisplay/ht16k33: Initialize fb_ops with fbdev macros Thomas Zimmermann
2023-11-27 13:15 ` [PATCH v2 11/32] hid/picolcd_fb: Set FBINFO_VIRTFB flag Thomas Zimmermann
2023-11-27 13:15 ` [PATCH v2 12/32] fbdev/sh_mobile_lcdcfb: " Thomas Zimmermann
2023-11-27 13:15 ` [PATCH v2 13/32] fbdev/sh_mobile_lcdcfb: Initialize fb_ops with fbdev macros Thomas Zimmermann
2023-11-27 13:15 ` [PATCH v2 14/32] fbdev/smscufx: Select correct helpers Thomas Zimmermann
2023-11-27 13:15 ` [PATCH v2 15/32] fbdev/udlfb: " Thomas Zimmermann
2023-11-27 13:15 ` [PATCH v2 16/32] fbdev/au1200fb: Set FBINFO_VIRTFB flag Thomas Zimmermann
2023-11-27 13:15 ` [PATCH v2 17/32] fbdev/au1200fb: Initialize fb_ops with fbdev macros Thomas Zimmermann
2023-11-27 13:15 ` [PATCH v2 18/32] fbdev/ps3fb: Set FBINFO_VIRTFB flag Thomas Zimmermann
2023-11-27 13:15 ` [PATCH v2 19/32] fbdev/ps3fb: Initialize fb_ops with fbdev macros Thomas Zimmermann
2023-11-27 13:15 ` [PATCH v2 20/32] media/ivtvfb: Initialize fb_ops to fbdev I/O-memory helpers Thomas Zimmermann
2023-11-27 13:15 ` [PATCH v2 21/32] fbdev/clps711x-fb: Initialize fb_ops with fbdev macros Thomas Zimmermann
2023-11-27 13:15 ` [PATCH v2 22/32] fbdev/vt8500lcdfb: " Thomas Zimmermann
2023-11-27 13:15 ` [PATCH v2 23/32] fbdev/wm8505fb: Initialize fb_ops to fbdev I/O-memory helpers Thomas Zimmermann
2023-11-27 13:15 ` [PATCH v2 24/32] fbdev/cyber2000fb: Initialize fb_ops with fbdev macros Thomas Zimmermann
2023-11-27 13:15 ` [PATCH v2 25/32] staging/sm750fb: Declare fb_ops as constant Thomas Zimmermann
2023-11-27 13:29 ` Greg Kroah-Hartman
2023-11-27 13:15 ` [PATCH v2 26/32] staging/sm750fb: Initialize fb_ops with fbdev macros Thomas Zimmermann
2023-11-27 13:30 ` Greg Kroah-Hartman
2023-11-27 13:15 ` [PATCH v2 27/32] fbdev: Rename FB_SYS_FOPS token to FB_SYSMEM_FOPS Thomas Zimmermann
2023-11-27 13:15 ` [PATCH v2 28/32] fbdev: Remove trailing whitespaces Thomas Zimmermann
2023-11-27 13:15 ` [PATCH v2 29/32] fbdev: Push pgprot_decrypted() into mmap implementations Thomas Zimmermann
2023-11-27 13:15 ` [PATCH v2 30/32] fbdev: Move default fb_mmap code into helper function Thomas Zimmermann
2023-11-27 13:16 ` [PATCH v2 31/32] fbdev: Warn on incorrect framebuffer access Thomas Zimmermann
2023-11-27 13:16 ` Thomas Zimmermann [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231127131655.4020-33-tzimmermann@suse.de \
--to=tzimmermann@suse.de \
--cc=deller@gmx.de \
--cc=dri-devel@lists.freedesktop.org \
--cc=javierm@redhat.com \
--cc=linux-fbdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).