mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/2] regulator: core: Implement regulator_is_enabled() call
@ 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 ` [PATCH 1/2] regulator: core: Implement regulator_is_enabled() call Sascha Hauer
  0 siblings, 2 replies; 3+ messages in thread
From: Alexander Shiyan @ 2025-03-28  6:31 UTC (permalink / raw)
  To: barebox; +Cc: Alexander Shiyan

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




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-03-31  6:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-28  6:31 [PATCH 1/2] regulator: core: Implement regulator_is_enabled() call 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 ` [PATCH 1/2] regulator: core: Implement regulator_is_enabled() call Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox