From: "Heiko Stübner" <heiko@sntech.de>
To: Mark Brown <broonie@kernel.org>
Cc: linux-kernel@vger.kernel.org, Liam Girdwood <lgirdwood@gmail.com>
Subject: [PATCH v2] regulator: gpio-regulator: fix forgotten gpios-states reading
Date: Thu, 13 Feb 2014 16:34:32 +0100 [thread overview]
Message-ID: <2852394.5yIWXYGTNK@phil> (raw)
In-Reply-To: <20140213111648.GP28112@sirena.org.uk>
From: Heiko Stuebner <heiko.stuebner@bqreaders.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@bqreaders.com>
---
Looks like I missed the dev_warn addition from 2014-02-11.
Patch applies against topic/gpio.
drivers/regulator/gpio-regulator.c | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/drivers/regulator/gpio-regulator.c b/drivers/regulator/gpio-regulator.c
index 9fd5561..989b23b 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. */
--
1.7.10.4
next prev parent reply other threads:[~2014-02-13 15:35 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-12 23:48 [PATCH] regulator: gpio-regulator: fix forgotten gpios-states reading Heiko Stübner
2014-02-13 11:16 ` Mark Brown
2014-02-13 15:34 ` Heiko Stübner [this message]
2014-02-14 14:59 ` [PATCH v2] " Mark Brown
2014-02-13 19:03 ` [PATCH] " Mark Brown
2014-02-13 19:17 ` Heiko Stübner
2014-02-13 21:09 ` Mark Brown
2014-02-13 21:32 ` [PATCH v2 RESEND] " Heiko Stübner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2852394.5yIWXYGTNK@phil \
--to=heiko@sntech.de \
--cc=broonie@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox