diff options
| -rw-r--r-- | drivers/regulator/gpio-regulator.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/drivers/regulator/gpio-regulator.c b/drivers/regulator/gpio-regulator.c index 5491ceeb53cc..9fd55611016c 100644 --- a/drivers/regulator/gpio-regulator.c +++ b/drivers/regulator/gpio-regulator.c | |||
| @@ -136,7 +136,6 @@ static struct gpio_regulator_config * | |||
| 136 | of_get_gpio_regulator_config(struct device *dev, struct device_node *np) | 136 | of_get_gpio_regulator_config(struct device *dev, struct device_node *np) |
| 137 | { | 137 | { |
| 138 | struct gpio_regulator_config *config; | 138 | struct gpio_regulator_config *config; |
| 139 | struct property *prop; | ||
| 140 | const char *regtype; | 139 | const char *regtype; |
| 141 | int proplen, gpio, i; | 140 | int proplen, gpio, i; |
| 142 | int ret; | 141 | int ret; |
| @@ -191,14 +190,12 @@ of_get_gpio_regulator_config(struct device *dev, struct device_node *np) | |||
| 191 | } | 190 | } |
| 192 | 191 | ||
| 193 | /* Fetch states. */ | 192 | /* Fetch states. */ |
| 194 | prop = of_find_property(np, "states", NULL); | 193 | proplen = of_property_count_u32_elems(np, "states"); |
| 195 | if (!prop) { | 194 | if (proplen < 0) { |
| 196 | dev_err(dev, "No 'states' property found\n"); | 195 | dev_err(dev, "No 'states' property found\n"); |
| 197 | return ERR_PTR(-EINVAL); | 196 | return ERR_PTR(-EINVAL); |
| 198 | } | 197 | } |
| 199 | 198 | ||
| 200 | proplen = prop->length / sizeof(int); | ||
| 201 | |||
| 202 | config->states = devm_kzalloc(dev, | 199 | config->states = devm_kzalloc(dev, |
| 203 | sizeof(struct gpio_regulator_state) | 200 | sizeof(struct gpio_regulator_state) |
| 204 | * (proplen / 2), | 201 | * (proplen / 2), |
| @@ -207,10 +204,10 @@ of_get_gpio_regulator_config(struct device *dev, struct device_node *np) | |||
| 207 | return ERR_PTR(-ENOMEM); | 204 | return ERR_PTR(-ENOMEM); |
| 208 | 205 | ||
| 209 | for (i = 0; i < proplen / 2; i++) { | 206 | for (i = 0; i < proplen / 2; i++) { |
| 210 | config->states[i].value = | 207 | of_property_read_u32_index(np, "states", i * 2, |
| 211 | be32_to_cpup((int *)prop->value + (i * 2)); | 208 | &config->states[i].value); |
| 212 | config->states[i].gpios = | 209 | of_property_read_u32_index(np, "states", i * 2 + 1, |
| 213 | be32_to_cpup((int *)prop->value + (i * 2 + 1)); | 210 | &config->states[i].gpios); |
| 214 | } | 211 | } |
| 215 | config->nr_states = i; | 212 | config->nr_states = i; |
| 216 | 213 | ||
