diff options
author | Benoit Cousson <b-cousson@ti.com> | 2011-12-05 09:23:54 -0500 |
---|---|---|
committer | Rob Herring <rob.herring@calxeda.com> | 2011-12-19 16:40:11 -0500 |
commit | 88af7f58c6f1fa28d617392c791f11317bcb590d (patch) | |
tree | 4787f62c5a7786819682a995c114506c33053e4a /drivers/of | |
parent | 44ad56b7df54cbc8063b46883d183e4e2f09f831 (diff) |
of/base: Take NULL string into account for property with multiple strings
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>
Signed-off-by: Rob Herring <rob.herring@calxeda.com>
Diffstat (limited to 'drivers/of')
-rw-r--r-- | 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 9b6588ef0673..b7072437eb8c 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, | |||
752 | 752 | ||
753 | for (i = 0; total < prop->length; total += l, p += l) { | 753 | for (i = 0; total < prop->length; total += l, p += l) { |
754 | l = strlen(p) + 1; | 754 | l = strlen(p) + 1; |
755 | if ((*p != 0) && (i++ == index)) { | 755 | if (i++ == index) { |
756 | *output = p; | 756 | *output = p; |
757 | return 0; | 757 | return 0; |
758 | } | 758 | } |
@@ -790,11 +790,9 @@ int of_property_count_strings(struct device_node *np, const char *propname) | |||
790 | 790 | ||
791 | p = prop->value; | 791 | p = prop->value; |
792 | 792 | ||
793 | for (i = 0; total < prop->length; total += l, p += l) { | 793 | for (i = 0; total < prop->length; total += l, p += l, i++) |
794 | l = strlen(p) + 1; | 794 | l = strlen(p) + 1; |
795 | if (*p != 0) | 795 | |
796 | i++; | ||
797 | } | ||
798 | return i; | 796 | return i; |
799 | } | 797 | } |
800 | EXPORT_SYMBOL_GPL(of_property_count_strings); | 798 | EXPORT_SYMBOL_GPL(of_property_count_strings); |