Skip to contentSkip to conversation

regulator: pwm-regulator: Make use of the helper function dev_err_probe()

PATCH Superseded Anand Moon 2 participants 3 messages Sep 19, 2021 – Sep 20, 2021

Subsystems (2)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Anand Moon

author
#0 lore raw

PATCH 1/1 regulator: pwm-regulator: Make use of the helper function dev_err_probe()

devm_regulator_register can return -EPROBE_DEFER if the 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.

Fixes 0cd71b9a43ad ("regulator: pwm: Don't warn on probe deferral")
Cc Martin Blumenstingl <[email protected]>
---
 drivers/regulator/pwm-regulator.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/regulator/pwm-regulator.c +3 -3
index 7629476d94ae..451e57a739f8 100644
@@ -382,9 +382,9 @@ static int pwm_regulator_probe(struct platform_device *pdev)
 					    &drvdata->desc, &config);
 	if (IS_ERR(regulator)) {
 		ret = PTR_ERR(regulator);
-		dev_err(&pdev->dev, "Failed to register regulator %s: %d\n",
-			drvdata->desc.name, ret);
-		return ret;
+		return dev_err_probe(&pdev->dev, ret,
+				     "Failed to register regulator %s: %d\n",
+				     drvdata->desc.name, ret);
 	}
 
 	return 0;
Signature · 1 line
2.33.0
#1 lore raw
Quoted 18 lines · Anand Moon

devm_regulator_register can return -EPROBE_DEFER if the 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.

Fixes 0cd71b9a43ad ("regulator: pwm: Don't warn on probe deferral")
Cc Martin Blumenstingl <[email protected]>
---
 drivers/regulator/pwm-regulator.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/regulator/pwm-regulator.c +0 -0
index 7629476d94ae..451e57a739f8 100644

drivers/regulator/pwm-regulator.c static int pwm_regulator_probe(struct platform_device *pdev) · line 387

Quoted 9 lines
drivers/regulator/pwm-regulator.c +3 -3
@@ -382,9 +382,9 @@ static int pwm_regulator_probe(struct platform_device *pdev)
 					    &drvdata->desc, &config);
 	if (IS_ERR(regulator)) {
 		ret = PTR_ERR(regulator);
-		dev_err(&pdev->dev, "Failed to register regulator %s: %d\n",
-			drvdata->desc.name, ret);
-		return ret;
+		return dev_err_probe(&pdev->dev, ret,
+				     "Failed to register regulator %s: %d\n",
+				     drvdata->desc.name, ret);

No need to keep ret and print it since it will be printed by dev_err_probe, pass directly PTR_ERR(regulator) and drop the ": %d" from the error string.

Neil

Quoted 4 lines
drivers/regulator/pwm-regulator.c +0 -0
 	}
 
 	return 0;
author
#2 lore raw

Hi Neil,

Quoted 32 lines · Neil Armstrong
Quoted 18 lines · Anand Moon

devm_regulator_register can return -EPROBE_DEFER if the 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.

Fixes 0cd71b9a43ad ("regulator: pwm: Don't warn on probe deferral")
Cc Martin Blumenstingl <[email protected]>
---
 drivers/regulator/pwm-regulator.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/regulator/pwm-regulator.c +0 -0
index 7629476d94ae..451e57a739f8 100644

drivers/regulator/pwm-regulator.c static int pwm_regulator_probe(struct platform_device *pdev) · line 387

Quoted 9 lines
drivers/regulator/pwm-regulator.c +3 -3
@@ -382,9 +382,9 @@ static int pwm_regulator_probe(struct platform_device *pdev)
                                          &drvdata->desc, &config);
      if (IS_ERR(regulator)) {
              ret = PTR_ERR(regulator);
-             dev_err(&pdev->dev, "Failed to register regulator %s: %d\n",
-                     drvdata->desc.name, ret);
-             return ret;
+             return dev_err_probe(&pdev->dev, ret,
+                                  "Failed to register regulator %s: %d\n",
+                                  drvdata->desc.name, ret);

No need to keep ret and print it since it will be printed by dev_err_probe, pass directly PTR_ERR(regulator) and drop the ": %d" from the error string.

Quoted 2 lines

Neil

Thanks for the input but it's a wrong fix I meant to fix another probe defer with *devm_pwm_get*
I will correct this in the next version..

Thanks
-Anand

Quoted 6 lines

drivers/regulator/pwm-regulator.c static int pwm_regulator_probe(struct platform_device *pdev) · line 390

Quoted 5 lines
drivers/regulator/pwm-regulator.c +0 -0
      }
 
      return 0;

_______________________________________________
linux-amlogic mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-amlogic