Re: [PATCH v6 1/2] iio: sx9310: Fix access to variable DT array

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Mar 22, 2021 at 1:16 PM Alexandru Ardelean
<ardeleanalex@xxxxxxxxx> wrote:
> On Mon, Mar 22, 2021 at 9:33 AM Gwendal Grignou <gwendal@xxxxxxxxxxxx> wrote:

...

> but i think there may be a bug, in the fact that number of elements in
> the array must be 4 (no more, no less)
> that is, when reading the DT, it implies a variable array size of 1 to
> 4, which doesn't seem true in the code;
>
> maybe a better idea would be to use of_property_read_***variable***_u32_array()
> this would allow for a flexible array size;

Wouldn't work in conjunction with the second patch.
The above API is OF specific.

>                count = of_property_read_variable_u32_array(np,
> "semtech,combined-sensors",
>                                            combined, 1,
> ARRAY_SIZE(combined));   // min 1 , max 4 elements
>                // count must be int, so that if it is negative, the
> array doesn't loop;
>                 for (i = 0; i < count; i++) {
>                         if (combined[i] <= SX9310_NUM_CHANNELS)
>                                 comb_mask |= BIT(combined[i]);
>                 }
>

-- 
With Best Regards,
Andy Shevchenko



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux