On 6 November 2012 19:48, Rob Herring <span dir="ltr"><<a href="mailto:robherring2@gmail.com" target="_blank">robherring2@gmail.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5">> diff --git a/drivers/of/base.c b/drivers/of/base.c<br></div></div></blockquote><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5">> +#define of_property_read_array(_np, _pname, _out, _sz)                       \<br>
> +     struct property *_prop = of_find_property(_np, _pname, NULL);   \<br>
> +     const __be32 *_val;                                             \<br>
> +                                                                     \<br>
> +     if (!_prop)                                                     \<br>
> +             return -EINVAL;                                         \<br>
> +     if (!_prop->value)                                              \<br>
> +             return -ENODATA;                                        \<br>
> +     if ((_sz * sizeof(*_out)) > _prop->length)                      \<br>
> +             return -EOVERFLOW;                                      \<br>
> +                                                                     \<br>
> +     _val = _prop->value;                                            \<br>
> +     while (_sz--)                                                   \<br>
> +             *_out++ = (typeof(*_out))be32_to_cpup(_val++);          \<br>
<br>
</div></div>This will not work. You are incrementing _out by 1, 2, or 4 bytes, but<br>
_val is always incremented by 4 bytes.<br>
<br>
According to the dtc commit adding this feature, the values are packed:<br>
<br>
With this patch the following property assignment:<br>
<br>
    property = /bits/ 16 <0x1234 0x5678 0x0 0xffff>;<br>
<br>
is equivalent to:<br>
<br>
    property = <0x12345678 0x0000ffff>;<br></blockquote><div><br></div><div>Something which i haven't expected :(</div><div>I will fix and test it well for all types before sending it now.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div class="im">> +/**<br>
> + * of_property_read_u8_array - Find and read an array of u8 from a property.<br>
> + *<br>
> + * @np:              device node from which the property value is to be read.<br>
> + * @propname:        name of the property to be searched.<br>
> + * @out_value:       pointer to return value, modified only if return value is 0.<br>
> + *<br>
<br>
</div>Missing sz<br>
<div class="im"></div></blockquote></div><br><div>Yes for both misses.</div>