fbdev: Make CONFIG_FB_DEVICE optional for drivers
Subsystems (4)
v3 cover fbdev: Make CONFIG_FB_DEVICE optional for drivers
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 v3:
- Use PTR_IF() to conditionally include overlay_sysfs_group in overlay_sysfs_groups
- Decouple variable definition and assignment in fbtft_sysfs_init/exit
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 | 20 +++++++++++++++---- drivers/video/fbdev/omap2/omapfb/Kconfig | 3 ++- .../video/fbdev/omap2/omapfb/omapfb-sysfs.c | 16 +++++++++++---- drivers/video/fbdev/sh_mobile_lcdcfb.c | 12 ++++++++++- include/linux/fb.h | 9 +++++++++ 6 files changed, 54 insertions(+), 11 deletions(-)
Signature · 1 line
2.43.0
PATCH v3 1/4 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.
--- include/linux/fb.h | 9 +++++++++ 1 file changed, 9 insertions(+)
include/linux/fb.h +9 -0
@@ -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) {
Signature · 1 line
2.43.0
PATCH v3 2/4 staging: fbtft: Make FB_DEVICE dependency optional
In reply to Chintan Patelfbtft 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.
--- drivers/staging/fbtft/Kconfig | 5 ++++- drivers/staging/fbtft/fbtft-sysfs.c | 20 ++++++++++++++++---- 2 files changed, 20 insertions(+), 5 deletions(-)
drivers/staging/fbtft/Kconfig +4 -1
@@ -2,11 +2,14 @@ menuconfig FB_TFT tristate "Support for small TFT LCD display modules" depends on FB && SPI - depends on FB_DEVICE depends on BACKLIGHT_CLASS_DEVICE depends on GPIOLIB || COMPILE_TEST select FB_BACKLIGHT select FB_SYSMEM_HELPERS_DEFERRED + help + Support for small TFT LCD display modules over SPI bus. FB_DEVICE + is not required, but if enabled, provides sysfs interface for debugging + and gamma curve configuration. if FB_TFT
drivers/staging/fbtft/fbtft-sysfs.c +16 -4
@@ -203,14 +203,26 @@ static struct device_attribute debug_device_attr =void fbtft_sysfs_init (struct fbtft_par *par) { -device_create_file (par->info->dev, &debug_device_attr); +struct device *dev; + + dev =dev_of_fbinfo (par->info); +if (!dev) +return ; + +device_create_file (dev, &debug_device_attr);if (par->gamma.curves && par->fbtftops.set_gamma) -device_create_file (par->info->dev, &gamma_device_attrs[0 ]); +device_create_file (dev, &gamma_device_attrs[0 ]); }void fbtft_sysfs_exit (struct fbtft_par *par) { -device_remove_file (par->info->dev, &debug_device_attr); +struct device *dev; + + dev =dev_of_fbinfo (par->info); +if (!dev) +return ; + +device_remove_file (dev, &debug_device_attr);if (par->gamma.curves && par->fbtftops.set_gamma) -device_remove_file (par->info->dev, &gamma_device_attrs[0 ]); +device_remove_file (dev, &gamma_device_attrs[0 ]); }
Signature · 1 line
2.43.0
PATCH v3 3/4 fbdev: omapfb: Make FB_DEVICE dependency optional
In reply to Chintan Patelomapfb 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.
--- drivers/video/fbdev/omap2/omapfb/Kconfig | 3 ++- drivers/video/fbdev/omap2/omapfb/omapfb-sysfs.c | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-)
drivers/video/fbdev/omap2/omapfb/Kconfig +2 -1
@@ -5,7 +5,6 @@ config OMAP2_VRFB menuconfig FB_OMAP2 tristate "OMAP2+ frame buffer support" depends on FB - depends on FB_DEVICE depends on DRM_OMAP = n depends on GPIOLIB select FB_OMAP2_DSS
@@ -13,6 +12,8 @@ menuconfig FB_OMAP2 select FB_IOMEM_HELPERS help Frame buffer driver for OMAP2+ based boards. + FB_DEVICE is not required, but if enabled, provides sysfs interface + for framebuffer configuration and debugging. if FB_OMAP2
drivers/video/fbdev/omap2/omapfb/omapfb-sysfs.c +12 -4
@@ -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++) { +struct device *dev =dev_of_fbinfo (fbdev->fbs[i]);int t; + +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 "
@@ -580,9 +584,13 @@ void omapfb_remove_sysfs(struct omapfb2_device *fbdev)DBG ("remove sysfs for fbs\n" );for (i =0 ; i < fbdev->num_fbs; i++) { +struct device *dev =dev_of_fbinfo (fbdev->fbs[i]); + +if (!dev) +continue ; +for (t =0 ; t <ARRAY_SIZE (omapfb_attrs); t++) -device_remove_file (fbdev->fbs[i]->dev, - &omapfb_attrs[t]); +device_remove_file (dev, &omapfb_attrs[t]); } }
Signature · 1 line
2.43.0
PATCH v3 4/4 fbdev: sh_mobile_lcdc: Make FB_DEVICE dependency optional
In reply to Chintan PatelThe 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 conditionally using PTR_IF(). The driver always sets .dev_groups, and the kernel naturally skips NULL attribute groups while the code remains buildable and type-checked.
--- drivers/video/fbdev/sh_mobile_lcdcfb.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/video/fbdev/sh_mobile_lcdcfb.c +11 -1
@@ -1350,7 +1350,17 @@ static struct attribute *overlay_sysfs_attrs[] = { &dev_attr_overlay_rop3.attr, NULL, }; -ATTRIBUTE_GROUPS (overlay_sysfs); + +#ifdef CONFIG_FB_DEVICE +static const struct attribute_group overlay_sysfs_group = { + .attrs = overlay_sysfs_attrs, +}; +#endif + +static const struct attribute_group *overlay_sysfs_groups[] = { +PTR_IF (IS_ENABLED (CONFIG_FB_DEVICE ), &overlay_sysfs_group), +NULL , +};static const struct fb_fix_screeninfo sh_mobile_lcdc_overlay_fix = { .id = "SH Mobile LCDC",
Signature · 1 line
2.43.0
Re: [PATCH v3 1/4] fb: Add dev_of_fbinfo() helper for optional sysfs support
In reply to Chintan Patel* Chintan Patel <[email protected]>:
Quoted 9 lines
Add
dev_of_fbinfo()to return the framebuffer struct device whenCONFIG_FB_DEVICEis enabled, or NULL otherwise.This allows fbdev drivers to use sysfs interfaces via runtime checks instead of
CONFIG_FB_DEVICEifdefs, keeping the code clean while remaining fully buildable.Suggested-by Helge Deller <[email protected]>Signed-off-by Chintan Patel <[email protected]>
Re: [PATCH v3 2/4] staging: fbtft: Make FB_DEVICE dependency optional
In reply to Chintan Patel* Chintan Patel <[email protected]>:
Quoted 11 lines
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_DEVICEand make sysfs support optional by usingdev_of_fbinfo()at runtime. WhenFB_DEVICEis disabled, sysfs operations are skipped while the code remains buildable and type-checked.Suggested-by Thomas Zimmermann <[email protected]>Suggested-by Helge Deller <[email protected]>Signed-off-by Chintan Patel <[email protected]>
Re: [PATCH v3 3/4] fbdev: omapfb: Make FB_DEVICE dependency optional
In reply to Chintan Patel* Chintan Patel <[email protected]>:
Quoted 10 lines
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_DEVICEand make sysfs support optional by usingdev_of_fbinfo()to obtain the backing device at runtime. WhenFB_DEVICEis disabled, sysfs operations are skipped while the code still builds and is type-checked.Suggested-by Helge Deller <[email protected]>Signed-off-by Chintan Patel <[email protected]>
Quoted 4 lines
--- drivers/video/fbdev/omap2/omapfb/Kconfig | 3 ++- drivers/video/fbdev/omap2/omapfb/omapfb-sysfs.c | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-)
Re: [PATCH v3 4/4] fbdev: sh_mobile_lcdc: Make FB_DEVICE dependency optional
In reply to Chintan Patel* Chintan Patel <[email protected]>:
Quoted 19 lines
The
sh_mobile_lcdcdriver exposes overlay configuration via sysfs, but the core driver does not requireCONFIG_FB_DEVICE.Make sysfs support optional by defining
overlay_sysfs_groupsconditionally usingPTR_IF(). The driver always sets .dev_groups, and the kernel naturally skips NULL attribute groups while the code remains buildable and type-checked.Suggested-by Helge Deller <[email protected]>Signed-off-by Chintan Patel <[email protected]>--- drivers/video/fbdev/sh_mobile_lcdcfb.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)drivers/video/fbdev/sh_mobile_lcdcfb.c +0
-0
drivers/video/fbdev/sh_mobile_lcdcfb.c static struct attribute *overlay_sysfs_attrs[] = { · line 1353
Quoted 4 lines
drivers/video/fbdev/sh_mobile_lcdcfb.c +0
-1@@ -1350,7 +1350,17 @@ static struct attribute *overlay_sysfs_attrs[] = { &dev_attr_overlay_rop3.attr, NULL, }; -ATTRIBUTE_GROUPS (overlay_sysfs);
Instead of replacing the ^ ATTRIBUTE_GROUPS() by the code below, isn't it possible to just mark the overlay_sysfs_attrs[] array _maybe_unused, and just do:
+ #ifdef CONFIG_FB_DEVICE
+ ATTRIBUTE_GROUPS(overlay_sysfs);
+ #endif
?
Helge
Quoted 18 lines
drivers/video/fbdev/sh_mobile_lcdcfb.c +11
-0+ +#ifdef CONFIG_FB_DEVICE +static const struct attribute_group overlay_sysfs_group = { + .attrs = overlay_sysfs_attrs, +}; +#endif + +static const struct attribute_group *overlay_sysfs_groups[] = { +PTR_IF (IS_ENABLED (CONFIG_FB_DEVICE ), &overlay_sysfs_group), +NULL , +};static const struct fb_fix_screeninfo sh_mobile_lcdc_overlay_fix = { .id ="SH Mobile LCDC" ,Signature · 1 line
2.43.0
Hi Chintan.
Quoted 10 lines · Chintan Patel
This series makes
CONFIG_FB_DEVICEoptional for fbdev drivers that use it only for sysfs interfaces, addressing Thomas Zimmermann’s TODO to remove hardFB_DEVICEdependencies.The series introduces a small helper,
dev_of_fbinfo(), which returns NULL whenCONFIG_FB_DEVICE=n. This allows sysfs code paths to be skipped via runtime checks, avoids #ifdefCONFIG_FB_DEVICEclutter, and keeps full compile-time syntax checking.Signed-off-by Chintan Patel <[email protected]>
Quoted 8 lines
---
Changes in v3:
- UsePTR_IF()to conditionally includeoverlay_sysfs_groupinoverlay_sysfs_groups
- Decouple variable definition and assignment in fbtft_sysfs_init/exitChanges in v2:
- Adddev_of_fbinfo()helper (suggested by Geert Uytterhoeven)
by Helge Deller, not me.
Quoted 2 lines
- Replace #ifdef
CONFIG_FB_DEVICEblocks with runtime NULL checks
- Switch tofb_dbg()/fb_info()logging (suggested by Thomas Zimmermann)
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Quoted 9 lines · Chintan Patel
This series makes
CONFIG_FB_DEVICEoptional for fbdev drivers that use it only for sysfs interfaces, addressing Thomas Zimmermann’s TODO to remove hardFB_DEVICEdependencies.The series introduces a small helper,
dev_of_fbinfo(), which returns NULL whenCONFIG_FB_DEVICE=n. This allows sysfs code paths to be skipped via runtime checks, avoids #ifdefCONFIG_FB_DEVICEclutter, and keeps full compile-time syntax checking.
Quoted 6 lines
Signed-off-by Chintan Patel <[email protected]>---
Changes in v3:
- UsePTR_IF()to conditionally includeoverlay_sysfs_groupinoverlay_sysfs_groups
- Decouple variable definition and assignment in fbtft_sysfs_init/exit
Any particular reasons you ignored my tag from v2?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v3 4/4] fbdev: sh_mobile_lcdc: Make FB_DEVICE dependency optional
In reply to Chintan PatelQuoted 7 lines · Chintan Patel
The
sh_mobile_lcdcdriver exposes overlay configuration via sysfs, but the core driver does not requireCONFIG_FB_DEVICE.Make sysfs support optional by defining
overlay_sysfs_groupsconditionally usingPTR_IF(). The driver always sets .dev_groups, and the kernel naturally skips NULL attribute groups while the code remains buildable and type-checked.
...
drivers/video/fbdev/sh_mobile_lcdcfb.c static struct attribute *overlay_sysfs_attrs[] = { · line 1362
Quoted 3 lines
drivers/video/fbdev/sh_mobile_lcdcfb.c +3
-0+static const struct attribute_group *overlay_sysfs_groups[] = { +PTR_IF (IS_ENABLED (CONFIG_FB_DEVICE ), &overlay_sysfs_group), +NULL ,
Please, drop comma at the end of the terminator entry.
Quoted 1 line
+};
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v3 3/4] fbdev: omapfb: Make FB_DEVICE dependency optional
In reply to Chintan PatelQuoted 7 lines · Chintan Patel
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_DEVICEand make sysfs support optional by usingdev_of_fbinfo()to obtain the backing device at runtime. WhenFB_DEVICEis disabled, sysfs operations are skipped while the code still builds and is type-checked.
...
Review
Quoted 1 line
(quoted diff) +1
-0+ struct device *dev = dev_of_fbinfo(fbdev->fbs[i]);
Still the same issue I pointed out in v2 review.
Quoted 4 lines
drivers/video/fbdev/omap2/omapfb/omapfb-sysfs.c +3
-0int t; + +if (!dev) +continue ;
...
drivers/video/fbdev/omap2/omapfb/omapfb-sysfs.c int omapfb_create_sysfs(struct omapfb2_device *fbdev) · line 565
Quoted 4 lines
drivers/video/fbdev/omap2/omapfb/omapfb-sysfs.c +4
-0+struct device *dev =dev_of_fbinfo (fbdev->fbs[i]); + +if (!dev) +continue ;
Ditto.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 10 lines · Andy Shevchenko
Quoted 8 lines · Chintan Patel
This series makes
CONFIG_FB_DEVICEoptional for fbdev drivers that use it only for sysfs interfaces, addressing Thomas Zimmermann’s TODO to remove hardFB_DEVICEdependencies.The series introduces a small helper,
dev_of_fbinfo(), which returns NULL whenCONFIG_FB_DEVICE=n. This allows sysfs code paths to be skipped via runtime checks, avoids #ifdefCONFIG_FB_DEVICEclutter, and keeps full compile-time syntax checking.
Quoted 9 lines
Quoted 6 lines
Signed-off-by Chintan Patel <[email protected]>---
Changes in v3:
- UsePTR_IF()to conditionally includeoverlay_sysfs_groupinoverlay_sysfs_groups
- Decouple variable definition and assignment in fbtft_sysfs_init/exitAny particular reasons you ignored my tag from v2?
Ah.. This is typo. I see what happened now. Looks like my script picked wrong or old patches instead of new updated one. Should I send v4 or v4 is fine?
Re: [PATCH v3 3/4] fbdev: omapfb: Make FB_DEVICE dependency optional
In reply to Andy ShevchenkoQuoted 22 lines · Andy Shevchenko
Quoted 7 lines · Chintan Patel
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_DEVICEand make sysfs support optional by usingdev_of_fbinfo()to obtain the backing device at runtime. WhenFB_DEVICEis disabled, sysfs operations are skipped while the code still builds and is type-checked....
Review
Quoted 1 line
(quoted diff) +1
-0+ struct device *dev = dev_of_fbinfo(fbdev->fbs[i]);Still the same issue I pointed out in v2 review.
Quoted 4 lines
int t;
drivers/video/fbdev/omap2/omapfb/omapfb-sysfs.c +3
-0+ +if (!dev) +continue ;...
Quoted 6 lines
drivers/video/fbdev/omap2/omapfb/omapfb-sysfs.c int omapfb_create_sysfs(struct omapfb2_device *fbdev) · line 565
Quoted 4 lines
drivers/video/fbdev/omap2/omapfb/omapfb-sysfs.c +4
-0+struct device *dev =dev_of_fbinfo (fbdev->fbs[i]); + +if (!dev) +continue ;Ditto.
Sorry about that. I had actually made your suggested changes but somehow I mistakenly send old patches instead of updated one. I will send updated one. Should I send v4 or v3 is fine?
Re: [PATCH v3 4/4] fbdev: sh_mobile_lcdc: Make FB_DEVICE dependency optional
In reply to Helge DellerQuoted 32 lines · Helge Deller
* Chintan Patel <[email protected]>:
Quoted 19 lines
The
sh_mobile_lcdcdriver exposes overlay configuration via sysfs, but the core driver does not requireCONFIG_FB_DEVICE.Make sysfs support optional by defining
overlay_sysfs_groupsconditionally usingPTR_IF(). The driver always sets .dev_groups, and the kernel naturally skips NULL attribute groups while the code remains buildable and type-checked.Suggested-by Helge Deller <[email protected]>Signed-off-by Chintan Patel <[email protected]>--- drivers/video/fbdev/sh_mobile_lcdcfb.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)drivers/video/fbdev/sh_mobile_lcdcfb.c +0
-0drivers/video/fbdev/sh_mobile_lcdcfb.c static struct attribute *overlay_sysfs_attrs[] = { · line 1353
Quoted 4 lines
drivers/video/fbdev/sh_mobile_lcdcfb.c +0
-1@@ -1350,7 +1350,17 @@ static struct attribute *overlay_sysfs_attrs[] = { &dev_attr_overlay_rop3.attr, NULL, }; -ATTRIBUTE_GROUPS (overlay_sysfs);Instead of replacing the ^
ATTRIBUTE_GROUPS()by the code below, isn't it possible to just mark the overlay_sysfs_attrs[] array_maybe_unused, and just do:
+ #ifdefCONFIG_FB_DEVICE
+ATTRIBUTE_GROUPS(overlay_sysfs);
+ #endif
Quoted 1 line
?
Hi Helge,
Yes, the __maybe_unused + #ifdef ATTRIBUTE_GROUPS() approach would work.
I went with the PTR_IF(IS_ENABLED()) pattern because Andy suggested using PTR_IF() to conditionally include overlay_sysfs_group in overlay_sysfs_groups, and to keep .dev_groups always populated while letting the device core skip NULL groups. This avoids conditional wiring via #ifdef and keeps the code type-checked without CONFIG_FB_DEVICE. If you still prefer the simpler #ifdef ATTRIBUTE_GROUPS() approach for this driver, I can switch to that, but I wanted to follow Andy’s guidance here.
Thanks!
Re: [PATCH v3 3/4] fbdev: omapfb: Make FB_DEVICE dependency optional
In reply to Chintan PatelQuoted 2 lines · Chintan Patel
Quoted 1 line · Andy Shevchenko
On Mon, Dec 29, 2025 at 09:28:21PM -0800, Chintan Patel wrote:
...
Quoted 5 lines
Quoted 1 line
Still the same issue I pointed out in v2 review.
Sorry about that. I had actually made your suggested changes but somehow I mistakenly send old patches instead of updated one. I will send updated one. Should I send v4 or v3 is fine?
v4 needs to be sent.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Helge Deller
maintainerRe: [PATCH v3 4/4] fbdev: sh_mobile_lcdc: Make FB_DEVICE dependency optional
In reply to Chintan PatelQuoted 40 lines · Chintan Patel
Quoted 32 lines · Helge Deller
* Chintan Patel <[email protected]>:
Quoted 19 lines
The
sh_mobile_lcdcdriver exposes overlay configuration via sysfs, but the core driver does not requireCONFIG_FB_DEVICE.Make sysfs support optional by defining
overlay_sysfs_groupsconditionally usingPTR_IF(). The driver always sets .dev_groups, and the kernel naturally skips NULL attribute groups while the code remains buildable and type-checked.Suggested-by Helge Deller <[email protected]>Signed-off-by Chintan Patel <[email protected]>---
drivers/video/fbdev/sh_mobile_lcdcfb.c| 12 +++++++++++-1 file changed, 11 insertions(+), 1 deletion(-)drivers/video/fbdev/sh_mobile_lcdcfb.c +0
-0drivers/video/fbdev/sh_mobile_lcdcfb.c static struct attribute *overlay_sysfs_attrs[] = { · line 1353
Quoted 4 lines
drivers/video/fbdev/sh_mobile_lcdcfb.c +0
-1@@ -1350,7 +1350,17 @@ static struct attribute *overlay_sysfs_attrs[] = { &dev_attr_overlay_rop3.attr, NULL, }; -ATTRIBUTE_GROUPS (overlay_sysfs);Instead of replacing the ^
ATTRIBUTE_GROUPS()by the code below, isn't it possible to just mark the overlay_sysfs_attrs[] array_maybe_unused, and just do:
+ #ifdefCONFIG_FB_DEVICE
+ATTRIBUTE_GROUPS(overlay_sysfs);
+ #endifQuoted 1 line
?
Hi Helge,
Yes, the
__maybe_unused+ #ifdefATTRIBUTE_GROUPS()approach would work.
Quoted 9 lines
I went with the PTR_IF(IS_ENABLED()) pattern because Andy suggested using
PTR_IF()to conditionally includeoverlay_sysfs_groupinoverlay_sysfs_groups, and to keep .dev_groups always populated while letting the device core skip NULL groups. This avoids conditional wiring via #ifdef and keeps the code type-checked withoutCONFIG_FB_DEVICE.
If you still prefer the simpler #ifdefATTRIBUTE_GROUPS()approach for this driver, I can switch to that, but I wanted to follow Andy’s guidance here.
I assume Andy will agree to my suggested approach, as it's cleaner and avoids code bloat/duplication. Maybe you send out a v4 with my suggested approach, then it's easier to judge... ?
Helge
Re: [PATCH v3 4/4] fbdev: sh_mobile_lcdc: Make FB_DEVICE dependency optional
Quoted 2 lines · Helge Deller
Quoted 1 line · Chintan Patel
On 12/30/25 00:13, Helge Deller wrote:
...
Quoted 23 lines
Quoted 13 lines
Quoted 10 lines
Quoted 1 line
-ATTRIBUTE_GROUPS(overlay_sysfs);
Instead of replacing the ^
ATTRIBUTE_GROUPS()by the code below, isn't it possible to just mark the overlay_sysfs_attrs[] array_maybe_unused, and just do:
+ #ifdefCONFIG_FB_DEVICE
+ATTRIBUTE_GROUPS(overlay_sysfs);
+ #endif?
Yes, the
__maybe_unused+ #ifdefATTRIBUTE_GROUPS()approach would work.Quoted 9 lines
I went with the PTR_IF(IS_ENABLED()) pattern because Andy suggested using
PTR_IF()to conditionally includeoverlay_sysfs_groupinoverlay_sysfs_groups, and to keep .dev_groups always populated while letting the device core skip NULL groups. This avoids conditional wiring via #ifdef and keeps the code type-checked withoutCONFIG_FB_DEVICE.
If you still prefer the simpler #ifdefATTRIBUTE_GROUPS()approach for this driver, I can switch to that, but I wanted to follow Andy’s guidance here.
Quoted 3 lines
I assume Andy will agree to my suggested approach, as it's cleaner and avoids code bloat/duplication. Maybe you send out a v4 with my suggested approach, then it's easier to judge... ?
I'm also fine with original code. But a suggested approach would work as well (at least like it sounds from the above description). Ideally would be nice to get rid of ifdeffery completely (that's why we have PTR_IF() for), although it might be not so readable. TL;DR: the most readable solution is the winner.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v3 4/4] fbdev: sh_mobile_lcdc: Make FB_DEVICE dependency optional
Quoted 29 lines · Andy Shevchenko
Quoted 2 lines · Helge Deller
Quoted 1 line · Chintan Patel
On 12/30/25 00:13, Helge Deller wrote:
...
Quoted 23 lines
Quoted 22 lines
Quoted 10 lines
Quoted 1 line
-ATTRIBUTE_GROUPS(overlay_sysfs);
Instead of replacing the ^
ATTRIBUTE_GROUPS()by the code below, isn't it possible to just mark the overlay_sysfs_attrs[] array_maybe_unused, and just do:
+ #ifdefCONFIG_FB_DEVICE
+ATTRIBUTE_GROUPS(overlay_sysfs);
+ #endif?
Yes, the
__maybe_unused+ #ifdefATTRIBUTE_GROUPS()approach would work.I went with the PTR_IF(IS_ENABLED()) pattern because Andy suggested using
PTR_IF()to conditionally includeoverlay_sysfs_groupinoverlay_sysfs_groups, and to keep .dev_groups always populated while letting the device core skip NULL groups. This avoids conditional wiring via #ifdef and keeps the code type-checked withoutCONFIG_FB_DEVICE.
If you still prefer the simpler #ifdefATTRIBUTE_GROUPS()approach for this driver, I can switch to that, but I wanted to follow Andy’s guidance here.
Quoted 9 lines
Quoted 3 lines
I assume Andy will agree to my suggested approach, as it's cleaner and avoids code bloat/duplication. Maybe you send out a v4 with my suggested approach, then it's easier to judge... ?
I'm also fine with original code. But a suggested approach would work as well (at least like it sounds from the above description). Ideally would be nice to get rid of ifdeffery completely (that's why we have
PTR_IF()for), although it might be not so readable. TL;DR: the most readable solution is the winner.
Thank you both! I will send v4 with Helge's suggestion and take it from there.