iio: sx9310: Fix access to variable DT array
authorGwendal Grignou <gwendal@chromium.org>
Fri, 26 Mar 2021 18:46:02 +0000 (11:46 -0700)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Wed, 7 Apr 2021 07:36:40 +0000 (08:36 +0100)
commit6f0078ae704d94b1a93e5f3d0a44cf3d8090fa91
tree1756d7e23484f16235f527bf5971254a1c8a87bc
parent194eafc9c1d49b53b59de9821fb63d423344cae3
iio: sx9310: Fix access to variable DT array

With the current code, we want to read 4 entries from DT array
"semtech,combined-sensors". If there are less, we silently fail as
of_property_read_u32_array() returns -EOVERFLOW.

First count the number of entries and if between 1 and 4, collect the
content of the array.

Fixes: 5b19ca2c78a0 ("iio: sx9310: Set various settings from DT")
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20210326184603.251683-2-gwendal@chromium.org
Cc: <stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/proximity/sx9310.c