Add dev_of_fbinfo() to return the framebuffer struct device when
CONFIG_FB_DEVICE is enabled, or NULL otherwise.
This allows fbdev drivers to use sysfs interfaces via runtime checks
instead of CONFIG_FB_DEVICE ifdefs, keeping the code clean while
remaining fully buildable.
Suggested-by: Helge Deller <deller@gmx.de>
Reviewed-by: Helge Deller <deller@gmx.de>
Reviewed-by: Andy Shevchenko <andy@kernel.org>
Signed-off-by: Chintan Patel <chintanlike@gmail.com>
---
include/linux/fb.h | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/include/linux/fb.h b/include/linux/fb.h
index 05cc251035da..dad3fb61a06a 100644
--- a/include/linux/fb.h
+++ b/include/linux/fb.h
@@ -628,6 +628,15 @@ static inline void unlock_fb_info(struct fb_info *info)
mutex_unlock(&info->lock);
}
+static inline struct device *dev_of_fbinfo(const struct fb_info *info)
+{
+#ifdef CONFIG_FB_DEVICE
+ return info->dev;
+#else
+ return NULL;
+#endif
+}
+
static inline void __fb_pad_aligned_buffer(u8 *dst, u32 d_pitch,
u8 *src, u32 s_pitch, u32 height)
{
--
2.43.0
On 1/7/26 05:42, Chintan Patel wrote: > Add dev_of_fbinfo() to return the framebuffer struct device when > CONFIG_FB_DEVICE is enabled, or NULL otherwise. > > This allows fbdev drivers to use sysfs interfaces via runtime checks > instead of CONFIG_FB_DEVICE ifdefs, keeping the code clean while > remaining fully buildable. > > Suggested-by: Helge Deller <deller@gmx.de> > Reviewed-by: Helge Deller <deller@gmx.de> > Reviewed-by: Andy Shevchenko <andy@kernel.org> > Signed-off-by: Chintan Patel <chintanlike@gmail.com> > --- > include/linux/fb.h | 9 +++++++++ > 1 file changed, 9 insertions(+) Whole v4 series applied to fbdev git tree. Thanks! Helge
On 1/11/26 10:50, Helge Deller wrote: > On 1/7/26 05:42, Chintan Patel wrote: >> Add dev_of_fbinfo() to return the framebuffer struct device when >> CONFIG_FB_DEVICE is enabled, or NULL otherwise. >> >> This allows fbdev drivers to use sysfs interfaces via runtime checks >> instead of CONFIG_FB_DEVICE ifdefs, keeping the code clean while >> remaining fully buildable. >> >> Suggested-by: Helge Deller <deller@gmx.de> >> Reviewed-by: Helge Deller <deller@gmx.de> >> Reviewed-by: Andy Shevchenko <andy@kernel.org> >> Signed-off-by: Chintan Patel <chintanlike@gmail.com> >> --- >> include/linux/fb.h | 9 +++++++++ >> 1 file changed, 9 insertions(+) > > Whole v4 series applied to fbdev git tree. > Appreciate Helge and everyone who reviewed it! This was my first kernel series and it was good learning experience for me.
Am 07.01.26 um 05:42 schrieb Chintan Patel:
> Add dev_of_fbinfo() to return the framebuffer struct device when
> CONFIG_FB_DEVICE is enabled, or NULL otherwise.
>
> This allows fbdev drivers to use sysfs interfaces via runtime checks
> instead of CONFIG_FB_DEVICE ifdefs, keeping the code clean while
> remaining fully buildable.
>
> Suggested-by: Helge Deller <deller@gmx.de>
> Reviewed-by: Helge Deller <deller@gmx.de>
> Reviewed-by: Andy Shevchenko <andy@kernel.org>
> Signed-off-by: Chintan Patel <chintanlike@gmail.com>
Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
> ---
> include/linux/fb.h | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/include/linux/fb.h b/include/linux/fb.h
> index 05cc251035da..dad3fb61a06a 100644
> --- a/include/linux/fb.h
> +++ b/include/linux/fb.h
> @@ -628,6 +628,15 @@ static inline void unlock_fb_info(struct fb_info *info)
> mutex_unlock(&info->lock);
> }
>
> +static inline struct device *dev_of_fbinfo(const struct fb_info *info)
> +{
> +#ifdef CONFIG_FB_DEVICE
> + return info->dev;
> +#else
> + return NULL;
> +#endif
> +}
> +
> static inline void __fb_pad_aligned_buffer(u8 *dst, u32 d_pitch,
> u8 *src, u32 s_pitch, u32 height)
> {
--
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Jochen Jaser, Andrew McDonald, Werner Knoblich, (HRB 36809, AG Nürnberg)
© 2016 - 2026 Red Hat, Inc.