From: Chintan Patel Date: Wed, 7 Jan 2026 04:42:54 +0000 (-0800) Subject: fb: Add dev_of_fbinfo() helper for optional sysfs support X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=39b65316fe9d6d3f730632408ace28d49c5845a4;p=thirdparty%2Flinux.git fb: Add dev_of_fbinfo() helper for optional sysfs support 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 Reviewed-by: Helge Deller Reviewed-by: Andy Shevchenko Signed-off-by: Chintan Patel Reviewed-by: Thomas Zimmermann Signed-off-by: Helge Deller --- diff --git a/include/linux/fb.h b/include/linux/fb.h index aaa50b81f1d2..e70ee58d689e 100644 --- a/include/linux/fb.h +++ b/include/linux/fb.h @@ -623,6 +623,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) {