From: Alexander Shiyan <eagle.alexander923@gmail.com>
To: barebox@lists.infradead.org
Cc: Alexander Shiyan <eagle.alexander923@gmail.com>
Subject: [PATCH 1/2] regulator: core: Implement regulator_is_enabled() call
Date: Fri, 28 Mar 2025 09:31:21 +0300 [thread overview]
Message-ID: <20250328063122.36276-1-eagle.alexander923@gmail.com> (raw)
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;
+}
+
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;
+}
+
static inline int regulator_set_voltage(struct regulator *regulator,
int min_uV, int max_uV)
{
--
2.39.1
next reply other threads:[~2025-03-28 6:32 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-28 6:31 Alexander Shiyan [this message]
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 ` [PATCH 1/2] regulator: core: Implement regulator_is_enabled() call 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=20250328063122.36276-1-eagle.alexander923@gmail.com \
--to=eagle.alexander923@gmail.com \
--cc=barebox@lists.infradead.org \
/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