[PATCH v1 1/4] iio: light: opt4001: Fix read-modify-write of wrong register in power down
From: Nikhil Gautam
Date: Sun Jul 12 2026 - 16:25:39 EST
opt4001_power_down() intends to clear the operating mode bits in the
CTRL register but reads OPT4001_DEVICE_ID instead of OPT4001_CTRL.
The device ID value with the mode bits masked out is then written to
CTRL, corrupting the conversion time and fault count configuration.
Read the CTRL register instead so only the operating mode bits are
cleared and the rest of the configuration is preserved.
Signed-off-by: Nikhil Gautam <nikhilgtr@xxxxxxxxx>
---
drivers/iio/light/opt4001.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/iio/light/opt4001.c b/drivers/iio/light/opt4001.c
index ba4eb82d9bc2..f2cf496cc243 100644
--- a/drivers/iio/light/opt4001.c
+++ b/drivers/iio/light/opt4001.c
@@ -228,7 +228,7 @@ static int opt4001_power_down(struct opt4001_chip *chip)
int ret;
unsigned int reg;
- ret = regmap_read(chip->regmap, OPT4001_DEVICE_ID, ®);
+ ret = regmap_read(chip->regmap, OPT4001_CTRL, ®);
if (ret) {
dev_err(dev, "Failed to read configuration\n");
return ret;
--
2.39.5