From: Richard Fitzgerald <rf@opensource.wolfsonmicro.com>
To: broonie@kernel.org
Cc: lgirdwood@gmail.com, linux-kernel@vger.kernel.org,
patches@opensource.wolfsonmicro.com
Subject: [PATCH] regulator: core: export function to check if regulator always on
Date: Wed, 12 Nov 2014 11:18:35 +0000 [thread overview]
Message-ID: <20141112111835.GA12635@opensource.wolfsonmicro.com> (raw)
Export a function to allow a consumer to check if its supply
regulator is always on. Drivers might wish to take different
action based on this - for example skipping time-consuming
power-saving preparations that are irrelevant if the regulator
cannot be disabled.
Signed-off-by: Richard Fitzgerald <rf@opensource.wolfsonmicro.com>
---
drivers/regulator/core.c | 16 ++++++++++++++++
include/linux/regulator/consumer.h | 6 ++++++
2 files changed, 22 insertions(+), 0 deletions(-)
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index cd87c0c..e93db90 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -2184,6 +2184,22 @@ int regulator_is_enabled(struct regulator *regulator)
EXPORT_SYMBOL_GPL(regulator_is_enabled);
/**
+ * regulator_is_always_on - check if regulator is always on
+ * @regulator: regulator source
+ *
+ * Returns positive if the regulator driver backing the source/client
+ * is always on, false otherwise.
+ */
+int regulator_is_always_on(struct regulator *regulator)
+{
+ if (regulator->always_on)
+ return 1;
+ else
+ return 0;
+}
+EXPORT_SYMBOL_GPL(regulator_is_always_on);
+
+/**
* regulator_can_change_voltage - check if regulator can change voltage
* @regulator: regulator source
*
diff --git a/include/linux/regulator/consumer.h b/include/linux/regulator/consumer.h
index f540b14..bd6daef 100644
--- a/include/linux/regulator/consumer.h
+++ b/include/linux/regulator/consumer.h
@@ -217,6 +217,7 @@ int regulator_bulk_force_disable(int num_consumers,
void regulator_bulk_free(int num_consumers,
struct regulator_bulk_data *consumers);
+int regulator_is_always_on(struct regulator *regulator);
int regulator_can_change_voltage(struct regulator *regulator);
int regulator_count_voltages(struct regulator *regulator);
int regulator_list_voltage(struct regulator *regulator, unsigned selector);
@@ -425,6 +426,11 @@ static inline void regulator_bulk_free(int num_consumers,
{
}
+static inline int regulator_is_always_on(struct regulator *regulator)
+{
+ return 1;
+}
+
static inline int regulator_can_change_voltage(struct regulator *regulator)
{
return 0;
--
1.7.2.5
next reply other threads:[~2014-11-12 11:18 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-12 11:18 Richard Fitzgerald [this message]
2014-11-12 11:35 ` [PATCH] regulator: core: export function to check if regulator always on Mark Brown
2014-11-12 13:07 ` Richard Fitzgerald
2014-11-12 14:58 ` Mark Brown
2014-11-12 16:58 ` Richard Fitzgerald
2014-11-12 17:26 ` Mark Brown
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=20141112111835.GA12635@opensource.wolfsonmicro.com \
--to=rf@opensource.wolfsonmicro.com \
--cc=broonie@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=patches@opensource.wolfsonmicro.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