lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <9348920.79Ktlcbcai@phil>
Date:	Thu, 13 Feb 2014 00:48:52 +0100
From:	Heiko Stübner <heiko@...ech.de>
To:	Mark Brown <broonie@...nel.org>
Cc:	linux-kernel@...r.kernel.org, Liam Girdwood <lgirdwood@...il.com>
Subject: [PATCH] regulator: gpio-regulator: fix forgotten gpios-states reading

From: Heiko Stuebner <heiko.stuebner@...eaders.com>

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@...eaders.com>
---
 drivers/regulator/gpio-regulator.c |   19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/drivers/regulator/gpio-regulator.c b/drivers/regulator/gpio-regulator.c
index 500aa3b..64b4413 100644
--- a/drivers/regulator/gpio-regulator.c
+++ b/drivers/regulator/gpio-regulator.c
@@ -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. */
-- 
1.7.10.4


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ