Skip to content

Commit 58793f2

Browse files
tq-steinalag-linaro
authored andcommitted
backlight: pwm_bl: Use dev_err_probe
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> Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org> Link: https://lore.kernel.org/r/20231117120625.2398417-1-alexander.stein@ew.tq-group.com Signed-off-by: Lee Jones <lee@kernel.org>
1 parent 2e91451 commit 58793f2

1 file changed

Lines changed: 18 additions & 16 deletions

File tree

drivers/video/backlight/pwm_bl.c

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -461,10 +461,9 @@ static int pwm_backlight_probe(struct platform_device *pdev)
461461

462462
if (!data) {
463463
ret = pwm_backlight_parse_dt(&pdev->dev, &defdata);
464-
if (ret < 0) {
465-
dev_err(&pdev->dev, "failed to find platform data\n");
466-
return ret;
467-
}
464+
if (ret < 0)
465+
return dev_err_probe(&pdev->dev, ret,
466+
"failed to find platform data\n");
468467

469468
data = &defdata;
470469
}
@@ -493,24 +492,27 @@ static int pwm_backlight_probe(struct platform_device *pdev)
493492
pb->enable_gpio = devm_gpiod_get_optional(&pdev->dev, "enable",
494493
GPIOD_ASIS);
495494
if (IS_ERR(pb->enable_gpio)) {
496-
ret = PTR_ERR(pb->enable_gpio);
495+
ret = dev_err_probe(&pdev->dev, PTR_ERR(pb->enable_gpio),
496+
"failed to acquire enable GPIO\n");
497497
goto err_alloc;
498498
}
499499

500500
pb->power_supply = devm_regulator_get_optional(&pdev->dev, "power");
501501
if (IS_ERR(pb->power_supply)) {
502502
ret = PTR_ERR(pb->power_supply);
503-
if (ret == -ENODEV)
503+
if (ret == -ENODEV) {
504504
pb->power_supply = NULL;
505-
else
505+
} else {
506+
dev_err_probe(&pdev->dev, ret,
507+
"failed to acquire power regulator\n");
506508
goto err_alloc;
509+
}
507510
}
508511

509512
pb->pwm = devm_pwm_get(&pdev->dev, NULL);
510513
if (IS_ERR(pb->pwm)) {
511-
ret = PTR_ERR(pb->pwm);
512-
if (ret != -EPROBE_DEFER)
513-
dev_err(&pdev->dev, "unable to request PWM\n");
514+
ret = dev_err_probe(&pdev->dev, PTR_ERR(pb->pwm),
515+
"unable to request PWM\n");
514516
goto err_alloc;
515517
}
516518

@@ -530,8 +532,8 @@ static int pwm_backlight_probe(struct platform_device *pdev)
530532

531533
ret = pwm_apply_state(pb->pwm, &state);
532534
if (ret) {
533-
dev_err(&pdev->dev, "failed to apply initial PWM state: %d\n",
534-
ret);
535+
dev_err_probe(&pdev->dev, ret,
536+
"failed to apply initial PWM state");
535537
goto err_alloc;
536538
}
537539

@@ -568,8 +570,8 @@ static int pwm_backlight_probe(struct platform_device *pdev)
568570
ret = pwm_backlight_brightness_default(&pdev->dev, data,
569571
state.period);
570572
if (ret < 0) {
571-
dev_err(&pdev->dev,
572-
"failed to setup default brightness table\n");
573+
dev_err_probe(&pdev->dev, ret,
574+
"failed to setup default brightness table\n");
573575
goto err_alloc;
574576
}
575577

@@ -597,8 +599,8 @@ static int pwm_backlight_probe(struct platform_device *pdev)
597599
bl = backlight_device_register(dev_name(&pdev->dev), &pdev->dev, pb,
598600
&pwm_backlight_ops, &props);
599601
if (IS_ERR(bl)) {
600-
dev_err(&pdev->dev, "failed to register backlight\n");
601-
ret = PTR_ERR(bl);
602+
ret = dev_err_probe(&pdev->dev, PTR_ERR(bl),
603+
"failed to register backlight\n");
602604
goto err_alloc;
603605
}
604606

0 commit comments

Comments
 (0)