aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iio/light
diff options
context:
space:
mode:
authorDavid Lechner <dlechner@baylibre.com>2025-06-28 12:52:30 -0500
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2025-07-13 15:36:24 +0100
commit8f02a8d6a7bfcf742bf65202eee3b8a5fc1f374f (patch)
tree3751317152861916c5f6c5c6816d2aa960268b76 /drivers/iio/light
parentiio: imu: adis16400: Use separate structures rather than an array for chip info (diff)
downloadlinux-8f02a8d6a7bfcf742bf65202eee3b8a5fc1f374f.tar.gz
linux-8f02a8d6a7bfcf742bf65202eee3b8a5fc1f374f.zip
iio: light: cm3232: move calibscale to struct cm3232_chip
Move the calibscale field from struct cm3232_als_info to struct cm3232_chip. The chip info struct is supposed to be const while the driver data struct should contain mutable fields. Since calibscale is a mutable field, it should be in the driver data struct. Signed-off-by: David Lechner <dlechner@baylibre.com> Link: https://patch.msgid.link/20250628-iio-const-data-20-v1-1-2bf90b03f9f1@baylibre.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/iio/light')
-rw-r--r--drivers/iio/light/cm3232.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/drivers/iio/light/cm3232.c b/drivers/iio/light/cm3232.c
index e864d2ef036e..b6823a5a0860 100644
--- a/drivers/iio/light/cm3232.c
+++ b/drivers/iio/light/cm3232.c
@@ -54,7 +54,6 @@ static const struct {
struct cm3232_als_info {
u8 regs_cmd_default;
u8 hw_id;
- int calibscale;
int mlux_per_bit;
int mlux_per_bit_base_it;
};
@@ -62,7 +61,6 @@ struct cm3232_als_info {
static struct cm3232_als_info cm3232_als_info_default = {
.regs_cmd_default = CM3232_CMD_DEFAULT,
.hw_id = CM3232_HW_ID,
- .calibscale = CM3232_CALIBSCALE_DEFAULT,
.mlux_per_bit = CM3232_MLUX_PER_BIT_DEFAULT,
.mlux_per_bit_base_it = CM3232_MLUX_PER_BIT_BASE_IT,
};
@@ -70,6 +68,7 @@ static struct cm3232_als_info cm3232_als_info_default = {
struct cm3232_chip {
struct i2c_client *client;
struct cm3232_als_info *als_info;
+ int calibscale;
u8 regs_cmd;
u16 regs_als;
};
@@ -222,7 +221,7 @@ static int cm3232_get_lux(struct cm3232_chip *chip)
chip->regs_als = (u16)ret;
lux *= chip->regs_als;
- lux *= als_info->calibscale;
+ lux *= chip->calibscale;
lux = div_u64(lux, CM3232_CALIBSCALE_RESOLUTION);
lux = div_u64(lux, CM3232_MLUX_PER_LUX);
@@ -237,7 +236,6 @@ static int cm3232_read_raw(struct iio_dev *indio_dev,
int *val, int *val2, long mask)
{
struct cm3232_chip *chip = iio_priv(indio_dev);
- struct cm3232_als_info *als_info = chip->als_info;
int ret;
switch (mask) {
@@ -248,7 +246,7 @@ static int cm3232_read_raw(struct iio_dev *indio_dev,
*val = ret;
return IIO_VAL_INT;
case IIO_CHAN_INFO_CALIBSCALE:
- *val = als_info->calibscale;
+ *val = chip->calibscale;
return IIO_VAL_INT;
case IIO_CHAN_INFO_INT_TIME:
return cm3232_read_als_it(chip, val, val2);
@@ -262,11 +260,10 @@ static int cm3232_write_raw(struct iio_dev *indio_dev,
int val, int val2, long mask)
{
struct cm3232_chip *chip = iio_priv(indio_dev);
- struct cm3232_als_info *als_info = chip->als_info;
switch (mask) {
case IIO_CHAN_INFO_CALIBSCALE:
- als_info->calibscale = val;
+ chip->calibscale = val;
return 0;
case IIO_CHAN_INFO_INT_TIME:
return cm3232_write_als_it(chip, val, val2);
@@ -339,6 +336,7 @@ static int cm3232_probe(struct i2c_client *client)
chip = iio_priv(indio_dev);
i2c_set_clientdata(client, indio_dev);
chip->client = client;
+ chip->calibscale = CM3232_CALIBSCALE_DEFAULT;
indio_dev->channels = cm3232_channels;
indio_dev->num_channels = ARRAY_SIZE(cm3232_channels);