summaryrefslogtreecommitdiffstats
path: root/drivers/iio/light/cm32181.c
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2020-04-28 19:29:21 +0200
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2020-05-10 10:46:02 +0100
commit63b1be78774f8c3bdb9efd862ba7dfe8e2c056ff (patch)
tree5e19cc70b2b2eaa237dea6935cf5e3d1e0931bc9 /drivers/iio/light/cm32181.c
parentf50f98310e51b3712a4e544c75615e89c8233125 (diff)
downloadlinux-63b1be78774f8c3bdb9efd862ba7dfe8e2c056ff.tar.gz
linux-63b1be78774f8c3bdb9efd862ba7dfe8e2c056ff.tar.bz2
linux-63b1be78774f8c3bdb9efd862ba7dfe8e2c056ff.zip
iio: light: cm32181: Make lux_per_bit and lux_per_bit_base_it runtime settings
Make lux_per_bit and lux_per_bit_base_it settings stored in struct cm32181_chip instead of a hardcoded (defined) values. This is a preparation patch for reading some ACPI tables which specify a device specific lux_per_bit value. Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/iio/light/cm32181.c')
-rw-r--r--drivers/iio/light/cm32181.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/iio/light/cm32181.c b/drivers/iio/light/cm32181.c
index 84c8d3144d03..a5deb0750313 100644
--- a/drivers/iio/light/cm32181.c
+++ b/drivers/iio/light/cm32181.c
@@ -70,6 +70,8 @@ struct cm32181_chip {
u16 conf_regs[CM32181_CONF_REG_NUM];
unsigned long init_regs_bitmap;
int calibscale;
+ int lux_per_bit;
+ int lux_per_bit_base_it;
int num_als_it;
const int *als_it_bits;
const int *als_it_values;
@@ -115,6 +117,8 @@ static int cm32181_reg_init(struct cm32181_chip *cm32181)
CM32181_CMD_ALS_IT_DEFAULT | CM32181_CMD_ALS_SM_DEFAULT;
cm32181->init_regs_bitmap = BIT(CM32181_REG_ADDR_CMD);
cm32181->calibscale = CM32181_CALIBSCALE_DEFAULT;
+ cm32181->lux_per_bit = CM32181_LUX_PER_BIT;
+ cm32181->lux_per_bit_base_it = CM32181_LUX_PER_BIT_BASE_IT;
/* Initialize registers*/
for_each_set_bit(i, &cm32181->init_regs_bitmap, CM32181_CONF_REG_NUM) {
@@ -211,8 +215,8 @@ static int cm32181_get_lux(struct cm32181_chip *cm32181)
if (ret < 0)
return -EINVAL;
- lux = CM32181_LUX_PER_BIT;
- lux *= CM32181_LUX_PER_BIT_BASE_IT;
+ lux = cm32181->lux_per_bit;
+ lux *= cm32181->lux_per_bit_base_it;
lux = div_u64(lux, als_it);
ret = i2c_smbus_read_word_data(client, CM32181_REG_ADDR_ALS);