Skip to content

Commit d4e93e8

Browse files
M-Vaittinenbroonie
authored andcommitted
regulator: bd71815: bd71828: bd9576: Use dev_err_probe()
The dev_err_probe() has (at least) following benefits over dev_err() when printing an error print for a failed function call at a device driver probe: - Omit error level print if error is 'EPRBE_DEFER' - Standardized print format for returned error - return the error value allowing shortening calls like: if (ret) { dev_err(...); return ret; } to if (ret) return dev_err_probe(...); Convert the ROHM BD71828, ROHM BD71815 and ROHM BD9576 regulator drivers to use the dev_err_probe() when returned error is not hard-coded constant. Signed-off-by: Matti Vaittinen <[email protected]> Link: https://lore.kernel.org/r/0b644da4a8f58558ffe474d2593f85c46de2f965.1669203610.git.mazziesaccount@gmail.com Signed-off-by: Mark Brown <[email protected]>
1 parent 44501eb commit d4e93e8

File tree

3 files changed

+38
-47
lines changed

3 files changed

+38
-47
lines changed

drivers/regulator/bd71815-regulator.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -602,12 +602,10 @@ static int bd7181x_probe(struct platform_device *pdev)
602602
config.ena_gpiod = NULL;
603603

604604
rdev = devm_regulator_register(&pdev->dev, desc, &config);
605-
if (IS_ERR(rdev)) {
606-
dev_err(&pdev->dev,
607-
"failed to register %s regulator\n",
608-
desc->name);
609-
return PTR_ERR(rdev);
610-
}
605+
if (IS_ERR(rdev))
606+
return dev_err_probe(&pdev->dev, PTR_ERR(rdev),
607+
"failed to register %s regulator\n",
608+
desc->name);
611609
}
612610
return 0;
613611
}

drivers/regulator/bd71828-regulator.c

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -750,23 +750,20 @@ static int bd71828_probe(struct platform_device *pdev)
750750
rd = &bd71828_rdata[i];
751751
rdev = devm_regulator_register(&pdev->dev,
752752
&rd->desc, &config);
753-
if (IS_ERR(rdev)) {
754-
dev_err(&pdev->dev,
755-
"failed to register %s regulator\n",
756-
rd->desc.name);
757-
return PTR_ERR(rdev);
758-
}
753+
if (IS_ERR(rdev))
754+
return dev_err_probe(&pdev->dev, PTR_ERR(rdev),
755+
"failed to register %s regulator\n",
756+
rd->desc.name);
757+
759758
for (j = 0; j < rd->reg_init_amnt; j++) {
760759
ret = regmap_update_bits(config.regmap,
761760
rd->reg_inits[j].reg,
762761
rd->reg_inits[j].mask,
763762
rd->reg_inits[j].val);
764-
if (ret) {
765-
dev_err(&pdev->dev,
766-
"regulator %s init failed\n",
767-
rd->desc.name);
768-
return ret;
769-
}
763+
if (ret)
764+
return dev_err_probe(&pdev->dev, ret,
765+
"regulator %s init failed\n",
766+
rd->desc.name);
770767
}
771768
}
772769
return 0;

drivers/regulator/bd9576-regulator.c

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -953,30 +953,28 @@ static int bd957x_probe(struct platform_device *pdev)
953953
dev_fwnode(pdev->dev.parent),
954954
"rohm,vout1-en", GPIOD_OUT_LOW,
955955
"vout1-en");
956-
if (!IS_ERR(en)) {
957-
/* VOUT1_OPS gpio ctrl */
958-
/*
959-
* Regulator core prioritizes the ena_gpio over
960-
* enable/disable/is_enabled callbacks so no need to
961-
* clear them. We can still use same ops
962-
*/
956+
957+
/* VOUT1_OPS gpio ctrl */
958+
/*
959+
* Regulator core prioritizes the ena_gpio over
960+
* enable/disable/is_enabled callbacks so no need to clear them
961+
* even if GPIO is used. So, we can still use same ops.
962+
*
963+
* In theory it is possible someone wants to set vout1-en LOW
964+
* during OTP loading and set VOUT1 to be controlled by GPIO -
965+
* but control the GPIO from some where else than this driver.
966+
* For that to work we should unset the is_enabled callback
967+
* here.
968+
*
969+
* I believe such case where rohm,vout1-en-low is set and
970+
* vout1-en-gpios is not is likely to be a misconfiguration.
971+
* So let's just err out for now.
972+
*/
973+
if (!IS_ERR(en))
963974
config.ena_gpiod = en;
964-
} else {
965-
/*
966-
* In theory it is possible someone wants to set
967-
* vout1-en LOW during OTP loading and set VOUT1 to be
968-
* controlled by GPIO - but control the GPIO from some
969-
* where else than this driver. For that to work we
970-
* should unset the is_enabled callback here.
971-
*
972-
* I believe such case where rohm,vout1-en-low is set
973-
* and vout1-en-gpios is not is likely to be a
974-
* misconfiguration. So let's just err out for now.
975-
*/
976-
dev_err(&pdev->dev,
977-
"Failed to get VOUT1 control GPIO\n");
978-
return PTR_ERR(en);
979-
}
975+
else
976+
return dev_err_probe(&pdev->dev, PTR_ERR(en),
977+
"Failed to get VOUT1 control GPIO\n");
980978
}
981979

982980
/*
@@ -1037,12 +1035,10 @@ static int bd957x_probe(struct platform_device *pdev)
10371035

10381036
r->rdev = devm_regulator_register(&pdev->dev, desc,
10391037
&config);
1040-
if (IS_ERR(r->rdev)) {
1041-
dev_err(&pdev->dev,
1042-
"failed to register %s regulator\n",
1043-
desc->name);
1044-
return PTR_ERR(r->rdev);
1045-
}
1038+
if (IS_ERR(r->rdev))
1039+
return dev_err_probe(&pdev->dev, PTR_ERR(r->rdev),
1040+
"failed to register %s regulator\n",
1041+
desc->name);
10461042
/*
10471043
* Clear the VOUT1 GPIO setting - rest of the regulators do not
10481044
* support GPIO control

0 commit comments

Comments
 (0)