mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Frank Wunderlich <frank-w@public-files.de>,
	Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH v3 3/6] regulator: consult min_uv, max_uv for regulator_get_voltage
Date: Sun, 24 Jul 2022 08:43:34 +0200	[thread overview]
Message-ID: <20220724064337.1799613-3-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20220724064337.1799613-1-a.fatoum@pengutronix.de>

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>
---
v2 -> v3:
  - fix botched rebase (regulator->ri-> instead of ri->)
v1 -> v2:
  - new patch
---
 drivers/regulator/core.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 472b26f3a0ac..1c7a8580d983 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -593,6 +593,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 (regulator->ri->min_uv == regulator->ri->max_uv) {
+		ret = regulator->ri->min_uv;
 	} else {
 		return -EINVAL;
 	}
-- 
2.30.2




  parent reply	other threads:[~2022-07-24  6:45 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-24  6:43 [PATCH v3 1/6] mfd: implement mfd_add_devices Ahmad Fatoum
2022-07-24  6:43 ` [PATCH v3 2/6] regmap: implement regmap_init_i2c_smbus Ahmad Fatoum
2022-07-24  6:43 ` Ahmad Fatoum [this message]
2022-07-24  6:43 ` [PATCH v3 4/6] regulator: recursively enable/disable regulator dependency tree Ahmad Fatoum
2022-07-24  6:43 ` [PATCH v3 5/6] regulator: fixed: request vin-supply as needed Ahmad Fatoum
2022-07-24  6:43 ` [PATCH v3 6/6] regulator: add Rockchip rk808 support Ahmad Fatoum

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220724064337.1799613-3-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=frank-w@public-files.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox