linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] regulator: gpio-regulator: Catch 'no states property' misuse
@ 2012-11-14 11:34 Lee Jones
  2012-11-14 11:43 ` Mark Brown
  0 siblings, 1 reply; 5+ messages in thread
From: Lee Jones @ 2012-11-14 11:34 UTC (permalink / raw)
  To: linux-kernel; +Cc: Lee Jones, Mark Brown, Frank Li

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


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

* Re: [PATCH 1/1] regulator: gpio-regulator: Catch 'no states property' misuse
  2012-11-14 11:34 Lee Jones
@ 2012-11-14 11:43 ` Mark Brown
  2012-11-14 11:50   ` Lee Jones
  0 siblings, 1 reply; 5+ messages in thread
From: Mark Brown @ 2012-11-14 11:43 UTC (permalink / raw)
  To: Lee Jones; +Cc: linux-kernel, Frank Li

[-- Attachment #1: Type: text/plain, Size: 277 bytes --]

On Wed, Nov 14, 2012 at 11:34:48AM +0000, Lee Jones wrote:
> 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.

Applied, thanks.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* Re: [PATCH 1/1] regulator: gpio-regulator: Catch 'no states property' misuse
  2012-11-14 11:43 ` Mark Brown
@ 2012-11-14 11:50   ` Lee Jones
  0 siblings, 0 replies; 5+ messages in thread
From: Lee Jones @ 2012-11-14 11:50 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-kernel, Frank Li

On Wed, 14 Nov 2012, Mark Brown wrote:

> On Wed, Nov 14, 2012 at 11:34:48AM +0000, Lee Jones wrote:
> > 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.
> 
> Applied, thanks.

Ah, sorry Mark, can you unapply this please?

I didn't add my fixups.

Resending.

-- 
Lee Jones
Linaro ST-Ericsson Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

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

* [PATCH 1/1] regulator: gpio-regulator: Catch 'no states property' misuse
@ 2012-11-14 11:51 Lee Jones
  2012-11-14 11:57 ` Mark Brown
  0 siblings, 1 reply; 5+ messages in thread
From: Lee Jones @ 2012-11-14 11:51 UTC (permalink / raw)
  To: linux-kernel; +Cc: Lee Jones, Mark Brown, Frank Li

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..51527c6 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 there are no 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..a7a2974 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


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

* Re: [PATCH 1/1] regulator: gpio-regulator: Catch 'no states property' misuse
  2012-11-14 11:51 [PATCH 1/1] regulator: gpio-regulator: Catch 'no states property' misuse Lee Jones
@ 2012-11-14 11:57 ` Mark Brown
  0 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2012-11-14 11:57 UTC (permalink / raw)
  To: Lee Jones; +Cc: linux-kernel, Frank Li

On Wed, Nov 14, 2012 at 11:51:36AM +0000, Lee Jones wrote:
> 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.

Applied, thanks.

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

end of thread, other threads:[~2012-11-14 11:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-14 11:51 [PATCH 1/1] regulator: gpio-regulator: Catch 'no states property' misuse Lee Jones
2012-11-14 11:57 ` Mark Brown
  -- strict thread matches above, loose matches on Subject: below --
2012-11-14 11:34 Lee Jones
2012-11-14 11:43 ` Mark Brown
2012-11-14 11:50   ` Lee Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).