* [PATCH v3 1/1] backlight: pwm_bl: Use dev_err_probe
@ 2023-11-17 12:06 Alexander Stein
2023-11-17 18:07 ` Uwe Kleine-König
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Alexander Stein @ 2023-11-17 12:06 UTC (permalink / raw)
To: Thierry Reding, Uwe Kleine-König, Lee Jones, Daniel Thompson,
Jingoo Han, Helge Deller
Cc: Alexander Stein, linux-pwm, dri-devel, linux-fbdev
Use dev_err_probe to simplify error paths. Also let dev_err_probe handle
the -EPROBE_DEFER case and add an entry to
/sys/kernel/debug/devices_deferred when deferred.
Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
---
Changes in v3:
* Fix alignment on continuation
* Small fixes to commit message
Changes in v2:
* Use dev_err_probe in more places in probe function (as suggested by Uwe)
* Adjusted commit message
drivers/video/backlight/pwm_bl.c | 34 +++++++++++++++++---------------
1 file changed, 18 insertions(+), 16 deletions(-)
diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c
index 289bd9ce4d36d..5bc9c6c075710 100644
--- a/drivers/video/backlight/pwm_bl.c
+++ b/drivers/video/backlight/pwm_bl.c
@@ -461,10 +461,9 @@ static int pwm_backlight_probe(struct platform_device *pdev)
if (!data) {
ret = pwm_backlight_parse_dt(&pdev->dev, &defdata);
- if (ret < 0) {
- dev_err(&pdev->dev, "failed to find platform data\n");
- return ret;
- }
+ if (ret < 0)
+ return dev_err_probe(&pdev->dev, ret,
+ "failed to find platform data\n");
data = &defdata;
}
@@ -493,24 +492,27 @@ static int pwm_backlight_probe(struct platform_device *pdev)
pb->enable_gpio = devm_gpiod_get_optional(&pdev->dev, "enable",
GPIOD_ASIS);
if (IS_ERR(pb->enable_gpio)) {
- ret = PTR_ERR(pb->enable_gpio);
+ ret = dev_err_probe(&pdev->dev, PTR_ERR(pb->enable_gpio),
+ "failed to acquire enable GPIO\n");
goto err_alloc;
}
pb->power_supply = devm_regulator_get_optional(&pdev->dev, "power");
if (IS_ERR(pb->power_supply)) {
ret = PTR_ERR(pb->power_supply);
- if (ret == -ENODEV)
+ if (ret == -ENODEV) {
pb->power_supply = NULL;
- else
+ } else {
+ dev_err_probe(&pdev->dev, ret,
+ "failed to acquire power regulator\n");
goto err_alloc;
+ }
}
pb->pwm = devm_pwm_get(&pdev->dev, NULL);
if (IS_ERR(pb->pwm)) {
- ret = PTR_ERR(pb->pwm);
- if (ret != -EPROBE_DEFER)
- dev_err(&pdev->dev, "unable to request PWM\n");
+ ret = dev_err_probe(&pdev->dev, PTR_ERR(pb->pwm),
+ "unable to request PWM\n");
goto err_alloc;
}
@@ -530,8 +532,8 @@ static int pwm_backlight_probe(struct platform_device *pdev)
ret = pwm_apply_state(pb->pwm, &state);
if (ret) {
- dev_err(&pdev->dev, "failed to apply initial PWM state: %d\n",
- ret);
+ dev_err_probe(&pdev->dev, ret,
+ "failed to apply initial PWM state");
goto err_alloc;
}
@@ -568,8 +570,8 @@ static int pwm_backlight_probe(struct platform_device *pdev)
ret = pwm_backlight_brightness_default(&pdev->dev, data,
state.period);
if (ret < 0) {
- dev_err(&pdev->dev,
- "failed to setup default brightness table\n");
+ dev_err_probe(&pdev->dev, ret,
+ "failed to setup default brightness table\n");
goto err_alloc;
}
@@ -597,8 +599,8 @@ static int pwm_backlight_probe(struct platform_device *pdev)
bl = backlight_device_register(dev_name(&pdev->dev), &pdev->dev, pb,
&pwm_backlight_ops, &props);
if (IS_ERR(bl)) {
- dev_err(&pdev->dev, "failed to register backlight\n");
- ret = PTR_ERR(bl);
+ ret = dev_err_probe(&pdev->dev, PTR_ERR(bl),
+ "failed to register backlight\n");
goto err_alloc;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH v3 1/1] backlight: pwm_bl: Use dev_err_probe
2023-11-17 12:06 [PATCH v3 1/1] backlight: pwm_bl: Use dev_err_probe Alexander Stein
@ 2023-11-17 18:07 ` Uwe Kleine-König
2023-11-21 15:08 ` Daniel Thompson
2023-11-23 15:37 ` (subset) " Lee Jones
2 siblings, 0 replies; 4+ messages in thread
From: Uwe Kleine-König @ 2023-11-17 18:07 UTC (permalink / raw)
To: Alexander Stein
Cc: Thierry Reding, Lee Jones, Daniel Thompson, Jingoo Han,
Helge Deller, linux-pwm, dri-devel, linux-fbdev
[-- Attachment #1: Type: text/plain, Size: 573 bytes --]
Hello Alexander,
On Fri, Nov 17, 2023 at 01:06:25PM +0100, Alexander Stein wrote:
> Use dev_err_probe to simplify error paths. Also let dev_err_probe handle
> the -EPROBE_DEFER case and add an entry to
> /sys/kernel/debug/devices_deferred when deferred.
>
> Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Thanks
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | https://www.pengutronix.de/ |
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v3 1/1] backlight: pwm_bl: Use dev_err_probe
2023-11-17 12:06 [PATCH v3 1/1] backlight: pwm_bl: Use dev_err_probe Alexander Stein
2023-11-17 18:07 ` Uwe Kleine-König
@ 2023-11-21 15:08 ` Daniel Thompson
2023-11-23 15:37 ` (subset) " Lee Jones
2 siblings, 0 replies; 4+ messages in thread
From: Daniel Thompson @ 2023-11-21 15:08 UTC (permalink / raw)
To: Alexander Stein
Cc: Thierry Reding, Uwe Kleine-König, Lee Jones, Jingoo Han,
Helge Deller, linux-pwm, dri-devel, linux-fbdev
On Fri, Nov 17, 2023 at 01:06:25PM +0100, Alexander Stein wrote:
> Use dev_err_probe to simplify error paths. Also let dev_err_probe handle
> the -EPROBE_DEFER case and add an entry to
> /sys/kernel/debug/devices_deferred when deferred.
>
> Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
Daniel.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: (subset) [PATCH v3 1/1] backlight: pwm_bl: Use dev_err_probe
2023-11-17 12:06 [PATCH v3 1/1] backlight: pwm_bl: Use dev_err_probe Alexander Stein
2023-11-17 18:07 ` Uwe Kleine-König
2023-11-21 15:08 ` Daniel Thompson
@ 2023-11-23 15:37 ` Lee Jones
2 siblings, 0 replies; 4+ messages in thread
From: Lee Jones @ 2023-11-23 15:37 UTC (permalink / raw)
To: Thierry Reding, Uwe Kleine-König, Lee Jones, Daniel Thompson,
Jingoo Han, Helge Deller, Alexander Stein
Cc: linux-pwm, dri-devel, linux-fbdev
On Fri, 17 Nov 2023 13:06:25 +0100, Alexander Stein wrote:
> Use dev_err_probe to simplify error paths. Also let dev_err_probe handle
> the -EPROBE_DEFER case and add an entry to
> /sys/kernel/debug/devices_deferred when deferred.
>
>
Applied, thanks!
[1/1] backlight: pwm_bl: Use dev_err_probe
commit: 58793f263abc8e5233fabf7466219202db09d048
--
Lee Jones [李琼斯]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-11-23 15:37 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-17 12:06 [PATCH v3 1/1] backlight: pwm_bl: Use dev_err_probe Alexander Stein
2023-11-17 18:07 ` Uwe Kleine-König
2023-11-21 15:08 ` Daniel Thompson
2023-11-23 15:37 ` (subset) " Lee Jones
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox