diff options
author | Ahmad Fatoum <a.fatoum@pengutronix.de> | 2022-07-24 21:00:03 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2022-08-08 16:22:06 +0200 |
commit | d353ffd5c6e6d4cee6eee72726125c965a0814f0 (patch) | |
tree | 23b52bf3c928923c071d78ed41d4dbde4e190752 | |
parent | 7a06cb799080894e614125802f79b6f5ba1022b0 (diff) | |
download | barebox-d353ffd5c6e6d4cee6eee72726125c965a0814f0.tar.gz barebox-d353ffd5c6e6d4cee6eee72726125c965a0814f0.tar.xz |
regulator: consult min_uv, max_uv for regulator_get_voltage
Fixed regulators currently always end up in the return -EINVAL else
branch. In Linux, the fixed regulator driver parses the DT and will
populate fixed_uV if min_uv and max_uv are equal. For barebox, it's
easier to do this in the core, but the result is the same:
We now can call regulator_get_voltage for fixed regulators.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20220724190006.2160802-3-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r-- | drivers/regulator/core.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 29a335f502..74324772ed 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -569,13 +569,15 @@ EXPORT_SYMBOL_GPL(regulator_bulk_free); int regulator_get_voltage(struct regulator *regulator) { + struct regulator_internal *ri; struct regulator_dev *rdev; int sel, ret; if (!regulator) return -EINVAL; - rdev = regulator->ri->rdev; + ri = regulator->ri; + rdev = ri->rdev; if (rdev->desc->ops->get_voltage_sel) { sel = rdev->desc->ops->get_voltage_sel(rdev); @@ -588,6 +590,8 @@ int regulator_get_voltage(struct regulator *regulator) ret = rdev->desc->ops->list_voltage(rdev, 0); } else if (rdev->desc->fixed_uV && (rdev->desc->n_voltages == 1)) { ret = rdev->desc->fixed_uV; + } else if (ri->min_uv && ri->min_uv == ri->max_uv) { + ret = ri->min_uv; } else { return -EINVAL; } |