diff options
author | Jonathan Cameron <Jonathan.Cameron@huawei.com> | 2023-08-07 20:24:16 +0100 |
---|---|---|
committer | Jonathan Cameron <Jonathan.Cameron@huawei.com> | 2023-08-07 20:24:16 +0100 |
commit | 5b02e8cfbd95b502553f8cb5fcb6f1ccdbecfbad (patch) | |
tree | 51e3b67b79bdaae9c83d1c5cd55b953d0ec7ca75 | |
parent | 013574567a60c427c36dbc2a5ff25fec69f9c4b6 (diff) | |
download | iio-hack-test.tar.gz |
iio: light: opt4001: Fix a wrong array iteration limithack-test
In practice it's unlikely anyone would try to set the integration time
to 0 which isn't in the available list and if they did then they would
get index 12 which whilst reserved on the device fits in the field.
However a compiler might get half way through this reasoning and that
might be the cause of
> >> drivers/iio/light/opt4001.c:215:9: error: call to '__compiletime_assert_355' declared with 'error' attribute: FIELD_PREP: value too large for the field
> 215 | reg |= FIELD_PREP(OPT4001_CTRL_CONV_TIME_MASK, chip->int_time);
Even if this isn't the cause, it looks like a bug to me.
Fixes: 9a9608418292 ("iio: light: Add support for TI OPT4001 light sensor")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202308061902.0gVz6bSe-lkp@intel.com/
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
-rw-r--r-- | drivers/iio/light/opt4001.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/iio/light/opt4001.c b/drivers/iio/light/opt4001.c index 502946bf9f946f..83f97870675803 100644 --- a/drivers/iio/light/opt4001.c +++ b/drivers/iio/light/opt4001.c @@ -137,7 +137,7 @@ static int opt4001_als_time_to_index(const u32 als_integration_time) { int i; - for (i = 0; i < ARRAY_SIZE(opt4001_int_time_available); i++) { + for (i = 0; i < ARRAY_SIZE(opt4001_int_time_available) / 2; i++) { if (als_integration_time == opt4001_int_time_available[i][1]) return i; } |