linux/drivers/iio/light
Aldo Conte 1f4f0bcc52 iio: light: cm3323: fix reg_conf not being initialized correctly
The code stores the return value of i2c_smbus_write_word_data()
in data->reg_conf; however, this value represents the result
of the write operation and not the value actually written to
the configuration register. This meant that the contents of
data->reg_conf did not truly reflect the contents
of the hardware register.

Instead, save the value of the register before the write
and use this value in the I2C write.

The bug was found by code inspection: i2c_smbus_write_word_data()
returns 0 on success, not the value written to the register.

Tested using i2c-stub on a Raspberry Pi 3B running a custom 6.19.10
kernel. Before loading the driver, the configuration register 0x00
CM3323_CMD_CONF was populated with 0x0030 using
`i2cset -y 11 0x10 0x00 0x0030 w`, encoding an integration time of 320ms
in bits[6:4].

Due to incorrect initialization of data->reg_conf in
cm3323_init(), the print of integration_time returns 0.040000
instead of the expected 0.320000. This happens because the read of the
integration_time depends on cm3323_get_it_bits() that is based on the
value of data->reg_conf, which is erroneously set to 0.

With this fix applied, data->reg_conf correctly saves 0x0030 after init
and the successive integration_time reports 0.320000 as expected.

Fixes: 8b05442637 ("iio: light: Add support for Capella CM3323 color sensor")
Cc: stable@vger.kernel.org
Signed-off-by: Aldo Conte <aldocontelk@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-15 12:01:38 +01:00
..
acpi-als.c iio: light: acpi-als: Convert ACPI driver to a platform one 2026-03-14 12:10:21 +00:00
adjd_s311.c iio: light: adjd_s311: Use iio_push_to_buffers_with_ts() to allow source size runtime check 2025-08-16 15:51:54 +01:00
adux1020.c iio: Remove single use of macro definition for regmap name 2025-06-09 07:45:36 +01:00
al3000a.c iio: Remove error prints for devm_add_action_or_reset() 2025-08-16 11:57:08 +01:00
al3010.c iio: normalize array sentinel style 2025-04-22 19:10:04 +01:00
al3320a.c iio: normalize array sentinel style 2025-04-22 19:10:04 +01:00
apds9160.c iio: light: fix several incorrect spellings 2026-03-21 19:12:14 +00:00
apds9300.c iio: Remove single use of macro definition for IRQ name 2025-06-09 07:45:36 +01:00
apds9306.c iio: light: apds9306: remove unused nlux_per_count 2026-03-03 21:20:03 +00:00
apds9960.c iio: light: apds9960: convert to use maple tree register cache 2025-11-09 12:57:05 +00:00
as73211.c iio: light: as73211: remove duplicate zero init of scan.chan[3] 2026-03-21 19:35:56 +00:00
bh1745.c iio: light: Simple conversions to iio_push_to_buffers_with_ts() 2025-08-16 16:00:17 +01:00
bh1750.c iio: light: bh1750: Add hardware reset support via GPIO 2025-04-22 19:09:51 +01:00
bh1780.c iio: light: bh1780: fix PM runtime leak on error path 2026-02-23 08:24:37 +00:00
cm3232.c iio: light: cm3232: make struct cm3232_als_info const 2025-07-13 15:36:24 +01:00
cm3323.c iio: light: cm3323: fix reg_conf not being initialized correctly 2026-05-15 12:01:38 +01:00
cm3605.c iio: normalize array sentinel style 2025-04-22 19:10:04 +01:00
cm32181.c iio: light: Fix spelling mistake "regist" -> "register" 2025-03-04 14:50:52 +00:00
cm36651.c iio: light: Fix spelling mistake "regist" -> "register" 2025-03-04 14:50:52 +00:00
cros_ec_light_prox.c iio: normalize array sentinel style 2025-04-22 19:10:04 +01:00
gp2ap002.c iio: light: Remove redundant pm_runtime_mark_last_busy() calls 2025-08-25 16:13:25 +01:00
gp2ap020a00f.c iio: light: gp2ap020a00f: remove unused debug_reg_addr 2026-03-03 21:20:03 +00:00
hid-sensor-als.c iio: light: Simple conversions to iio_push_to_buffers_with_ts() 2025-08-16 16:00:17 +01:00
hid-sensor-prox.c IIO: New device support, features and cleanup for 6.16 - take 2 2025-05-22 15:54:52 +02:00
iqs621-als.c iio: fix write_event_config signature 2024-11-03 20:33:44 +00:00
isl29018.c iio: light: isl29018: replace sprintf() with safer alternatives 2025-12-21 11:41:12 +00:00
isl29028.c iio: light: Remove redundant pm_runtime_mark_last_busy() calls 2025-08-25 16:13:25 +01:00
isl29125.c iio: light: isl29125: Use iio_push_to_buffers_with_ts() to allow source size runtime check 2025-08-16 15:52:46 +01:00
isl76682.c iio: light: isl76682: make isl76682_range_table const 2025-07-13 15:36:23 +01:00
jsa1212.c iio: Remove single use of macro definition for regmap name 2025-06-09 07:45:36 +01:00
Kconfig iio: light: fix several incorrect spellings 2026-03-21 19:12:14 +00:00
lm3533-als.c iio: Switch back to struct platform_driver::remove() 2024-10-10 19:31:50 +01:00
ltr390.c iio: light: fix several incorrect spellings 2026-03-21 19:12:14 +00:00
ltr501.c iio: light: ltr501: return proper error code from ltr501_get_gain_index() 2026-03-03 21:20:58 +00:00
ltrf216a.c iio: light: Remove redundant pm_runtime_mark_last_busy() calls 2025-08-25 16:13:25 +01:00
lv0104cs.c iio: Drop explicit initialization of struct i2c_device_id::driver_data to 0 2024-05-27 09:48:57 +01:00
Makefile iio: light: add support for veml6046x00 RGBIR color sensor 2025-08-16 11:57:08 +01:00
max44000.c iio: light: max44000: Use iio_push_to_buffers_with_ts() to allow source size runtime check 2025-08-16 15:54:57 +01:00
max44009.c iio: fix write_event_config signature 2024-11-03 20:33:44 +00:00
noa1305.c iio: light: noa1305: Fix up integration time look up 2024-08-17 15:37:37 +01:00
opt3001.c iio: light: fix several incorrect spellings 2026-03-21 19:12:14 +00:00
opt4001.c iio: Remove error prints for devm_add_action_or_reset() 2025-08-16 11:57:08 +01:00
opt4060.c iio: light: opt4060: Use IIO cleanup helpers 2026-01-22 20:53:17 +00:00
pa12203001.c iio: light: Remove redundant pm_runtime_mark_last_busy() calls 2025-08-25 16:13:25 +01:00
rohm-bu27034.c iio: light: Simple conversions to iio_push_to_buffers_with_ts() 2025-08-16 16:00:17 +01:00
rpr0521.c iio: light: Remove redundant pm_runtime_mark_last_busy() calls 2025-08-25 16:13:25 +01:00
si1133.c move asm/unaligned.h to linux/unaligned.h 2024-10-02 17:23:23 -04:00
si1145.c iio: Use IRQF_NO_THREAD 2026-01-29 16:10:44 +00:00
st_uvis25_core.c iio: light: st_uvis25: Use iio_push_to_buffers_with_ts() to allow source size runtime check 2025-08-16 15:55:57 +01:00
st_uvis25_i2c.c iio: normalize array sentinel style 2025-04-22 19:10:04 +01:00
st_uvis25_spi.c iio: normalize array sentinel style 2025-04-22 19:10:04 +01:00
st_uvis25.h iio: light: st_uvis25: Use iio_push_to_buffers_with_ts() to allow source size runtime check 2025-08-16 15:55:57 +01:00
stk3310.c iio: light: Drop unnecessary -ENOMEM messages 2025-08-25 12:36:03 +01:00
tcs3414.c iio: light: tcs3414: Use iio_push_to_buffers_with_ts() to allow source size runtime check 2025-08-16 15:56:47 +01:00
tcs3472.c iio: light: tcs3472: Use iio_push_to_buffers_with_ts() to allow source size runtime check 2025-08-16 15:57:26 +01:00
tsl2563.c iio: normalize array sentinel style 2025-04-22 19:10:04 +01:00
tsl2583.c iio: light: Remove redundant pm_runtime_mark_last_busy() calls 2025-08-25 16:13:25 +01:00
tsl2591.c iio: light: Remove redundant pm_runtime_mark_last_busy() calls 2025-08-25 16:13:25 +01:00
tsl2772.c iio: light: fix several incorrect spellings 2026-03-21 19:12:14 +00:00
tsl4531.c iio: Drop explicit initialization of struct i2c_device_id::driver_data to 0 2024-05-27 09:48:57 +01:00
us5182d.c iio: light: Remove redundant pm_runtime_mark_last_busy() calls 2025-08-25 16:13:25 +01:00
vcnl4000.c iio: light: vcnl4000: add support for regulators 2026-03-21 12:40:30 +00:00
vcnl4035.c iio: light: vcnl4035: fix scan buffer on big-endian 2026-03-21 20:59:50 +00:00
veml3235.c iio: light: veml3235: convert to use maple tree register cache 2025-11-09 12:57:05 +00:00
veml6030.c iio: light: Simple conversions to iio_push_to_buffers_with_ts() 2025-08-16 16:00:17 +01:00
veml6040.c iio: light: Remove dev_err_probe() if error is -ENOMEM 2025-08-25 09:40:45 +01:00
veml6046x00.c iio: light: add support for veml6046x00 RGBIR color sensor 2025-08-16 11:57:08 +01:00
veml6070.c iio: light: veml6070: Fix resource leak in probe error path 2026-04-28 16:36:09 +01:00
veml6075.c iio: normalize array sentinel style 2025-04-22 19:10:04 +01:00
vl6180.c iio: light: vl6180: Use iio_push_to_buffers_with_ts() to allow source size runtime check 2025-08-16 15:59:34 +01:00
zopt2201.c iio: light: zopt2201: use lock guards 2026-02-23 08:24:24 +00:00