[PATCH v3 3/4] fbdev: omapfb: Make FB_DEVICE dependency optional

Chintan Patel posted 4 patches 1 month, 1 week ago
There is a newer version of this series
[PATCH v3 3/4] fbdev: omapfb: Make FB_DEVICE dependency optional
Posted by Chintan Patel 1 month, 1 week ago
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.

Suggested-by: Helge Deller <deller@gmx.de>
Signed-off-by: Chintan Patel <chintanlike@gmail.com>
---
 drivers/video/fbdev/omap2/omapfb/Kconfig        |  3 ++-
 drivers/video/fbdev/omap2/omapfb/omapfb-sysfs.c | 16 ++++++++++++----
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/drivers/video/fbdev/omap2/omapfb/Kconfig b/drivers/video/fbdev/omap2/omapfb/Kconfig
index f4cdf999a080..2d20e79adefc 100644
--- a/drivers/video/fbdev/omap2/omapfb/Kconfig
+++ b/drivers/video/fbdev/omap2/omapfb/Kconfig
@@ -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
 
diff --git a/drivers/video/fbdev/omap2/omapfb/omapfb-sysfs.c b/drivers/video/fbdev/omap2/omapfb/omapfb-sysfs.c
index 831b2c2fbdf9..ef555dd598aa 100644
--- a/drivers/video/fbdev/omap2/omapfb/omapfb-sysfs.c
+++ b/drivers/video/fbdev/omap2/omapfb/omapfb-sysfs.c
@@ -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]);
 	}
 }
 
-- 
2.43.0
Re: [PATCH v3 3/4] fbdev: omapfb: Make FB_DEVICE dependency optional
Posted by Andy Shevchenko 1 month, 1 week ago
On Mon, Dec 29, 2025 at 09:28:21PM -0800, Chintan Patel wrote:
> 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.

...

> +		struct device *dev = dev_of_fbinfo(fbdev->fbs[i]);

Still the same issue I pointed out in v2 review.

>  		int t;
> +
> +		if (!dev)
> +			continue;

...

> +		struct device *dev = dev_of_fbinfo(fbdev->fbs[i]);
> +
> +		if (!dev)
> +			continue;

Ditto.

-- 
With Best Regards,
Andy Shevchenko
Re: [PATCH v3 3/4] fbdev: omapfb: Make FB_DEVICE dependency optional
Posted by Chintan Patel 1 month, 1 week ago

On 12/30/25 03:37, Andy Shevchenko wrote:
> On Mon, Dec 29, 2025 at 09:28:21PM -0800, Chintan Patel wrote:
>> 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.
> 
> ...
> 
>> +		struct device *dev = dev_of_fbinfo(fbdev->fbs[i]);
> 
> Still the same issue I pointed out in v2 review.
> 
>>   		int t;
>> +
>> +		if (!dev)
>> +			continue;
> 
> ...
> 
>> +		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 3/4] fbdev: omapfb: Make FB_DEVICE dependency optional
Posted by Andy Shevchenko 1 month, 1 week ago
On Tue, Dec 30, 2025 at 8:01 PM Chintan Patel <chintanlike@gmail.com> wrote:
> On 12/30/25 03:37, Andy Shevchenko wrote:
> > On Mon, Dec 29, 2025 at 09:28:21PM -0800, Chintan Patel wrote:

...

> > 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.

-- 
With Best Regards,
Andy Shevchenko
Re: [PATCH v3 3/4] fbdev: omapfb: Make FB_DEVICE dependency optional
Posted by Helge Deller 1 month, 1 week ago
* Chintan Patel <chintanlike@gmail.com>:
> 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.
> 
> Suggested-by: Helge Deller <deller@gmx.de>
> Signed-off-by: Chintan Patel <chintanlike@gmail.com>

Reviewed-by: Helge Deller <deller@gmx.de>

> ---
>  drivers/video/fbdev/omap2/omapfb/Kconfig        |  3 ++-
>  drivers/video/fbdev/omap2/omapfb/omapfb-sysfs.c | 16 ++++++++++++----
>  2 files changed, 14 insertions(+), 5 deletions(-)