diff options
author | Heiko Stuebner <heiko.stuebner@bqreaders.com> | 2014-02-13 10:34:32 -0500 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2014-02-14 09:58:57 -0500 |
commit | 1f5a9623eb4300a722eab2f6c6a31a194c804cec (patch) | |
tree | c83ec1173b71bb9be16d0900522e5cd032aa7767 | |
parent | 934624d6e9f0b3d41557c4105c286e8daeaadb4e (diff) |
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>
-rw-r--r-- | drivers/regulator/gpio-regulator.c | 22 |
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) | |||
171 | if (!config->gpios) | 171 | if (!config->gpios) |
172 | return ERR_PTR(-ENOMEM); | 172 | return ERR_PTR(-ENOMEM); |
173 | 173 | ||
174 | prop = of_find_property(np, "gpios-states", NULL); | 174 | proplen = of_property_count_u32_elems(np, "gpios-states"); |
175 | if (prop) { | 175 | /* optional property */ |
176 | proplen = prop->length / sizeof(int); | 176 | if (proplen < 0) |
177 | if (proplen != config->nr_gpios) { | 177 | proplen = 0; |
178 | dev_warn(dev, "gpios <-> gpios-states mismatch\n"); | 178 | |
179 | prop = NULL; | 179 | if (proplen > 0 && proplen != config->nr_gpios) { |
180 | } | 180 | dev_warn(dev, "gpios <-> gpios-states mismatch\n"); |
181 | proplen = 0; | ||
181 | } | 182 | } |
182 | 183 | ||
183 | for (i = 0; i < config->nr_gpios; i++) { | 184 | for (i = 0; i < config->nr_gpios; i++) { |
@@ -185,8 +186,11 @@ of_get_gpio_regulator_config(struct device *dev, struct device_node *np) | |||
185 | if (gpio < 0) | 186 | if (gpio < 0) |
186 | break; | 187 | break; |
187 | config->gpios[i].gpio = gpio; | 188 | config->gpios[i].gpio = gpio; |
188 | if (prop && be32_to_cpup((int *)prop->value + i)) | 189 | if (proplen > 0) { |
189 | config->gpios[i].flags = GPIOF_OUT_INIT_HIGH; | 190 | of_property_read_u32_index(np, "gpios-states", i, &ret); |
191 | if (ret) | ||
192 | config->gpios[i].flags = GPIOF_OUT_INIT_HIGH; | ||
193 | } | ||
190 | } | 194 | } |
191 | 195 | ||
192 | /* Fetch states. */ | 196 | /* Fetch states. */ |