This series makes CONFIG_FB_DEVICE optional for fbdev drivers that use
it only for sysfs interfaces, addressing Thomas Zimmermann’s TODO to
remove hard FB_DEVICE dependencies.
The series introduces a small helper, dev_of_fbinfo(), which returns
NULL when CONFIG_FB_DEVICE=n. This allows sysfs code paths to be skipped
via runtime checks, avoids #ifdef CONFIG_FB_DEVICE clutter, and keeps
full compile-time syntax checking.
Changes in v2:
Add dev_of_fbinfo() helper (suggested by Geert Uytterhoeven)
Replace #ifdef CONFIG_FB_DEVICE blocks with runtime NULL checks
Switch to fb_dbg() / fb_info() logging (suggested by Thomas Zimmermann)
Chintan Patel (4):
fb: Add dev_of_fbinfo() helper for optional sysfs support
staging: fbtft: Make FB_DEVICE dependency optional
fbdev: omapfb: Make FB_DEVICE dependency optional
fbdev: sh_mobile_lcdc: Make FB_DEVICE dependency optional
drivers/staging/fbtft/Kconfig | 5 ++++-
drivers/staging/fbtft/fbtft-sysfs.c | 18 ++++++++++++++----
drivers/video/fbdev/omap2/omapfb/Kconfig | 3 ++-
.../video/fbdev/omap2/omapfb/omapfb-sysfs.c | 16 ++++++++++++----
drivers/video/fbdev/sh_mobile_lcdcfb.c | 9 +++++++++
include/linux/fb.h | 9 +++++++++
6 files changed, 50 insertions(+), 10 deletions(-)
--
2.43.0
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>
Signed-off-by: Chintan Patel <redacted>
---
include/linux/fb.h | 9 +++++++++
1 file changed, 9 insertions(+)
fbtft provides sysfs interfaces for debugging and gamma configuration,
but these are not required for the core driver.
Drop the hard dependency on CONFIG_FB_DEVICE and make sysfs support
optional by using dev_of_fbinfo() at runtime. When FB_DEVICE is disabled,
sysfs operations are skipped while the code remains buildable and
type-checked.
v2:
- Replace CONFIG_FB_DEVICE ifdefs with runtime checks
- Use dev_of_fbinfo() to guard sysfs creation and removal
Suggested-by: Thomas Zimmermann <tzimmermann@suse.de>
Suggested-by: Helge Deller <deller@gmx.de>
Signed-off-by: Chintan Patel <redacted>
---
drivers/staging/fbtft/Kconfig | 5 ++++-
drivers/staging/fbtft/fbtft-sysfs.c | 18 ++++++++++++++----
2 files changed, 18 insertions(+), 5 deletions(-)
omapfb provides several sysfs interfaces for framebuffer configuration
and debugging, but these are not required for the core driver.
Remove the hard dependency on CONFIG_FB_DEVICE and make sysfs support
optional by using dev_of_fbinfo() to obtain the backing device at runtime.
When FB_DEVICE is disabled, sysfs operations are skipped while the code
still builds and is type-checked.
v2:
- Replace CONFIG_FB_DEVICE ifdefs and stubs with runtime checks
- Use dev_of_fbinfo() to skip sysfs when unavailable
Suggested-by: Helge Deller <deller@gmx.de>
Signed-off-by: Chintan Patel <redacted>
---
drivers/video/fbdev/omap2/omapfb/Kconfig | 3 ++-
drivers/video/fbdev/omap2/omapfb/omapfb-sysfs.c | 16 ++++++++++++----
2 files changed, 14 insertions(+), 5 deletions(-)
@@ -558,10 +558,14 @@ int omapfb_create_sysfs(struct omapfb2_device *fbdev)DBG("create sysfs for fbs\n");for(i=0;i<fbdev->num_fbs;i++){+structdevice*dev=dev_of_fbinfo(fbdev->fbs[i]);intt;++if(!dev)+continue;+for(t=0;t<ARRAY_SIZE(omapfb_attrs);t++){-r=device_create_file(fbdev->fbs[i]->dev,-&omapfb_attrs[t]);+r=device_create_file(dev,&omapfb_attrs[t]);if(r){dev_err(fbdev->dev,"failed to create sysfs "
The sh_mobile_lcdc driver exposes overlay configuration via sysfs, but the
core driver does not require CONFIG_FB_DEVICE.
Make sysfs support optional by defining overlay_sysfs_groups as NULL when
FB_DEVICE is disabled. The driver always sets .dev_groups, and the kernel
naturally skips NULL attribute groups while the code remains buildable
and type-checked.
v2:
- Replace CONFIG_FB_DEVICE ifdefs with NULL overlay_sysfs_groups
- Always populate .dev_groups
Suggested-by: Helge Deller <deller@gmx.de>
Signed-off-by: Chintan Patel <redacted>
---
drivers/video/fbdev/sh_mobile_lcdcfb.c | 9 +++++++++
1 file changed, 9 insertions(+)
From: Andy Shevchenko <hidden> Date: 2025-12-27 14:16:00
On Fri, Dec 19, 2025 at 7:43 AM Chintan Patel [off-list ref] wrote:
quoted hunk
fbtft provides sysfs interfaces for debugging and gamma configuration,
but these are not required for the core driver.
Drop the hard dependency on CONFIG_FB_DEVICE and make sysfs support
optional by using dev_of_fbinfo() at runtime. When FB_DEVICE is disabled,
sysfs operations are skipped while the code remains buildable and
type-checked.
v2:
- Replace CONFIG_FB_DEVICE ifdefs with runtime checks
- Use dev_of_fbinfo() to guard sysfs creation and removal
Suggested-by: Thomas Zimmermann <tzimmermann@suse.de>
Suggested-by: Helge Deller <deller@gmx.de>
Signed-off-by: Chintan Patel <redacted>
---
drivers/staging/fbtft/Kconfig | 5 ++++-
drivers/staging/fbtft/fbtft-sysfs.c | 18 ++++++++++++++----
2 files changed, 18 insertions(+), 5 deletions(-)
From: Andy Shevchenko <hidden> Date: 2025-12-27 14:20:03
On Fri, Dec 19, 2025 at 7:43 AM Chintan Patel [off-list ref] wrote:
fbtft provides sysfs interfaces for debugging and gamma configuration,
but these are not required for the core driver.
Drop the hard dependency on CONFIG_FB_DEVICE and make sysfs support
optional by using dev_of_fbinfo() at runtime. When FB_DEVICE is disabled,
sysfs operations are skipped while the code remains buildable and
type-checked.
v2:
- Replace CONFIG_FB_DEVICE ifdefs with runtime checks
- Use dev_of_fbinfo() to guard sysfs creation and removal
The place for the change log is either a cover letter, or...
The better way is to decouple the definition and the assignment in the
cases when it's followed by a conditional (validation check). In this
case any new code added in between doesn't affect readability and
maintenance efforts.
struct device *dev;
dev = dev_of_fbinfo(par->info);
if (!dev)
return;
From: Andy Shevchenko <hidden> Date: 2025-12-27 14:22:29
On Fri, Dec 19, 2025 at 7:43 AM Chintan Patel [off-list ref] wrote:
The sh_mobile_lcdc driver exposes overlay configuration via sysfs, but the
core driver does not require CONFIG_FB_DEVICE.
Make sysfs support optional by defining overlay_sysfs_groups as NULL when
FB_DEVICE is disabled. The driver always sets .dev_groups, and the kernel
naturally skips NULL attribute groups while the code remains buildable
and type-checked.
Same comment about the changelog in the commit messages.
...
+#ifdef CONFIG_FB_DEVICE
ATTRIBUTE_GROUPS(overlay_sysfs);
+#else
+/*
+ * When CONFIG_FB_DEVICE is disabled, define overlay_sysfs_groups as NULL.
+ * The compiler will optimize out the sysfs code paths when dev_groups is NULL.
+ */
+static const struct attribute_group *overlay_sysfs_groups[] = { NULL };
+#endif
Hmm... I'm wondering if PTR_IF() can anyhow help here.
--
With Best Regards,
Andy Shevchenko
From: Andy Shevchenko <hidden> Date: 2025-12-27 14:23:50
On Fri, Dec 19, 2025 at 7:43 AM Chintan Patel [off-list ref] 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.
Reviewed-by: Andy Shevchenko <andy@kernel.org>
--
With Best Regards,
Andy Shevchenko
From: Andy Shevchenko <hidden> Date: 2025-12-27 14:25:13
On Fri, Dec 19, 2025 at 7:43 AM Chintan Patel [off-list ref] wrote:
This series makes CONFIG_FB_DEVICE optional for fbdev drivers that use
it only for sysfs interfaces, addressing Thomas Zimmermann’s TODO to
remove hard FB_DEVICE dependencies.
The series introduces a small helper, dev_of_fbinfo(), which returns
NULL when CONFIG_FB_DEVICE=n. This allows sysfs code paths to be skipped
via runtime checks, avoids #ifdef CONFIG_FB_DEVICE clutter, and keeps
full compile-time syntax checking.
Please, address my comments and I give a tag for v3. I pretty much
like the series, thanks!
--
With Best Regards,
Andy Shevchenko
Hi Andy,
On 12/27/25 06:19, Andy Shevchenko wrote:
On Fri, Dec 19, 2025 at 7:43 AM Chintan Patel [off-list ref] wrote:
quoted
fbtft provides sysfs interfaces for debugging and gamma configuration,
but these are not required for the core driver.
Drop the hard dependency on CONFIG_FB_DEVICE and make sysfs support
optional by using dev_of_fbinfo() at runtime. When FB_DEVICE is disabled,
sysfs operations are skipped while the code remains buildable and
type-checked.
quoted
v2:
- Replace CONFIG_FB_DEVICE ifdefs with runtime checks
- Use dev_of_fbinfo() to guard sysfs creation and removal
The place for the change log is either a cover letter, or...
The better way is to decouple the definition and the assignment in the
cases when it's followed by a conditional (validation check). In this
case any new code added in between doesn't affect readability and
maintenance efforts.
struct device *dev;
dev = dev_of_fbinfo(par->info);
if (!dev)
return;