drm/panel: lvds: Handle the optional regulator case properly
Subsystems (4)
PATCH 1/1 drm/panel: lvds: Handle the optional regulator case properly
The devm_regulator_get_optional function, unlike it was assumed in the commit a1c55bccf600 ("drm/panel: lvds: Add support for the power-supply property"), is actually returning an error pointer with -ENODEV instead of NULL when there's no regulator to find.
Make sure we handle that case properly.
--- drivers/gpu/drm/panel/panel-lvds.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/gpu/drm/panel/panel-lvds.c +7 -2
@@ -215,8 +215,13 @@ static int panel_lvds_probe(struct platform_device *pdev) lvds->supply =devm_regulator_get_optional (lvds->dev,"power" );if (IS_ERR (lvds->supply)) { ret =PTR_ERR (lvds->supply); -dev_err (lvds->dev,"failed to request regulator: %d\n" , ret); -return ret; + +if (ret != -ENODEV ) { +dev_err (lvds->dev,"failed to request regulator: %d\n" , ret); +return ret; + }else { + lvds->supply =NULL ; + } }/* Get GPIOs and backlight controller. */
Signature · 6 lines
2.14.3 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Laurent Pinchart
maintainerHi Maxime,
(CC'ing Mark Brown)
Thank you for the patch.
Quoted 19 lines · On Wednesday, 10 January 2018 17:59:41 EET Maxime Ripard wrote:
The
devm_regulator_get_optionalfunction, unlike it was assumed in the commita1c55bccf600("drm/panel: lvds: Add support for the power-supply property"), is actually returning an error pointer with-ENODEVinstead of NULL when there's no regulator to find.Make sure we handle that case properly.
Fixes a1c55bccf600 ("drm/panel: lvds: Add support for the power-supplyproperty") Signed-off-by: Maxime Ripard <[email protected]>
--- drivers/gpu/drm/panel/panel-lvds.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)(quoted diff) +0
-0
b/drivers/gpu/drm/panel/panel-lvds.cindex57e38a9e7ab4..9f46e7095c0e100644
drivers/gpu/drm/panel/panel-lvds.c static int panel_lvds_probe(struct platform_device · line 221
Quoted 9 lines
drivers/gpu/drm/panel/panel-lvds.c +4
-2@@ -215,8 +215,13 @@ static int panel_lvds_probe(struct platform_device *pdev) lvds->supply = devm_regulator_get_optional(lvds->dev, "power");if (IS_ERR (lvds->supply)) { ret =PTR_ERR (lvds->supply); -dev_err (lvds->dev,"failed to request regulator: %d\n" , ret); -return ret; + +if (ret != -ENODEV ) { +dev_err (lvds->dev,"failed to request regulator: %d\n" , ret); +return ret;
I wouldn't print an error message if ret == -EPROBE_DEFER.
drivers/gpu/drm/panel/panel-lvds.c static int panel_lvds_probe(struct platform_device *pdev) · line 225
Quoted 4 lines
drivers/gpu/drm/panel/panel-lvds.c +3
-0+ }else { + lvds->supply =NULL ; + } }
How about
lvds->supply = devm_regulator_get_optional(lvds->dev, "power");
if (IS_ERR(lvds->supply)) {
ret = PTR_ERR(lvds->supply);
if (ret != -ENODEV) {
if (ret == -EPROBE_DEFER)
dev_err(lvds->dev, "failed to request regulator: %d\n", ret);
return ret;
}
lvds->supply = NULL;
}My preference, however, would be for devm_regulator_get_optional() to return NULL when no regulator is present. The current implementation returns -ENODEV in multiple cases, making it impossible to properly discriminate between having no regulator and not being able to get the regulator due to an error.
Mark, what do you think about this ?
Quoted 1 line
drivers/gpu/drm/panel/panel-lvds.c +0
-0/* Get GPIOs and backlight controller. */
Signature · 3 lines
Regards, Laurent Pinchart
Hi,
Quoted 45 lines · Laurent Pinchart
Hi Maxime,
(CC'ing Mark Brown)
Thank you for the patch.
Quoted 19 lines · On Wednesday, 10 January 2018 17:59:41 EET Maxime Ripard wrote:
The
devm_regulator_get_optionalfunction, unlike it was assumed in the commita1c55bccf600("drm/panel: lvds: Add support for the power-supply property"), is actually returning an error pointer with-ENODEVinstead of NULL when there's no regulator to find.Make sure we handle that case properly.
Fixes a1c55bccf600 ("drm/panel: lvds: Add support for the power-supplyproperty") Signed-off-by: Maxime Ripard <[email protected]>
--- drivers/gpu/drm/panel/panel-lvds.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)(quoted diff) +0
-0
b/drivers/gpu/drm/panel/panel-lvds.cindex57e38a9e7ab4..9f46e7095c0e100644drivers/gpu/drm/panel/panel-lvds.c static int panel_lvds_probe(struct platform_device · line 221
Quoted 9 lines
drivers/gpu/drm/panel/panel-lvds.c +4
-2@@ -215,8 +215,13 @@ static int panel_lvds_probe(struct platform_device *pdev) lvds->supply = devm_regulator_get_optional(lvds->dev, "power");if (IS_ERR (lvds->supply)) { ret =PTR_ERR (lvds->supply); -dev_err (lvds->dev,"failed to request regulator: %d\n" , ret); -return ret; + +if (ret != -ENODEV ) { +dev_err (lvds->dev,"failed to request regulator: %d\n" , ret); +return ret;I wouldn't print an error message if ret == -EPROBE_DEFER.
drivers/gpu/drm/panel/panel-lvds.c static int panel_lvds_probe(struct platform_device *pdev) · line 225
Quoted 4 lines
drivers/gpu/drm/panel/panel-lvds.c +3
-0+ }else { + lvds->supply =NULL ; + } }How about
Quoted 5 lines
lvds->supply = devm_regulator_get_optional(lvds->dev, "power");
if (IS_ERR(lvds->supply)) {
ret = PTR_ERR(lvds->supply);
if (ret != -ENODEV) {
if (ret == -EPROBE_DEFER)I guess that would be != -EPROBE_DEFER
Quoted 6 lines
dev_err(lvds->dev, "failed to request regulator: %d\n", ret); return ret; } lvds->supply = NULL; }
Otherwise, it works for me.
Quoted 4 lines
My preference, however, would be for
devm_regulator_get_optional()to return NULL when no regulator is present. The current implementation returns-ENODEVin multiple cases, making it impossible to properly discriminate between having no regulator and not being able to get the regulator due to an error.
It would feel more intuitive to me too, but it would also require to fix most of the call sites that would have a similar pattern.
Maxime
Signature · 3 lines
Maxime Ripard, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
Laurent Pinchart
maintainerHi Maxime,
Quoted 43 lines · On Thursday, 11 January 2018 15:12:56 EET Maxime Ripard wrote:
Quoted 42 lines · Laurent Pinchart
Quoted 21 lines · On Wednesday, 10 January 2018 17:59:41 EET Maxime Ripard wrote:
The
devm_regulator_get_optionalfunction, unlike it was assumed in the commita1c55bccf600("drm/panel: lvds: Add support for the power-supply property"), is actually returning an error pointer with-ENODEVinstead of NULL when there's no regulator to find.Make sure we handle that case properly.
Fixes a1c55bccf600 ("drm/panel: lvds: Add support for the power-supplyproperty") Signed-off-by: Maxime Ripard
<[email protected]>
---drivers/gpu/drm/panel/panel-lvds.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)(quoted diff) +0
-0
b/drivers/gpu/drm/panel/panel-lvds.cindex57e38a9e7ab4..9f46e7095c0e100644drivers/gpu/drm/panel/panel-lvds.c static int panel_lvds_probe(struct platform_device · line 222
Quoted 10 lines
drivers/gpu/drm/panel/panel-lvds.c +4
-2@@ -215,8 +215,13 @@ static int panel_lvds_probe(struct platform_device *pdev) lvds->supply =devm_regulator_get_optional (lvds->dev,"power" );if (IS_ERR (lvds->supply)) { ret =PTR_ERR (lvds->supply); -dev_err (lvds->dev,"failed to request regulator: %d\n" , ret); -return ret; + +if (ret != -ENODEV ) { +dev_err (lvds->dev,"failed to request regulator: %d\n" , ret); +return ret;I wouldn't print an error message if ret == -EPROBE_DEFER.
drivers/gpu/drm/panel/panel-lvds.c static int panel_lvds_probe(struct platform_device *pdev) · line 225
Quoted 4 lines
drivers/gpu/drm/panel/panel-lvds.c +3
-0+ }else { + lvds->supply =NULL ; + } }How about
Quoted 7 lines
Quoted 5 lines
lvds->supply = devm_regulator_get_optional(lvds->dev, "power"); if (IS_ERR(lvds->supply)) { ret = PTR_ERR(lvds->supply); if (ret != -ENODEV) { if (ret == -EPROBE_DEFER)I guess that would be != -EPROBE_DEFER
Of course, my bad.
Quoted 9 lines
Quoted 6 lines
dev_err(lvds->dev, "failed to request regulator: %d\n", ret); return ret; } lvds->supply = NULL; }Otherwise, it works for me.
Quoted 8 lines
Quoted 5 lines
My preference, however, would be for
devm_regulator_get_optional()to return NULL when no regulator is present. The current implementation returns-ENODEVin multiple cases, making it impossible to properly discriminate between having no regulator and not being able to get the regulator due to an error.It would feel more intuitive to me too, but it would also require to fix most of the call sites that would have a similar pattern.
Of course. I don't mean we need to delay this patch, but I still think it would be a good API improvement that could be developed separately (and of course I wouldn't complain if you volunteered ;-)).
Signature · 8 lines
Regards, Laurent Pinchart _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Hi Maxime,
Quoted 50 lines · On Friday, 12 January 2018 00:06:06 EET Laurent Pinchart wrote:
Quoted 49 lines · On Thursday, 11 January 2018 15:12:56 EET Maxime Ripard wrote:
Quoted 47 lines · Laurent Pinchart
Quoted 21 lines · On Wednesday, 10 January 2018 17:59:41 EET Maxime Ripard wrote:
The
devm_regulator_get_optionalfunction, unlike it was assumed in the commita1c55bccf600("drm/panel: lvds: Add support for the power-supply property"), is actually returning an error pointer with-ENODEVinstead of NULL when there's no regulator to find.Make sure we handle that case properly.
Fixes a1c55bccf600 ("drm/panel: lvds: Add support for the power-supplyproperty") Signed-off-by: Maxime Ripard
<[email protected]>
---drivers/gpu/drm/panel/panel-lvds.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)(quoted diff) +0
-0
b/drivers/gpu/drm/panel/panel-lvds.cindex57e38a9e7ab4..9f46e7095c0e100644drivers/gpu/drm/panel/panel-lvds.c static int panel_lvds_probe(struct platform_device · line 222
Quoted 10 lines
drivers/gpu/drm/panel/panel-lvds.c +4
-2@@ -215,8 +215,13 @@ static int panel_lvds_probe(struct platform_device *pdev) lvds->supply =devm_regulator_get_optional (lvds->dev,"power" );if (IS_ERR (lvds->supply)) { ret =PTR_ERR (lvds->supply); -dev_err (lvds->dev,"failed to request regulator: %d\n" , ret); -return ret; + +if (ret != -ENODEV ) { +dev_err (lvds->dev,"failed to request regulator: %d\n" , ret); +return ret;I wouldn't print an error message if ret == -EPROBE_DEFER.
drivers/gpu/drm/panel/panel-lvds.c static int panel_lvds_probe(struct platform_device *pdev) · line 225
Quoted 4 lines
drivers/gpu/drm/panel/panel-lvds.c +3
-0+ }else { + lvds->supply =NULL ; + } }How about
lvds->supply = devm_regulator_get_optional(lvds->dev, "power"); if (IS_ERR(lvds->supply)) { ret = PTR_ERR(lvds->supply); if (ret != -ENODEV) { if (ret == -EPROBE_DEFER)
Quoted 12 lines
Quoted 1 line
I guess that would be != -EPROBE_DEFER
Of course, my bad.
Quoted 8 lines
Quoted 6 lines
dev_err(lvds->dev, "failed to request regulator: %d\n", ret); return ret; } lvds->supply = NULL; }Otherwise, it works for me.
With the above change,
Quoted 12 lines
Quoted 8 lines
Quoted 5 lines
My preference, however, would be for
devm_regulator_get_optional()to return NULL when no regulator is present. The current implementation returns-ENODEVin multiple cases, making it impossible to properly discriminate between having no regulator and not being able to get the regulator due to an error.It would feel more intuitive to me too, but it would also require to fix most of the call sites that would have a similar pattern.
Of course. I don't mean we need to delay this patch, but I still think it would be a good API improvement that could be developed separately (and of course I wouldn't complain if you volunteered ;-)).
Signature · 8 lines
Regards, Laurent Pinchart _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Maxime Ripard
AppliedQuoted 64 lines · Laurent Pinchart
Hi Maxime,
Quoted 61 lines · On Friday, 12 January 2018 00:06:06 EET Laurent Pinchart wrote:
Quoted 43 lines · On Thursday, 11 January 2018 15:12:56 EET Maxime Ripard wrote:
Quoted 42 lines · Laurent Pinchart
Quoted 21 lines · On Wednesday, 10 January 2018 17:59:41 EET Maxime Ripard wrote:
The
devm_regulator_get_optionalfunction, unlike it was assumed in the commita1c55bccf600("drm/panel: lvds: Add support for the power-supply property"), is actually returning an error pointer with-ENODEVinstead of NULL when there's no regulator to find.Make sure we handle that case properly.
Fixes a1c55bccf600 ("drm/panel: lvds: Add support for the power-supplyproperty") Signed-off-by: Maxime Ripard
<[email protected]>
---drivers/gpu/drm/panel/panel-lvds.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)(quoted diff) +0
-0
b/drivers/gpu/drm/panel/panel-lvds.cindex57e38a9e7ab4..9f46e7095c0e100644drivers/gpu/drm/panel/panel-lvds.c static int panel_lvds_probe(struct platform_device · line 222
Quoted 10 lines
drivers/gpu/drm/panel/panel-lvds.c +4
-2@@ -215,8 +215,13 @@ static int panel_lvds_probe(struct platform_device *pdev) lvds->supply =devm_regulator_get_optional (lvds->dev,"power" );if (IS_ERR (lvds->supply)) { ret =PTR_ERR (lvds->supply); -dev_err (lvds->dev,"failed to request regulator: %d\n" , ret); -return ret; + +if (ret != -ENODEV ) { +dev_err (lvds->dev,"failed to request regulator: %d\n" , ret); +return ret;I wouldn't print an error message if ret == -EPROBE_DEFER.
drivers/gpu/drm/panel/panel-lvds.c static int panel_lvds_probe(struct platform_device *pdev) · line 225
Quoted 4 lines
drivers/gpu/drm/panel/panel-lvds.c +3
-0+ }else { + lvds->supply =NULL ; + } }How about
Quoted 7 lines
Quoted 5 lines
lvds->supply = devm_regulator_get_optional(lvds->dev, "power"); if (IS_ERR(lvds->supply)) { ret = PTR_ERR(lvds->supply); if (ret != -ENODEV) { if (ret == -EPROBE_DEFER)I guess that would be != -EPROBE_DEFER
Of course, my bad.
Quoted 7 lines
Quoted 6 lines
dev_err(lvds->dev, "failed to request regulator: %d\n", ret); return ret; } lvds->supply = NULL; }
Quoted 6 lines
Quoted 1 line
Quoted 1 line
Otherwise, it works for me.
With the above change,
Reviewed-by Laurent Pinchart <[email protected]>Tested-by Laurent Pinchart <[email protected]>
Applied to drm-misc-next-fixes.
Maxime
Signature · 3 lines
Maxime Ripard, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
Quoted 4 lines · Laurent Pinchart
My preference, however, would be for
devm_regulator_get_optional()to return NULL when no regulator is present. The current implementation returns-ENODEVin multiple cases, making it impossible to properly discriminate between having no regulator and not being able to get the regulator due to an error.
Just a word of warning, IS_ERR(NULL) is false, and your proposed change would apparently require quite a churn all over the kernel.
BR,
Jani.
Signature · 1 line
Jani Nikula, Intel Open Source Technology Center
Laurent Pinchart
maintainerHi Jani,
Quoted 9 lines · On Thursday, 11 January 2018 16:31:59 EET Jani Nikula wrote:
Quoted 5 lines · Laurent Pinchart
My preference, however, would be for
devm_regulator_get_optional()to return NULL when no regulator is present. The current implementation returns-ENODEVin multiple cases, making it impossible to properly discriminate between having no regulator and not being able to get the regulator due to an error.Just a word of warning,
IS_ERR(NULL)is false, and your proposed change would apparently require quite a churn all over the kernel.
That's correct, but I still think that would make the API clearer. I don't want to block this patch until we make such a change, but it's a good opportunity to discuss it. I'd like to know what Mark's opinion is.
Signature · 8 lines
Regards, Laurent Pinchart _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel