patch "iio: light: opt4001: Fix power down clearing bits of the wrong" added to char-misc-next
Subsystems (2)
This is a note to let you know that I've just added the patch titled
iio: light: opt4001: Fix power down clearing bits of the wrong
to my char-misc git tree which can be found at
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git
in the char-misc-next branch.
The patch will show up in the next release of the linux-next tree (usually sometime within the next 24 hours during the week.)
The patch will also be merged in the next major kernel release during the merge window.
If you have any questions about this process, please let me know.
From 3b2cd82c524c75a2173f2e3f874652a75f81cd1d Mon Sep 17 00:00:00 2001
From: Nikhil Gautam <[email protected]>
Date: Tue, 14 Jul 2026 17:01:31 +0530
Subject: iio: light: opt4001: Fix power down clearing bits of the wrong
register
opt4001_power_down() intends to clear the operating mode bits in the CTRL register but reads OPT4001_DEVICE_ID instead of OPT4001_CTRL, so the value written back to CTRL contains device ID bits rather than the current configuration.
Fix and simplify this by using regmap_clear_bits() on the CTRL register directly in the devm action, and drop opt4001_power_down() which has no other users.
--- drivers/iio/light/opt4001.c | 27 ++++----------------------- 1 file changed, 4 insertions(+), 23 deletions(-)
drivers/iio/light/opt4001.c +4 -23
@@ -222,33 +222,14 @@ static int opt4001_set_conf(struct opt4001_chip *chip)return ret; } -static int opt4001_power_down (struct opt4001_chip *chip) -{ -struct device *dev = &chip->client->dev; -int ret; -unsigned int reg; - - ret =regmap_read (chip->regmap,OPT4001_DEVICE_ID , ®); -if (ret) { -dev_err (dev,"Failed to read configuration\n" ); -return ret; - } - -/* MODE_OFF is 0x0 so just set bits to 0 */ - reg &= ~OPT4001_CTRL_OPER_MODE_MASK ; - - ret =regmap_write (chip->regmap,OPT4001_CTRL , reg); -if (ret) -dev_err (dev,"Failed to set configuration to power down\n" ); - -return ret; -} -static void opt4001_chip_off_action (void *data) {struct opt4001_chip *chip = data; +int ret; -opt4001_power_down (chip); + ret =regmap_clear_bits (chip->regmap,OPT4001_CTRL ,OPT4001_CTRL_OPER_MODE_MASK ); +if (ret) +dev_err (&chip->client->dev,"Failed to power down\n" ); }static const struct iio_chan_spec opt4001_channels[] = {
Signature · 1 line
2.55.0