From: tony@atomide.com (Tony Lindgren)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/3] of/base: Take NULL string into account for property with multiple strings
Date: Wed, 14 Dec 2011 10:18:22 -0800 [thread overview]
Message-ID: <20111214181822.GE32251@atomide.com> (raw)
In-Reply-To: <1323095036-3739-2-git-send-email-b-cousson@ti.com>
* Benoit Cousson <b-cousson@ti.com> [111205 05:53]:
> The current implementation just ignore any NULL string inserted in a
> multiple strings property.
> In some cases we can have a property with a fix number of strings but
> not necessarily used, like for example in a list of valid pinmux modes.
>
> prop = "uart_rx", "uart_tx", "", "", "safe_mode";
>
> Do no skip NULL string and take them into account in
> of_property_read_string_index and of_property_count_strings.
>
> Reported-by: Tony Lindgren <tony@atomide.com>
> Signed-off-by: Benoit Cousson <b-cousson@ti.com>
> Cc: Grant Likely <grant.likely@secretlab.ca>
> Cc: Rob Herring <rob.herring@calxeda.com>
This fix should be merged before people start doing workarounds
in drivers for this:
Tested-by: Tony Lindgren <tony@atomide.com>
> ---
> drivers/of/base.c | 8 +++-----
> 1 files changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/of/base.c b/drivers/of/base.c
> index 9b6588e..b707243 100644
> --- a/drivers/of/base.c
> +++ b/drivers/of/base.c
> @@ -752,7 +752,7 @@ int of_property_read_string_index(struct device_node *np, const char *propname,
>
> for (i = 0; total < prop->length; total += l, p += l) {
> l = strlen(p) + 1;
> - if ((*p != 0) && (i++ == index)) {
> + if (i++ == index) {
> *output = p;
> return 0;
> }
> @@ -790,11 +790,9 @@ int of_property_count_strings(struct device_node *np, const char *propname)
>
> p = prop->value;
>
> - for (i = 0; total < prop->length; total += l, p += l) {
> + for (i = 0; total < prop->length; total += l, p += l, i++)
> l = strlen(p) + 1;
> - if (*p != 0)
> - i++;
> - }
> +
> return i;
> }
> EXPORT_SYMBOL_GPL(of_property_count_strings);
> --
> 1.7.0.4
>
next prev parent reply other threads:[~2011-12-14 18:18 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-05 14:23 [PATCH 0/3] of: Add support for named irq and reg Benoit Cousson
2011-12-05 14:23 ` [PATCH 1/3] of/base: Take NULL string into account for property with multiple strings Benoit Cousson
2011-12-14 18:18 ` Tony Lindgren [this message]
2011-12-19 14:02 ` Rob Herring
2012-01-03 14:15 ` Cousson, Benoit
2012-01-04 7:34 ` Grant Likely
2011-12-05 14:23 ` [PATCH 2/3] of/address: Add reg-names property to name an iomem resource Benoit Cousson
2011-12-05 14:23 ` [PATCH 3/3] of/irq: Add interrupts-names property to name an irq resource Benoit Cousson
2012-01-04 7:17 ` Grant Likely
2012-01-04 14:15 ` Cousson, Benoit
2011-12-19 13:50 ` [PATCH 0/3] of: Add support for named irq and reg Cousson, Benoit
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=20111214181822.GE32251@atomide.com \
--to=tony@atomide.com \
--cc=linux-arm-kernel@lists.infradead.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;
as well as URLs for NNTP newsgroup(s).