Skip to content

Commit cd27856

Browse files
Vidhu Sarwalgregkh
authored andcommitted
iio: light: al3010: fix incorrect scale for the highest gain range
commit aa411ad upstream. al3010_scales[] encodes the highest gain range as {0, 1187200}. For IIO_VAL_INT_PLUS_MICRO, the fractional part must be less than 1000000, so the scale 1.1872 should instead be represented as { 1, 187200 }. Since write_raw() compares the value from userspace against this table, writing the advertised 1.1872 scale never matches the malformed entry and returns -EINVAL. As a result, the highest gain range cannot be selected. Reading the scale in that state also reports the malformed value. Fixes: c36b519 ("iio: light: add Dyna-Image AL3010 driver") Signed-off-by: Vidhu Sarwal <vidhu.linux@gmail.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com> Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 9fb4ff0 commit cd27856

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

drivers/iio/light/al3010.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ enum al3xxxx_range {
4242
};
4343

4444
static const int al3010_scales[][2] = {
45-
{0, 1187200}, {0, 296800}, {0, 74200}, {0, 18600}
45+
{ 1, 187200 }, { 0, 296800 }, { 0, 74200 }, { 0, 18600 },
4646
};
4747

4848
static const struct regmap_config al3010_regmap_config = {

0 commit comments

Comments
 (0)