]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
iio: light: veml6030: fix microlux value calculation
authorJavier Carrasco <javier.carrasco.cruz@gmail.com>
Wed, 16 Oct 2024 17:04:31 +0000 (19:04 +0200)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Thu, 24 Oct 2024 17:30:03 +0000 (18:30 +0100)
The raw value conversion to obtain a measurement in lux as
INT_PLUS_MICRO does not calculate the decimal part properly to display
it as micro (in this case microlux). It only calculates the module to
obtain the decimal part from a resolution that is 10000 times the
provided in the datasheet (0.5376 lux/cnt for the veml6030). The
resulting value must still be multiplied by 100 to make it micro.

This bug was introduced with the original implementation of the driver.

Only the illuminance channel is fixed becuase the scale is non sensical
for the intensity channels anyway.

Cc: stable@vger.kernel.org
Fixes: 7b779f573c48 ("iio: light: add driver for veml6030 ambient light sensor")
Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Link: https://patch.msgid.link/20241016-veml6030-fix-processed-micro-v1-1-4a5644796437@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/light/veml6030.c

index 9630de1c578ecbc3a4f64cd645c59d7a50f3be9d..621428885455c0591b93411fe146d7b5ec92357b 100644 (file)
@@ -522,7 +522,7 @@ static int veml6030_read_raw(struct iio_dev *indio_dev,
                        }
                        if (mask == IIO_CHAN_INFO_PROCESSED) {
                                *val = (reg * data->cur_resolution) / 10000;
-                               *val2 = (reg * data->cur_resolution) % 10000;
+                               *val2 = (reg * data->cur_resolution) % 10000 * 100;
                                return IIO_VAL_INT_PLUS_MICRO;
                        }
                        *val = reg;