Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1f5a9623 authored by Heiko Stuebner's avatar Heiko Stuebner Committed by Mark Brown
Browse files

regulator: gpio-regulator: fix forgotten gpios-states reading



Commit 934624d6 ("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: default avatarHeiko Stuebner <heiko.stuebner@bqreaders.com>
Signed-off-by: default avatarMark Brown <broonie@linaro.org>
parent 934624d6
Loading
Loading
Loading
Loading
+13 −9
Original line number Original line Diff line number Diff line
@@ -171,13 +171,14 @@ of_get_gpio_regulator_config(struct device *dev, struct device_node *np)
	if (!config->gpios)
	if (!config->gpios)
		return ERR_PTR(-ENOMEM);
		return ERR_PTR(-ENOMEM);


	prop = of_find_property(np, "gpios-states", NULL);
	proplen = of_property_count_u32_elems(np, "gpios-states");
	if (prop) {
	/* optional property */
		proplen = prop->length / sizeof(int);
	if (proplen < 0)
		if (proplen != config->nr_gpios) {
		proplen = 0;

	if (proplen > 0 && proplen != config->nr_gpios) {
		dev_warn(dev, "gpios <-> gpios-states mismatch\n");
		dev_warn(dev, "gpios <-> gpios-states mismatch\n");
			prop = NULL;
		proplen = 0;
		}
	}
	}


	for (i = 0; i < config->nr_gpios; i++) {
	for (i = 0; i < config->nr_gpios; i++) {
@@ -185,9 +186,12 @@ of_get_gpio_regulator_config(struct device *dev, struct device_node *np)
		if (gpio < 0)
		if (gpio < 0)
			break;
			break;
		config->gpios[i].gpio = gpio;
		config->gpios[i].gpio = gpio;
		if (prop && be32_to_cpup((int *)prop->value + i))
		if (proplen > 0) {
			of_property_read_u32_index(np, "gpios-states", i, &ret);
			if (ret)
				config->gpios[i].flags = GPIOF_OUT_INIT_HIGH;
				config->gpios[i].flags = GPIOF_OUT_INIT_HIGH;
		}
		}
	}


	/* Fetch states. */
	/* Fetch states. */
	proplen = of_property_count_u32_elems(np, "states");
	proplen = of_property_count_u32_elems(np, "states");