From: Marco Felsch <m.felsch@pengutronix.de>
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Barebox List <barebox@lists.infradead.org>
Subject: Re: [PATCH 04/11] regulator: add regulator_get_voltage_internal()
Date: Wed, 20 Sep 2023 13:25:31 +0200 [thread overview]
Message-ID: <20230920112531.jgn5fnjjslccjcsy@pengutronix.de> (raw)
In-Reply-To: <20230920103316.2758383-5-s.hauer@pengutronix.de>
On 23-09-20, Sascha Hauer wrote:
> regulator_get_voltage() works on struct regulator * which may not always
> be available internally, so add a regulator_get_voltage_internal() and
> use it from regulator_get_voltage().
>
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> ---
> drivers/regulator/core.c | 52 +++++++++++++++++++++-------------------
> 1 file changed, 27 insertions(+), 25 deletions(-)
>
> diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
> index 8ef5a2372c..5693fa9634 100644
> --- a/drivers/regulator/core.c
> +++ b/drivers/regulator/core.c
> @@ -121,6 +121,32 @@ static int regulator_set_voltage_internal(struct regulator_dev *rdev,
> return -ENOSYS;
> }
>
> +static int regulator_get_voltage_internal(struct regulator_dev *rdev)
Can we name this regulator_get_voltage_rdev()? This would align the code
with Linux.
Regards,
Marco
> +{
> + int sel, ret;
> +
> + if (rdev->desc->ops->get_voltage_sel) {
> + sel = rdev->desc->ops->get_voltage_sel(rdev);
> + if (sel < 0)
> + return sel;
> + ret = rdev->desc->ops->list_voltage(rdev, sel);
> + } else if (rdev->desc->ops->get_voltage) {
> + ret = rdev->desc->ops->get_voltage(rdev);
> + } else if (rdev->desc->ops->list_voltage) {
> + 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 (rdev->min_uv && rdev->min_uv == rdev->max_uv) {
> + ret = rdev->min_uv;
> + } else if (rdev->supply) {
> + ret = regulator_get_voltage(rdev->supply);
> + } else {
> + return -EINVAL;
> + }
> +
> + return ret;
> +}
> +
> static int regulator_resolve_supply(struct regulator_dev *rdev)
> {
> struct regulator *supply;
> @@ -622,34 +648,10 @@ EXPORT_SYMBOL_GPL(regulator_bulk_free);
>
> int regulator_get_voltage(struct regulator *regulator)
> {
> - struct regulator_dev *rdev;
> - int sel, ret;
> -
> if (!regulator)
> return -EINVAL;
>
> - rdev = regulator->rdev;
> -
> - if (rdev->desc->ops->get_voltage_sel) {
> - sel = rdev->desc->ops->get_voltage_sel(rdev);
> - if (sel < 0)
> - return sel;
> - ret = rdev->desc->ops->list_voltage(rdev, sel);
> - } else if (rdev->desc->ops->get_voltage) {
> - ret = rdev->desc->ops->get_voltage(rdev);
> - } else if (rdev->desc->ops->list_voltage) {
> - 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 (rdev->min_uv && rdev->min_uv == rdev->max_uv) {
> - ret = rdev->min_uv;
> - } else if (rdev->supply) {
> - ret = regulator_get_voltage(rdev->supply);
> - } else {
> - return -EINVAL;
> - }
> -
> - return ret;
> + return regulator_get_voltage_internal(regulator->rdev);
> }
> EXPORT_SYMBOL_GPL(regulator_get_voltage);
>
> --
> 2.39.2
>
>
>
next prev parent reply other threads:[~2023-09-20 11:26 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-20 10:33 [PATCH 00/11] regulator updates Sascha Hauer
2023-09-20 10:33 ` [PATCH 01/11] regulator: rename variable rd to rdev Sascha Hauer
2023-09-20 11:15 ` Marco Felsch
2023-09-20 10:33 ` [PATCH 02/11] regulator: merge struct regulator_internal fields into struct regulator_dev Sascha Hauer
2023-09-20 10:52 ` Marco Felsch
2023-09-20 11:07 ` Sascha Hauer
2023-09-20 11:13 ` Marco Felsch
2023-09-20 11:20 ` Marco Felsch
2023-09-20 10:33 ` [PATCH 03/11] regulator: introduce regulator logging functions Sascha Hauer
2023-09-20 11:22 ` Marco Felsch
2023-09-20 10:33 ` [PATCH 04/11] regulator: add regulator_get_voltage_internal() Sascha Hauer
2023-09-20 11:25 ` Marco Felsch [this message]
2023-09-20 11:45 ` Sascha Hauer
2023-09-20 10:33 ` [PATCH 05/11] regulator: Add missing cases in regulator_map_voltage() Sascha Hauer
2023-09-20 11:28 ` Marco Felsch
2023-09-20 10:33 ` [PATCH 06/11] regulator: stpmic1: add .get_voltage_sel Sascha Hauer
2023-09-20 11:29 ` Marco Felsch
2023-09-20 10:33 ` [PATCH 07/11] regulator: stpmic1: add .supply_name Sascha Hauer
2023-09-20 11:36 ` Marco Felsch
2023-09-20 10:33 ` [PATCH 08/11] regulator: register regulator as last step in of_regulator_register() Sascha Hauer
2023-09-20 11:39 ` Marco Felsch
2023-09-20 10:33 ` [PATCH 09/11] regulator: Set initial voltage Sascha Hauer
2023-09-20 11:51 ` Marco Felsch
2023-09-20 10:33 ` [PATCH 10/11] regulator: drop struct regulator_dev::supply_name Sascha Hauer
2023-09-20 11:51 ` Marco Felsch
2023-09-20 10:33 ` [PATCH 11/11] regulator: print regulator tree Sascha Hauer
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=20230920112531.jgn5fnjjslccjcsy@pengutronix.de \
--to=m.felsch@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=s.hauer@pengutronix.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