Skip to content

Commit 39b6531

Browse files
nehudesihdeller
authored andcommitted
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 <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> Signed-off-by: Helge Deller <deller@gmx.de>
1 parent 8f582bc commit 39b6531

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

include/linux/fb.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,15 @@ static inline void unlock_fb_info(struct fb_info *info)
623623
mutex_unlock(&info->lock);
624624
}
625625

626+
static inline struct device *dev_of_fbinfo(const struct fb_info *info)
627+
{
628+
#ifdef CONFIG_FB_DEVICE
629+
return info->dev;
630+
#else
631+
return NULL;
632+
#endif
633+
}
634+
626635
static inline void __fb_pad_aligned_buffer(u8 *dst, u32 d_pitch,
627636
u8 *src, u32 s_pitch, u32 height)
628637
{

0 commit comments

Comments
 (0)