From: Lee Jones <lee.jones@linaro.org>
To: linux-kernel@vger.kernel.org
Cc: Lee Jones <lee.jones@linaro.org>,
Mark Brown <broonie@opensource.wolfsonmicro.com>,
Frank Li <Frank.Li@freescale.com>
Subject: [PATCH 1/1] regulator: gpio-regulator: Catch 'no states property' misuse
Date: Wed, 14 Nov 2012 11:34:48 +0000 [thread overview]
Message-ID: <1352892888-15546-1-git-send-email-lee.jones@linaro.org> (raw)
A selection of voltage or current values (AKA states) should always
be specified when using a GPIO regulator. If there are no switchable
states then the fixed regulators should be used instead.
Cc: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: Frank Li <Frank.Li@freescale.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
---
.../bindings/regulator/gpio-regulator.txt | 3 ++-
drivers/regulator/gpio-regulator.c | 5 +++++
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/Documentation/devicetree/bindings/regulator/gpio-regulator.txt b/Documentation/devicetree/bindings/regulator/gpio-regulator.txt
index 3703be2..827fa70 100644
--- a/Documentation/devicetree/bindings/regulator/gpio-regulator.txt
+++ b/Documentation/devicetree/bindings/regulator/gpio-regulator.txt
@@ -2,11 +2,12 @@ GPIO controlled regulators
Required properties:
- compatible : Must be "regulator-gpio".
+- states : Selection of available voltages and GPIO configs.
+ (if you don't have states, then use a fixed regulator)
Optional properties:
- gpio-enable : GPIO to use to enable/disable the regulator.
- gpios : GPIO group used to control voltage.
-- states : Selection of available voltages and GPIO configs.
- startup-delay-us : Startup time in microseconds.
- enable-active-high : Polarity of GPIO is active high (default is low).
diff --git a/drivers/regulator/gpio-regulator.c b/drivers/regulator/gpio-regulator.c
index e467d0a..c82edab 100644
--- a/drivers/regulator/gpio-regulator.c
+++ b/drivers/regulator/gpio-regulator.c
@@ -183,6 +183,11 @@ of_get_gpio_regulator_config(struct device *dev, struct device_node *np)
/* Fetch states. */
prop = of_find_property(np, "states", NULL);
+ if (!prop) {
+ dev_err(&dev, "No 'states' property found\n");
+ return ERR_PTR(-EINVAL);
+ }
+
proplen = prop->length / sizeof(int);
config->states = devm_kzalloc(dev,
--
1.7.9.5
next reply other threads:[~2012-11-14 11:35 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-14 11:34 Lee Jones [this message]
2012-11-14 11:43 ` Mark Brown
2012-11-14 11:50 ` Lee Jones
2012-11-14 11:51 Lee Jones
2012-11-14 11:57 ` 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=1352892888-15546-1-git-send-email-lee.jones@linaro.org \
--to=lee.jones@linaro.org \
--cc=Frank.Li@freescale.com \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=linux-kernel@vger.kernel.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
all inboxes | Powered by JetHome®