[PATCH v3] fbdev: mb862xxfbdrv: Make CONFIG_FB_DEVICE optional

Javier Garcia posted 1 patch 1 month, 4 weeks ago
drivers/video/fbdev/mb862xx/mb862xxfbdrv.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
[PATCH v3] fbdev: mb862xxfbdrv: Make CONFIG_FB_DEVICE optional
Posted by Javier Garcia 1 month, 4 weeks ago
This patch wraps the relevant code blocks with `IS_ENABLED(CONFIG_FB_DEVICE)`.

Allows the driver to be used for framebuffer text console, even if
support for the /dev/fb device isn't compiled-in (CONFIG_FB_DEVICE=n).

This align with Documentation/drm/todo.rst
"Remove driver dependencies on FB_DEVICE"

I've not the card so I was not able to test it.

Signed-off-by: Javier Garcia <rampxxxx@gmail.com>
---
v2 -> v3:
      * Change commit msg , thanks Helge Deller.
      * Delete not used include , thanks Uwe Kleine-Koenig.
      * v1 https://lore.kernel.org/lkml/20251006164143.1187434-1-rampxxxx@gmail.com/
v1 -> v2:
      * Fix error and improvement , thanks Uwe Kleine-Koenig.
      * v1 https://lore.kernel.org/lkml/20251005173812.1169436-1-rampxxxx@gmail.com

 drivers/video/fbdev/mb862xx/mb862xxfbdrv.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/video/fbdev/mb862xx/mb862xxfbdrv.c b/drivers/video/fbdev/mb862xx/mb862xxfbdrv.c
index ade88e7bc760..3f79dfc27a53 100644
--- a/drivers/video/fbdev/mb862xx/mb862xxfbdrv.c
+++ b/drivers/video/fbdev/mb862xx/mb862xxfbdrv.c
@@ -759,7 +759,7 @@ static int of_platform_mb862xx_probe(struct platform_device *ofdev)
 
 	dev_set_drvdata(dev, info);
 
-	if (device_create_file(dev, &dev_attr_dispregs))
+	if (IS_ENABLED(CONFIG_FB_DEVICE) && device_create_file(dev, &dev_attr_dispregs))
 		dev_err(dev, "Can't create sysfs regdump file\n");
 	return 0;
 
@@ -801,7 +801,8 @@ static void of_platform_mb862xx_remove(struct platform_device *ofdev)
 	free_irq(par->irq, (void *)par);
 	irq_dispose_mapping(par->irq);
 
-	device_remove_file(&ofdev->dev, &dev_attr_dispregs);
+	if (IS_ENABLED(CONFIG_FB_DEVICE))
+		device_remove_file(&ofdev->dev, &dev_attr_dispregs);
 
 	unregister_framebuffer(fbi);
 	fb_dealloc_cmap(&fbi->cmap);
@@ -1101,7 +1102,7 @@ static int mb862xx_pci_probe(struct pci_dev *pdev,
 
 	pci_set_drvdata(pdev, info);
 
-	if (device_create_file(dev, &dev_attr_dispregs))
+	if (IS_ENABLED(CONFIG_FB_DEVICE) && device_create_file(dev, &dev_attr_dispregs))
 		dev_err(dev, "Can't create sysfs regdump file\n");
 
 	if (par->type == BT_CARMINE)
@@ -1151,7 +1152,8 @@ static void mb862xx_pci_remove(struct pci_dev *pdev)
 
 	mb862xx_i2c_exit(par);
 
-	device_remove_file(&pdev->dev, &dev_attr_dispregs);
+	if (IS_ENABLED(CONFIG_FB_DEVICE))
+		device_remove_file(&pdev->dev, &dev_attr_dispregs);
 
 	unregister_framebuffer(fbi);
 	fb_dealloc_cmap(&fbi->cmap);
-- 
2.50.1
Re: [PATCH v3] fbdev: mb862xxfbdrv: Make CONFIG_FB_DEVICE optional
Posted by Uwe Kleine-König 1 month, 4 weeks ago
Hello Javier,

On Wed, Oct 08, 2025 at 08:36:27PM +0200, Javier Garcia wrote:
> This patch wraps the relevant code blocks with `IS_ENABLED(CONFIG_FB_DEVICE)`.
> 
> Allows the driver to be used for framebuffer text console, even if
> support for the /dev/fb device isn't compiled-in (CONFIG_FB_DEVICE=n).
> 
> This align with Documentation/drm/todo.rst
> "Remove driver dependencies on FB_DEVICE"
> 
> I've not the card so I was not able to test it.

I still don't understand why the creation of the dispregs sysfs file
should be conditional on FB_DEVICE. Either they have nothing to do with
each other, or I'm missing something. The former makes this patch wrong,
the latter would be an indication that the commit log is still
non-optimal.

Best regards
Uwe
Re: [PATCH v3] fbdev: mb862xxfbdrv: Make CONFIG_FB_DEVICE optional
Posted by Helge Deller 1 month, 3 weeks ago
On 10/9/25 10:50, Uwe Kleine-König wrote:
> Hello Javier,
> 
> On Wed, Oct 08, 2025 at 08:36:27PM +0200, Javier Garcia wrote:
>> This patch wraps the relevant code blocks with `IS_ENABLED(CONFIG_FB_DEVICE)`.
>>
>> Allows the driver to be used for framebuffer text console, even if
>> support for the /dev/fb device isn't compiled-in (CONFIG_FB_DEVICE=n).
>>
>> This align with Documentation/drm/todo.rst

This seems to be Documentation/gpu/todo.rst now...

>> "Remove driver dependencies on FB_DEVICE">>> I've not the card so I was not able to test it.
> 
> I still don't understand why the creation of the dispregs sysfs file
> should be conditional on FB_DEVICE. 

I think this is because people simply believe it, as it's documented like this
in the todo file. I think this is wrong.

I think the problem was, that device_create_file() has a "struct device *"
pointer as first parameter. Some device drivers probably referenced
the "struct device" pointer of the "/dev/fb" device, which does not exist
when FB_DEVICE isn't enabled. As such, the device_create_file() would fail
during initialization (since the devide ptr is NULL) of the driver and
prevent the driver from working.
That's not the case for this driver here, and probably not for the other
remaining drivers.

> Either they have nothing to do with each other, or I'm missing
> something. 

Right now you are right... it has nothing to do with each other.

> The former makes this patch wrong, the latter would be an
> indication that the commit log is still non-optimal.
Either way, I've dropped the patch from the git repo for now.
I don't think the patch is wrong, but it's not deemed necessary either.
If someone has that device I'd happy to apply it after some feedback.

In addition, maybe the section from the todo file should be dropped?

Helge
Re: [PATCH v3] fbdev: mb862xxfbdrv: Make CONFIG_FB_DEVICE optional
Posted by Helge Deller 1 month, 4 weeks ago
On 10/8/25 20:36, Javier Garcia wrote:
> This patch wraps the relevant code blocks with `IS_ENABLED(CONFIG_FB_DEVICE)`.
> 
> Allows the driver to be used for framebuffer text console, even if
> support for the /dev/fb device isn't compiled-in (CONFIG_FB_DEVICE=n).
> 
> This align with Documentation/drm/todo.rst
> "Remove driver dependencies on FB_DEVICE"
> 
> I've not the card so I was not able to test it.
> 
> Signed-off-by: Javier Garcia <rampxxxx@gmail.com>

applied (with minor changes to the commit message).

Thanks!
Helge