regulator: gpio-regulator: fix forgotten gpios-states reading
PATCH 1/1 regulator: gpio-regulator: fix forgotten gpios-states reading
From: Heiko Stuebner <[email protected]>
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.
--- drivers/regulator/gpio-regulator.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)
drivers/regulator/gpio-regulator.c +9 -10
@@ -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. */
Signature · 1 line
1.7.10.4
Mark Brown
maintainerQuoted 7 lines · Heiko Stübner
From: Heiko Stuebner <[email protected]>
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?
PATCH v2 1/1 regulator: gpio-regulator: fix forgotten gpios-states reading
From: Heiko Stuebner <[email protected]>
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.
---
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(-)
drivers/regulator/gpio-regulator.c +13 -9
@@ -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. */
Signature · 1 line
1.7.10.4
Mark Brown
maintainerQuoted 5 lines · Heiko Stübner
From: Heiko Stuebner <[email protected]>
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.
Am Donnerstag, 13. Februar 2014, 19:03:22 schrieb Mark Brown:
Quoted 8 lines · Heiko Stübner
Quoted 5 lines
From: Heiko Stuebner <[email protected]>
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
Mark Brown
maintainerQuoted 1 line · Heiko Stübner
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.
PATCH RESEND v2 1/1 regulator: gpio-regulator: fix forgotten gpios-states reading
From: Heiko Stuebner <[email protected]>
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.
---
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(-)
drivers/regulator/gpio-regulator.c +13 -9
@@ -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. */
Signature · 1 line
1.7.10.4
Quoted 5 lines · Heiko Stübner
From: Heiko Stuebner <[email protected]>
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.