Skip to content

Commit

Permalink
of/base: Take NULL string into account for property with multiple str…
Browse files Browse the repository at this point in the history
…ings

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>
  • Loading branch information
Benoit Cousson authored and Rob Herring committed Dec 19, 2011
1 parent 44ad56b commit 88af7f5
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions drivers/of/base.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 88af7f5

Please sign in to comment.