| From a8026822bcae71dc75b33eda12be607cf3a06ac2 Mon Sep 17 00:00:00 2001 |
| From: =?UTF-8?q?Guido=20G=C3=BCnther?= <agx@sigxcpu.org> |
| Date: Fri, 27 Dec 2019 11:22:54 +0100 |
| Subject: [PATCH] iio: light: vcnl4000: Fix scale for vcnl4040 |
| MIME-Version: 1.0 |
| Content-Type: text/plain; charset=UTF-8 |
| Content-Transfer-Encoding: 8bit |
| |
| commit bc80573ea25bb033a58da81b3ce27205b97c088e upstream. |
| |
| According to the data sheet the ambient sensor's scale is 0.12 lux/step |
| (not 0.024 lux/step as used by vcnl4200) when the integration time is |
| 80ms. The integration time is currently hardcoded in the driver to that |
| value. |
| |
| See p. 8 in https://www.vishay.com/docs/84307/designingvcnl4040.pdf |
| |
| Fixes: 5a441aade5b3 ("iio: light: vcnl4000 add support for the VCNL4040 proximity and light sensor") |
| Signed-off-by: Guido Günther <agx@sigxcpu.org> |
| Reviewed-by: Marco Felsch <m.felsch@pengutronix.de> |
| Cc: <Stable@vger.kernel.org> |
| Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> |
| Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> |
| Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com> |
| |
| diff --git a/drivers/iio/light/vcnl4000.c b/drivers/iio/light/vcnl4000.c |
| index 51421ac32517..b010ddac1adb 100644 |
| --- a/drivers/iio/light/vcnl4000.c |
| +++ b/drivers/iio/light/vcnl4000.c |
| @@ -163,7 +163,6 @@ static int vcnl4200_init(struct vcnl4000_data *data) |
| if (ret < 0) |
| return ret; |
| |
| - data->al_scale = 24000; |
| data->vcnl4200_al.reg = VCNL4200_AL_DATA; |
| data->vcnl4200_ps.reg = VCNL4200_PS_DATA; |
| switch (id) { |
| @@ -172,11 +171,13 @@ static int vcnl4200_init(struct vcnl4000_data *data) |
| /* show 54ms in total. */ |
| data->vcnl4200_al.sampling_rate = ktime_set(0, 54000 * 1000); |
| data->vcnl4200_ps.sampling_rate = ktime_set(0, 4200 * 1000); |
| + data->al_scale = 24000; |
| break; |
| case VCNL4040_PROD_ID: |
| /* Integration time is 80ms, add 10ms. */ |
| data->vcnl4200_al.sampling_rate = ktime_set(0, 100000 * 1000); |
| data->vcnl4200_ps.sampling_rate = ktime_set(0, 100000 * 1000); |
| + data->al_scale = 120000; |
| break; |
| } |
| data->vcnl4200_al.last_measurement = ktime_set(0, 0); |
| -- |
| 2.7.4 |
| |