regulator: pwm-regulator: Make use of the helper function dev_err_probe()
PATCH v3 1/1 regulator: pwm-regulator: Make use of the helper function dev_err_probe()
devm_pwm_get() can return -EPROBE_DEFER if the pwm regulator is not ready yet. Use dev_err_probe() for pwm regulator resources to indicate the deferral reason when waiting for the resource to come up.
---
V2 - Fix the return message and drop the FIX tag in commit. V1 - Fix the wrong probe defer for devm_regulator_register.
- Fix the commit message.
--- drivers/regulator/pwm-regulator.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/regulator/pwm-regulator.c +2 -7
@@ -353,13 +353,8 @@ static int pwm_regulator_probe(struct platform_device *pdev) drvdata->pwm =devm_pwm_get (&pdev->dev,NULL );if (IS_ERR (drvdata->pwm)) { - ret =PTR_ERR (drvdata->pwm); -if (ret == -EPROBE_DEFER ) -dev_dbg (&pdev->dev, -"Failed to get PWM, deferring probe\n" ); -else -dev_err (&pdev->dev,"Failed to get PWM: %d\n" , ret); -return ret; +return dev_err_probe (&pdev->dev,PTR_ERR (drvdata->pwm), +"Failed to get PWM\n" ); }if (init_data->constraints.boot_on || init_data->constraints.always_on)
Signature · 1 line
2.33.0
Hi Anand,
On Tue, Sep 21, 2021 at 11:27 PM Anand Moon <[email protected]> wrote:
[...]
Quoted 4 lines
drivers/regulator/pwm-regulator.c +0
-0@@ -353,13 +353,8 @@ static int pwm_regulator_probe(struct platform_device *pdev) drvdata->pwm =devm_pwm_get (&pdev->dev,NULL );if (IS_ERR (drvdata->pwm)) {
drivers/regulator/pwm-regulator.c static int pwm_regulator_probe(struct platform_device *pdev) · line 358
Quoted 10 lines
drivers/regulator/pwm-regulator.c +2
-7- ret =PTR_ERR (drvdata->pwm); -if (ret == -EPROBE_DEFER ) -dev_dbg (&pdev->dev, -"Failed to get PWM, deferring probe\n" ); -else -dev_err (&pdev->dev,"Failed to get PWM: %d\n" , ret); -return ret; +return dev_err_probe (&pdev->dev,PTR_ERR (drvdata->pwm), +"Failed to get PWM\n" ); }
From functional perspective you're patch is looking good now. I just noticed that the coding-style in the pwm-regulator driver is not not use any curly brackets for the if block when there's only one statement
with the curly brackets removed (and if there are no other changes to this patch) then you can add my:
Best regards,
Martin
Hi Martin,
Quoted 24 lines · Martin Blumenstingl
Hi Anand,
On Tue, Sep 21, 2021 at 11:27 PM Anand Moon <[email protected]> wrote:
[...]Quoted 4 lines
drivers/regulator/pwm-regulator.c +0
-0@@ -353,13 +353,8 @@ static int pwm_regulator_probe(struct platform_device *pdev) drvdata->pwm =devm_pwm_get (&pdev->dev,NULL );if (IS_ERR (drvdata->pwm)) {drivers/regulator/pwm-regulator.c static int pwm_regulator_probe(struct platform_device *pdev) · line 358
Quoted 10 lines
drivers/regulator/pwm-regulator.c +2
-7- ret =PTR_ERR (drvdata->pwm); -if (ret == -EPROBE_DEFER ) -dev_dbg (&pdev->dev, -"Failed to get PWM, deferring probe\n" ); -else -dev_err (&pdev->dev,"Failed to get PWM: %d\n" , ret); -return ret; +return dev_err_probe (&pdev->dev,PTR_ERR (drvdata->pwm), +"Failed to get PWM\n" ); }From functional perspective you're patch is looking good now. I just noticed that the coding-style in the pwm-regulator driver is not not use any curly brackets for the if block when there's only one statement
Quoted 4 lines
with the curly brackets removed (and if there are no other changes to this patch) then you can add my:
Thanks, I will update the patch in the next version.
Quoted 3 lines
Best regards,
Martin
Thanks
-Anand