fbdev: mb862xxfbdrv: Make CONFIG_FB_DEVICE optional
PATCH v2 1/1 fbdev: mb862xxfbdrv: Make CONFIG_FB_DEVICE optional
This patch wraps the relevant code blocks with IS_ENABLED(ifdef CONFIG_FB_DEVICE), allowing the driver to be built and used even if CONFIG_FB_DEVICE is not selected.
The sysfs only give access to show some controller and cursor registers so it's not needed to allow driver works correctly.
This align with Documentation/drm/todo.rst
"Remove driver dependencies on FB_DEVICE"
---
v1 -> v2:
* Fix error and improvement , thanks Uwe Kleine-Koenig.
* v1 https://lore.kernel.org/lkml/[email protected]
drivers/video/fbdev/mb862xx/mb862xxfbdrv.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/video/fbdev/mb862xx/mb862xxfbdrv.c +7 -4
@@ -17,6 +17,7 @@#include <linux/module.h> #include <linux/init.h> #include <linux/interrupt.h> +#include "linux/kconfig.h" #include <linux/pci.h> #include <linux/of.h> #include <linux/of_address.h>
@@ -759,7 +760,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 +802,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 +1103,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 +1153,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);
Signature · 1 line
2.50.1
Helge Deller
maintainerHi Javier,
thanks for the updated patch!
Some notes:
Quoted 8 lines · Javier Garcia
This patch wraps the relevant code blocks with
IS_ENABLED(ifdef CONFIG_FB_DEVICE), allowing the driver to be built and used even ifCONFIG_FB_DEVICEis not selected.The sysfs only give access to show some controller and cursor registers so it's not needed to allow driver works correctly.
This align with
Documentation/drm/todo.rst
"Remove driver dependencies onFB_DEVICE"
Can you make this commit message more crisp?
E.g. what is the benefit? Something new possible or fixed? Also, the driver can be built without CONFIG_FB_DEVICE, but it will then probably not work.
Do you have that card and tested it?
Maybe something like:
Allow 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).
Quoted 51 lines
Signed-off-by Javier Garcia <[email protected]>---
v1 -> v2:
* Fix error and improvement , thanks Uwe Kleine-Koenig.
* v1 https://lore.kernel.org/lkml/[email protected]drivers/video/fbdev/mb862xx/mb862xxfbdrv.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)drivers/video/fbdev/mb862xx/mb862xxfbdrv.c +5
-3@@ -17,6 +17,7 @@#include <linux/module.h> #include <linux/init.h> #include <linux/interrupt.h> +#include "linux/kconfig.h" #include <linux/pci.h> #include <linux/of.h> #include <linux/of_address.h> @@ -759,7 +760,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 +802,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 +1103,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 )
drivers/video/fbdev/mb862xx/mb862xxfbdrv.c static void mb862xx_pci_remove(struct pci_dev *pdev) · line 1156
Quoted 5 lines
drivers/video/fbdev/mb862xx/mb862xxfbdrv.c +1
-1@@ -1151,7 +1153,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 ))
a space is missign after "if".
Helge
Quoted 1 line · Javier Garcia
This patch wraps the relevant code blocks with
IS_ENABLED(ifdef CONFIG_FB_DEVICE),
stray "ifdef "
Quoted 1 line
allowing the driver to be built and used even if
CONFIG_FB_DEVICEis not selected.
The driver built fine without FB_DEVICE already before, doesn't it?
Quoted 5 lines
The sysfs only give access to show some controller and cursor registers so it's not needed to allow driver works correctly.
This align with
Documentation/drm/todo.rst
"Remove driver dependencies onFB_DEVICE"
Given the above, I still don't understand that. (But maybe this can be fixed by Helge's request to improve the commit message.)
Quoted 15 lines
Signed-off-by Javier Garcia <[email protected]>---
v1 -> v2:
* Fix error and improvement , thanks Uwe Kleine-Koenig.
* v1 https://lore.kernel.org/lkml/[email protected]drivers/video/fbdev/mb862xx/mb862xxfbdrv.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)drivers/video/fbdev/mb862xx/mb862xxfbdrv.c +0
-0
drivers/video/fbdev/mb862xx/mb862xxfbdrv.c line 20
Quoted 4 lines
drivers/video/fbdev/mb862xx/mb862xxfbdrv.c +1
-0@@ -17,6 +17,7 @@#include <linux/module.h> #include <linux/init.h> #include <linux/interrupt.h> +#include "linux/kconfig.h"
I didn't need that during my build tests, also don't use "" here, but <>.
drivers/video/fbdev/mb862xx/mb862xxfbdrv.c line 23
Quoted 4 lines
drivers/video/fbdev/mb862xx/mb862xxfbdrv.c +0
-0#include <linux/pci.h> #include <linux/of.h> #include <linux/of_address.h>
Best regards
Uwe
PATCH v3 1/1 fbdev: mb862xxfbdrv: Make CONFIG_FB_DEVICE optional
In reply to Javier GarciaThis 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.
---
v2 -> v3:
* Change commit msg , thanks Helge Deller.
* Delete not used include , thanks Uwe Kleine-Koenig.
* v1 https://lore.kernel.org/lkml/[email protected]/
v1 -> v2:
* Fix error and improvement , thanks Uwe Kleine-Koenig.
* v1 https://lore.kernel.org/lkml/[email protected]
drivers/video/fbdev/mb862xx/mb862xxfbdrv.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/video/fbdev/mb862xx/mb862xxfbdrv.c +6 -4
@@ -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);
Signature · 1 line
2.50.1
Helge Deller
maintainerQuoted 11 lines · Javier Garcia
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/fbdevice isn't compiled-in (CONFIG_FB_DEVICE=n).This align with
Documentation/drm/todo.rst
"Remove driver dependencies onFB_DEVICE"I've not the card so I was not able to test it.
Signed-off-by Javier Garcia <[email protected]>
applied (with minor changes to the commit message).
Thanks!
Helge
Hello Javier,
Quoted 9 lines · Javier Garcia
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/fbdevice isn't compiled-in (CONFIG_FB_DEVICE=n).This align with
Documentation/drm/todo.rst
"Remove driver dependencies onFB_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
Helge Deller
maintainerQuoted 9 lines · Uwe Kleine-König
Hello Javier,
Quoted 6 lines · Javier Garcia
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/fbdevice isn't compiled-in (CONFIG_FB_DEVICE=n).This align with
Documentation/drm/todo.rst
This seems to be Documentation/gpu/todo.rst now...
Quoted 4 lines
Quoted 1 line
"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.
Quoted 2 lines
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.
Quoted 2 lines
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