* [PATCH] regulator: gpio-regulator: fix forgotten gpios-states reading
@ 2014-02-12 23:48 Heiko Stübner
2014-02-13 11:16 ` Mark Brown
2014-02-13 19:03 ` [PATCH] " Mark Brown
0 siblings, 2 replies; 8+ messages in thread
From: Heiko Stübner @ 2014-02-12 23:48 UTC (permalink / raw)
To: Mark Brown; +Cc: linux-kernel, Liam Girdwood
From: Heiko Stuebner <heiko.stuebner@bqreaders.com>
Commit 934624d6e9f0 ("regulator: gpio-regulator: do not open-code counting
and access of dt array elements") forgot to convert the recently added
gpios-states property using the same pattern.
Convert this instance to use the of-helpers too, resolving the build error.
Signed-off-by: Heiko Stuebner <heiko.stuebner@bqreaders.com>
---
drivers/regulator/gpio-regulator.c | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/drivers/regulator/gpio-regulator.c b/drivers/regulator/gpio-regulator.c
index 500aa3b..64b4413 100644
--- a/drivers/regulator/gpio-regulator.c
+++ b/drivers/regulator/gpio-regulator.c
@@ -171,22 +171,21 @@ of_get_gpio_regulator_config(struct device *dev, struct device_node *np)
if (!config->gpios)
return ERR_PTR(-ENOMEM);
- prop = of_find_property(np, "gpios-states", NULL);
- if (prop) {
- proplen = prop->length / sizeof(int);
- if (proplen != config->nr_gpios) {
- /* gpios <-> gpios-states mismatch */
- prop = NULL;
- }
- }
+ proplen = of_property_count_u32_elems(np, "gpios-states");
+ /* check gpios <-> gpios-states mismatch */
+ if (proplen != config->nr_gpios)
+ proplen = 0;
for (i = 0; i < config->nr_gpios; i++) {
gpio = of_get_named_gpio(np, "gpios", i);
if (gpio < 0)
break;
config->gpios[i].gpio = gpio;
- if (prop && be32_to_cpup((int *)prop->value + i))
- config->gpios[i].flags = GPIOF_OUT_INIT_HIGH;
+ if (proplen > 0) {
+ of_property_read_u32_index(np, "gpios-states", i, &ret);
+ if (ret)
+ config->gpios[i].flags = GPIOF_OUT_INIT_HIGH;
+ }
}
/* Fetch states. */
--
1.7.10.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] regulator: gpio-regulator: fix forgotten gpios-states reading
2014-02-12 23:48 [PATCH] regulator: gpio-regulator: fix forgotten gpios-states reading Heiko Stübner
@ 2014-02-13 11:16 ` Mark Brown
2014-02-13 15:34 ` [PATCH v2] " Heiko Stübner
2014-02-13 19:03 ` [PATCH] " Mark Brown
1 sibling, 1 reply; 8+ messages in thread
From: Mark Brown @ 2014-02-13 11:16 UTC (permalink / raw)
To: Heiko Stübner; +Cc: linux-kernel, Liam Girdwood
[-- Attachment #1: Type: text/plain, Size: 611 bytes --]
On Thu, Feb 13, 2014 at 12:48:52AM +0100, Heiko Stübner wrote:
> From: Heiko Stuebner <heiko.stuebner@bqreaders.com>
> Commit 934624d6e9f0 ("regulator: gpio-regulator: do not open-code counting
> and access of dt array elements") forgot to convert the recently added
> gpios-states property using the same pattern.
> Convert this instance to use the of-helpers too, resolving the build error.
This doesn't apply for me against either topic/gpio or a remerge of
-next that still has your patch on it (I applied a revert for yesterday
to avoid breakage in -next). Can you please check and resend?
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2] regulator: gpio-regulator: fix forgotten gpios-states reading
2014-02-13 11:16 ` Mark Brown
@ 2014-02-13 15:34 ` Heiko Stübner
2014-02-14 14:59 ` Mark Brown
0 siblings, 1 reply; 8+ messages in thread
From: Heiko Stübner @ 2014-02-13 15:34 UTC (permalink / raw)
To: Mark Brown; +Cc: linux-kernel, Liam Girdwood
From: Heiko Stuebner <heiko.stuebner@bqreaders.com>
Commit 934624d6e9f0 ("regulator: gpio-regulator: do not open-code counting
and access of dt array elements") forgot to convert the recently added
gpios-states property using the same pattern.
Convert this instance to use the of-helpers too, resolving the build error.
Signed-off-by: Heiko Stuebner <heiko.stuebner@bqreaders.com>
---
Looks like I missed the dev_warn addition from 2014-02-11.
Patch applies against topic/gpio.
drivers/regulator/gpio-regulator.c | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/drivers/regulator/gpio-regulator.c b/drivers/regulator/gpio-regulator.c
index 9fd5561..989b23b 100644
--- a/drivers/regulator/gpio-regulator.c
+++ b/drivers/regulator/gpio-regulator.c
@@ -171,13 +171,14 @@ of_get_gpio_regulator_config(struct device *dev, struct device_node *np)
if (!config->gpios)
return ERR_PTR(-ENOMEM);
- prop = of_find_property(np, "gpios-states", NULL);
- if (prop) {
- proplen = prop->length / sizeof(int);
- if (proplen != config->nr_gpios) {
- dev_warn(dev, "gpios <-> gpios-states mismatch\n");
- prop = NULL;
- }
+ proplen = of_property_count_u32_elems(np, "gpios-states");
+ /* optional property */
+ if (proplen < 0)
+ proplen = 0;
+
+ if (proplen > 0 && proplen != config->nr_gpios) {
+ dev_warn(dev, "gpios <-> gpios-states mismatch\n");
+ proplen = 0;
}
for (i = 0; i < config->nr_gpios; i++) {
@@ -185,8 +186,11 @@ of_get_gpio_regulator_config(struct device *dev, struct device_node *np)
if (gpio < 0)
break;
config->gpios[i].gpio = gpio;
- if (prop && be32_to_cpup((int *)prop->value + i))
- config->gpios[i].flags = GPIOF_OUT_INIT_HIGH;
+ if (proplen > 0) {
+ of_property_read_u32_index(np, "gpios-states", i, &ret);
+ if (ret)
+ config->gpios[i].flags = GPIOF_OUT_INIT_HIGH;
+ }
}
/* Fetch states. */
--
1.7.10.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] regulator: gpio-regulator: fix forgotten gpios-states reading
2014-02-12 23:48 [PATCH] regulator: gpio-regulator: fix forgotten gpios-states reading Heiko Stübner
2014-02-13 11:16 ` Mark Brown
@ 2014-02-13 19:03 ` Mark Brown
2014-02-13 19:17 ` Heiko Stübner
1 sibling, 1 reply; 8+ messages in thread
From: Mark Brown @ 2014-02-13 19:03 UTC (permalink / raw)
To: Heiko Stübner; +Cc: linux-kernel, Liam Girdwood
[-- Attachment #1: Type: text/plain, Size: 383 bytes --]
On Thu, Feb 13, 2014 at 12:48:52AM +0100, Heiko Stübner wrote:
> From: Heiko Stuebner <heiko.stuebner@bqreaders.com>
>
> Commit 934624d6e9f0 ("regulator: gpio-regulator: do not open-code counting
> and access of dt array elements") forgot to convert the recently added
> gpios-states property using the same pattern.
Morimoto-san sent a fix which did apply so I took that.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] regulator: gpio-regulator: fix forgotten gpios-states reading
2014-02-13 19:03 ` [PATCH] " Mark Brown
@ 2014-02-13 19:17 ` Heiko Stübner
2014-02-13 21:09 ` Mark Brown
0 siblings, 1 reply; 8+ messages in thread
From: Heiko Stübner @ 2014-02-13 19:17 UTC (permalink / raw)
To: Mark Brown; +Cc: linux-kernel, Liam Girdwood
Am Donnerstag, 13. Februar 2014, 19:03:22 schrieb Mark Brown:
> On Thu, Feb 13, 2014 at 12:48:52AM +0100, Heiko Stübner wrote:
> > From: Heiko Stuebner <heiko.stuebner@bqreaders.com>
> >
> > Commit 934624d6e9f0 ("regulator: gpio-regulator: do not open-code counting
> > and access of dt array elements") forgot to convert the recently added
> > gpios-states property using the same pattern.
>
> Morimoto-san sent a fix which did apply so I took that.
The gpio-state code also uses the pattern, that we're trying to remove (open-
coding dt element counting and exposing dtb internals, aka be32_to_cpup).
So reintroducing the "struct property" fixes the compile issue but does not
resolve the underlying issue we're trying to improve.
So I would argue for removing this commit again in favor of my v2 sent 16:34.
Heiko
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] regulator: gpio-regulator: fix forgotten gpios-states reading
2014-02-13 19:17 ` Heiko Stübner
@ 2014-02-13 21:09 ` Mark Brown
2014-02-13 21:32 ` [PATCH v2 RESEND] " Heiko Stübner
0 siblings, 1 reply; 8+ messages in thread
From: Mark Brown @ 2014-02-13 21:09 UTC (permalink / raw)
To: Heiko Stübner; +Cc: linux-kernel, Liam Girdwood
[-- Attachment #1: Type: text/plain, Size: 241 bytes --]
On Thu, Feb 13, 2014 at 08:17:54PM +0100, Heiko Stübner wrote:
> So I would argue for removing this commit again in favor of my v2 sent 16:34.
Yes, that's fine - it hasn't arrived here yet though and I wanted to get
a proper fix in.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2 RESEND] regulator: gpio-regulator: fix forgotten gpios-states reading
2014-02-13 21:09 ` Mark Brown
@ 2014-02-13 21:32 ` Heiko Stübner
0 siblings, 0 replies; 8+ messages in thread
From: Heiko Stübner @ 2014-02-13 21:32 UTC (permalink / raw)
To: Mark Brown; +Cc: linux-kernel, Liam Girdwood
From: Heiko Stuebner <heiko.stuebner@bqreaders.com>
Commit 934624d6e9f0 ("regulator: gpio-regulator: do not open-code counting
and access of dt array elements") forgot to convert the recently added
gpios-states property using the same pattern.
Convert this instance to use the of-helpers too, resolving the build error.
Signed-off-by: Heiko Stuebner <heiko.stuebner@bqreaders.com>
---
Looks like I missed the dev_warn addition from 2014-02-11 in v1.
Patch applies against topic/gpio.
drivers/regulator/gpio-regulator.c | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/drivers/regulator/gpio-regulator.c b/drivers/regulator/gpio-regulator.c
index 9fd5561..989b23b 100644
--- a/drivers/regulator/gpio-regulator.c
+++ b/drivers/regulator/gpio-regulator.c
@@ -171,13 +171,14 @@ of_get_gpio_regulator_config(struct device *dev, struct device_node *np)
if (!config->gpios)
return ERR_PTR(-ENOMEM);
- prop = of_find_property(np, "gpios-states", NULL);
- if (prop) {
- proplen = prop->length / sizeof(int);
- if (proplen != config->nr_gpios) {
- dev_warn(dev, "gpios <-> gpios-states mismatch\n");
- prop = NULL;
- }
+ proplen = of_property_count_u32_elems(np, "gpios-states");
+ /* optional property */
+ if (proplen < 0)
+ proplen = 0;
+
+ if (proplen > 0 && proplen != config->nr_gpios) {
+ dev_warn(dev, "gpios <-> gpios-states mismatch\n");
+ proplen = 0;
}
for (i = 0; i < config->nr_gpios; i++) {
@@ -185,8 +186,11 @@ of_get_gpio_regulator_config(struct device *dev, struct device_node *np)
if (gpio < 0)
break;
config->gpios[i].gpio = gpio;
- if (prop && be32_to_cpup((int *)prop->value + i))
- config->gpios[i].flags = GPIOF_OUT_INIT_HIGH;
+ if (proplen > 0) {
+ of_property_read_u32_index(np, "gpios-states", i, &ret);
+ if (ret)
+ config->gpios[i].flags = GPIOF_OUT_INIT_HIGH;
+ }
}
/* Fetch states. */
--
1.7.10.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v2] regulator: gpio-regulator: fix forgotten gpios-states reading
2014-02-13 15:34 ` [PATCH v2] " Heiko Stübner
@ 2014-02-14 14:59 ` Mark Brown
0 siblings, 0 replies; 8+ messages in thread
From: Mark Brown @ 2014-02-14 14:59 UTC (permalink / raw)
To: Heiko Stübner; +Cc: linux-kernel, Liam Girdwood
[-- Attachment #1: Type: text/plain, Size: 344 bytes --]
On Thu, Feb 13, 2014 at 04:34:32PM +0100, Heiko Stübner wrote:
> From: Heiko Stuebner <heiko.stuebner@bqreaders.com>
>
> Commit 934624d6e9f0 ("regulator: gpio-regulator: do not open-code counting
> and access of dt array elements") forgot to convert the recently added
> gpios-states property using the same pattern.
Applied, thanks.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2014-02-14 18:26 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-12 23:48 [PATCH] regulator: gpio-regulator: fix forgotten gpios-states reading Heiko Stübner
2014-02-13 11:16 ` Mark Brown
2014-02-13 15:34 ` [PATCH v2] " Heiko Stübner
2014-02-14 14:59 ` Mark Brown
2014-02-13 19:03 ` [PATCH] " Mark Brown
2014-02-13 19:17 ` Heiko Stübner
2014-02-13 21:09 ` Mark Brown
2014-02-13 21:32 ` [PATCH v2 RESEND] " Heiko Stübner
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.