summaryrefslogtreecommitdiffstats
path: root/drivers/regulator/gpio-regulator.c
diff options
context:
space:
mode:
authorHeiko Stuebner <heiko.stuebner@bqreaders.com>2014-02-13 16:34:32 +0100
committerMark Brown <broonie@linaro.org>2014-02-14 14:58:57 +0000
commit1f5a9623eb4300a722eab2f6c6a31a194c804cec (patch)
treec83ec1173b71bb9be16d0900522e5cd032aa7767 /drivers/regulator/gpio-regulator.c
parent934624d6e9f0b3d41557c4105c286e8daeaadb4e (diff)
downloadlinux-1f5a9623eb4300a722eab2f6c6a31a194c804cec.tar.gz
linux-1f5a9623eb4300a722eab2f6c6a31a194c804cec.tar.bz2
linux-1f5a9623eb4300a722eab2f6c6a31a194c804cec.zip
regulator: gpio-regulator: fix forgotten gpios-states reading
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> Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'drivers/regulator/gpio-regulator.c')
-rw-r--r--drivers/regulator/gpio-regulator.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/drivers/regulator/gpio-regulator.c b/drivers/regulator/gpio-regulator.c
index 9fd55611016c..989b23b377c0 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. */