[PATCH] regulator: core: avoid error messages for deferred probing

From: Andreas Kemnade
Date: Mon Jan 25 2021 - 14:49:01 EST


Noise like this happens on boot with regulators which can be bypassed
when the supply is not probed. That looks too alarming and confusing.

[ 3.844092] vddpu: bypassed regulator has no supply!
[ 3.849105] vddpu: failed to get the current voltage: -EPROBE_DEFER
[ 3.855591] vddpu: supplied by DCDC1
[ 3.877211] vddsoc: bypassed regulator has no supply!
[ 3.882538] vddsoc: failed to get the current voltage: -EPROBE_DEFER
[ 3.888975] vddsoc: supplied by DCDC1

Handle such issues silently.

Signed-off-by: Andreas Kemnade <andreas@xxxxxxxxxxxx>
---
drivers/regulator/core.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index ca03d8e70bd1..238745fc97c2 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1168,6 +1168,9 @@ static int machine_constraints_voltage(struct regulator_dev *rdev,
current_uV = regulator_get_voltage_rdev(rdev);
}

+ if (current_uV == -EPROBE_DEFER)
+ return -EPROBE_DEFER;
+
if (current_uV < 0) {
rdev_err(rdev,
"failed to get the current voltage: %pe\n",
@@ -4151,9 +4154,12 @@ int regulator_get_voltage_rdev(struct regulator_dev *rdev)
if (bypassed) {
/* if bypassed the regulator must have a supply */
if (!rdev->supply) {
+ if (rdev->supply_name)
+ return -EPROBE_DEFER;
+
rdev_err(rdev,
"bypassed regulator has no supply!\n");
- return -EPROBE_DEFER;
+ return -EINVAL;
}

return regulator_get_voltage_rdev(rdev->supply->rdev);
--
2.29.2