From: Mark Brown <broonie@opensource.wolfsonmicro.com>
To: Liam Girdwood <lrg@slimlogic.co.uk>
Cc: linux-kernel@vger.kernel.org,
Mark Brown <broonie@opensource.wolfsonmicro.com>
Subject: [PATCH 2/6] regulator: Add regulator voltage range check API
Date: Tue, 21 Jul 2009 16:00:24 +0100 [thread overview]
Message-ID: <1248188428-11277-2-git-send-email-broonie@opensource.wolfsonmicro.com> (raw)
In-Reply-To: <1248188428-11277-1-git-send-email-broonie@opensource.wolfsonmicro.com>
Simplify checking of support for voltage ranges by providing an API which
wraps the existing count and list operations.
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
drivers/regulator/core.c | 29 +++++++++++++++++++++++++++++
include/linux/regulator/consumer.h | 2 ++
2 files changed, 31 insertions(+), 0 deletions(-)
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 8445524..33a8c3c 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1442,6 +1442,35 @@ int regulator_list_voltage(struct regulator *regulator, unsigned selector)
EXPORT_SYMBOL_GPL(regulator_list_voltage);
/**
+ * regulator_is_supported_voltage - check if a voltage range can be supported
+ *
+ * @regulator: Regulator to check.
+ * @min_uV: Minimum required voltage in uV.
+ * @max_uV: Maximum required voltage in uV.
+ *
+ * Returns a boolean or a negative error code.
+ */
+int regulator_is_supported_voltage(struct regulator *regulator,
+ int min_uV, int max_uV)
+{
+ int i, voltages, ret;
+
+ ret = regulator_count_voltages(regulator);
+ if (ret < 0)
+ return ret;
+ voltages = ret;
+
+ for (i = 0; i < voltages; i++) {
+ ret = regulator_list_voltage(regulator, i);
+
+ if (ret >= min_uV && ret <= max_uV)
+ return 1;
+ }
+
+ return 0;
+}
+
+/**
* regulator_set_voltage - set regulator output voltage
* @regulator: regulator source
* @min_uV: Minimum required voltage in uV
diff --git a/include/linux/regulator/consumer.h b/include/linux/regulator/consumer.h
index 976b57b..490c5b3 100644
--- a/include/linux/regulator/consumer.h
+++ b/include/linux/regulator/consumer.h
@@ -146,6 +146,8 @@ void regulator_bulk_free(int num_consumers,
int regulator_count_voltages(struct regulator *regulator);
int regulator_list_voltage(struct regulator *regulator, unsigned selector);
+int regulator_is_supported_voltage(struct regulator *regulator,
+ int min_uV, int max_uV);
int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV);
int regulator_get_voltage(struct regulator *regulator);
int regulator_set_current_limit(struct regulator *regulator,
--
1.6.3.3
next prev parent reply other threads:[~2009-07-21 15:00 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-21 15:00 [PATCH 1/6] regulator: Add regulator_get_exclusive() API Mark Brown
2009-07-21 15:00 ` Mark Brown [this message]
2009-07-21 15:00 ` [PATCH 3/6] regulator: Warn when unregistering an in-use regulator Mark Brown
2009-07-21 15:00 ` [PATCH 4/6] regulator: Fix support for deviceless supply mappings Mark Brown
2009-07-21 15:00 ` [PATCH 5/6] regulator: Improve virtual consumer probe error handling Mark Brown
2009-07-21 15:00 ` [PATCH 6/6] regulator: Provide mode to status conversion function Mark Brown
2009-07-22 20:41 ` Liam Girdwood
2009-07-23 8:42 ` Mark Brown
2009-07-22 20:14 ` [PATCH 3/6] regulator: Warn when unregistering an in-use regulator Liam Girdwood
2009-07-23 8:39 ` Mark Brown
2009-07-21 20:49 ` [PATCH 1/6] regulator: Add regulator_get_exclusive() API Daniel Ribeiro
2009-07-22 1:58 ` Eric Miao
2009-07-22 9:58 ` Mark Brown
2009-07-22 20:47 ` Liam Girdwood
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=1248188428-11277-2-git-send-email-broonie@opensource.wolfsonmicro.com \
--to=broonie@opensource.wolfsonmicro.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lrg@slimlogic.co.uk \
/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
all inboxes | Powered by JetHome®