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 <mazziesaccount@gmail.com>
Link: https://lore.kernel.org/r/0b644da4a8f58558ffe474d2593f85c46de2f965.1669203610.git.mazziesaccount@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Matti Vaittinen 2022-11-23 14:00:21 +02:00 committed by Mark Brown
parent 44501eba9b
commit d4e93e8da0
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0
3 changed files with 38 additions and 47 deletions

View File

@ -602,12 +602,10 @@ static int bd7181x_probe(struct platform_device *pdev)
config.ena_gpiod = NULL; config.ena_gpiod = NULL;
rdev = devm_regulator_register(&pdev->dev, desc, &config); rdev = devm_regulator_register(&pdev->dev, desc, &config);
if (IS_ERR(rdev)) { if (IS_ERR(rdev))
dev_err(&pdev->dev, return dev_err_probe(&pdev->dev, PTR_ERR(rdev),
"failed to register %s regulator\n", "failed to register %s regulator\n",
desc->name); desc->name);
return PTR_ERR(rdev);
}
} }
return 0; return 0;
} }

View File

@ -750,23 +750,20 @@ static int bd71828_probe(struct platform_device *pdev)
rd = &bd71828_rdata[i]; rd = &bd71828_rdata[i];
rdev = devm_regulator_register(&pdev->dev, rdev = devm_regulator_register(&pdev->dev,
&rd->desc, &config); &rd->desc, &config);
if (IS_ERR(rdev)) { if (IS_ERR(rdev))
dev_err(&pdev->dev, return dev_err_probe(&pdev->dev, PTR_ERR(rdev),
"failed to register %s regulator\n", "failed to register %s regulator\n",
rd->desc.name); rd->desc.name);
return PTR_ERR(rdev);
}
for (j = 0; j < rd->reg_init_amnt; j++) { for (j = 0; j < rd->reg_init_amnt; j++) {
ret = regmap_update_bits(config.regmap, ret = regmap_update_bits(config.regmap,
rd->reg_inits[j].reg, rd->reg_inits[j].reg,
rd->reg_inits[j].mask, rd->reg_inits[j].mask,
rd->reg_inits[j].val); rd->reg_inits[j].val);
if (ret) { if (ret)
dev_err(&pdev->dev, return dev_err_probe(&pdev->dev, ret,
"regulator %s init failed\n", "regulator %s init failed\n",
rd->desc.name); rd->desc.name);
return ret;
}
} }
} }
return 0; return 0;

View File

@ -953,30 +953,28 @@ static int bd957x_probe(struct platform_device *pdev)
dev_fwnode(pdev->dev.parent), dev_fwnode(pdev->dev.parent),
"rohm,vout1-en", GPIOD_OUT_LOW, "rohm,vout1-en", GPIOD_OUT_LOW,
"vout1-en"); "vout1-en");
if (!IS_ERR(en)) {
/* VOUT1_OPS gpio ctrl */ /* VOUT1_OPS gpio ctrl */
/* /*
* Regulator core prioritizes the ena_gpio over * Regulator core prioritizes the ena_gpio over
* enable/disable/is_enabled callbacks so no need to * enable/disable/is_enabled callbacks so no need to clear them
* clear them. We can still use same ops * even if GPIO is used. So, we can still use same ops.
*/
config.ena_gpiod = en;
} else {
/*
* In theory it is possible someone wants to set
* vout1-en LOW during OTP loading and set VOUT1 to be
* controlled by GPIO - but control the GPIO from some
* where else than this driver. For that to work we
* should unset the is_enabled callback here.
* *
* I believe such case where rohm,vout1-en-low is set * In theory it is possible someone wants to set vout1-en LOW
* and vout1-en-gpios is not is likely to be a * during OTP loading and set VOUT1 to be controlled by GPIO -
* misconfiguration. So let's just err out for now. * but control the GPIO from some where else than this driver.
* For that to work we should unset the is_enabled callback
* here.
*
* I believe such case where rohm,vout1-en-low is set and
* vout1-en-gpios is not is likely to be a misconfiguration.
* So let's just err out for now.
*/ */
dev_err(&pdev->dev, if (!IS_ERR(en))
config.ena_gpiod = en;
else
return dev_err_probe(&pdev->dev, PTR_ERR(en),
"Failed to get VOUT1 control GPIO\n"); "Failed to get VOUT1 control GPIO\n");
return PTR_ERR(en);
}
} }
/* /*
@ -1037,12 +1035,10 @@ static int bd957x_probe(struct platform_device *pdev)
r->rdev = devm_regulator_register(&pdev->dev, desc, r->rdev = devm_regulator_register(&pdev->dev, desc,
&config); &config);
if (IS_ERR(r->rdev)) { if (IS_ERR(r->rdev))
dev_err(&pdev->dev, return dev_err_probe(&pdev->dev, PTR_ERR(r->rdev),
"failed to register %s regulator\n", "failed to register %s regulator\n",
desc->name); desc->name);
return PTR_ERR(r->rdev);
}
/* /*
* Clear the VOUT1 GPIO setting - rest of the regulators do not * Clear the VOUT1 GPIO setting - rest of the regulators do not
* support GPIO control * support GPIO control