From: Sascha Hauer <s.hauer@pengutronix.de>
To: Alexander Shiyan <eagle.alexander923@gmail.com>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 1/2] regulator: core: Implement regulator_is_enabled() call
Date: Mon, 31 Mar 2025 08:49:21 +0200 [thread overview]
Message-ID: <Z-o68SVbRz4-8lr0@pengutronix.de> (raw)
In-Reply-To: <20250328063122.36276-1-eagle.alexander923@gmail.com>
On Fri, Mar 28, 2025 at 09:31:21AM +0300, Alexander Shiyan wrote:
> Signed-off-by: Alexander Shiyan <eagle.alexander923@gmail.com>
> ---
> drivers/regulator/core.c | 11 +++++++++++
> include/regulator.h | 6 ++++++
> 2 files changed, 17 insertions(+)
>
> diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
> index 2c3b009ea6..c9e30ab3fd 100644
> --- a/drivers/regulator/core.c
> +++ b/drivers/regulator/core.c
> @@ -610,6 +610,17 @@ int regulator_disable(struct regulator *r)
> return regulator_disable_rdev(r->rdev);
> }
>
> +int regulator_is_enabled(struct regulator *r)
> +{
> + if (!r)
> + return 0;
> +
> + if (r->rdev->always_on)
> + return 1;
> +
> + return r->rdev->enable_count;
> +}
This differs from what Linux does. Linux will return the result of the
is_enabled hook here. We should likely do the same and only if the
is_enabled hook is not present return the enable_count.
> +
> int regulator_set_voltage(struct regulator *r, int min_uV, int max_uV)
> {
> if (!r)
> diff --git a/include/regulator.h b/include/regulator.h
> index 9785b8ac07..5fdf1602dd 100644
> --- a/include/regulator.h
> +++ b/include/regulator.h
> @@ -217,6 +217,7 @@ void regulator_put(struct regulator *r);
> struct regulator *regulator_get_name(const char *name);
> int regulator_enable(struct regulator *);
> int regulator_disable(struct regulator *);
> +int regulator_is_enabled(struct regulator *);
> int regulator_is_enabled_regmap(struct regulator_dev *);
> int regulator_enable_regmap(struct regulator_dev *);
> int regulator_disable_regmap(struct regulator_dev *);
> @@ -285,6 +286,11 @@ static inline int regulator_disable(struct regulator *r)
> return 0;
> }
>
> +static inline int regulator_is_enabled(struct regulator *r)
> +{
> + return 0;
> +}
I think we should return true here as it likely makes the consumers
happier.
Sascha
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
prev parent reply other threads:[~2025-03-31 6:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-28 6:31 Alexander Shiyan
2025-03-28 6:31 ` [PATCH 2/2] gpio: clk-gpio: Updating the driver from the kernel repository Alexander Shiyan
2025-03-31 6:49 ` Sascha Hauer [this message]
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=Z-o68SVbRz4-8lr0@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=eagle.alexander923@gmail.com \
/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