Re: [PATCH] iio: dac: mcp4725: Update the cached DAC value only on success
From: Jonathan Cameron
Date: Sun Oct 25 2026 - 18:32:14 EST
On Sun, 25 Oct 2026 23:08:50 +0200
Andy Shevchenko <andriy.shevchenko@xxxxxxxxx> wrote:
> On Sun, Oct 25, 2026 at 11:13:51PM +0900, Baek Kyu, Kim wrote:
> > mcp4725_write_raw() updates dac_value even if mcp4725_set_value() rejects
> > the requested value or reports an I2C transfer error. After writing 1000,
> > a rejected write of 4096 returns -EINVAL without an I2C transfer, but
> > out_voltage0_raw reports 4096. A later powerdown exit sends 00 00 instead
> > of the 03 e8 frame for the last successful value. The EEPROM store path
> > uses the same cache.
> >
> > Return the setter error before updating dac_value. This keeps the last
> > successful software value for readback, powerdown exit and EEPROM writes.
>
> Does it need a Fixes tag?
Yes. Given I wanted to reduce outstanding patches, I added it an applied
to the fixes-togreg branch of iio.git
This goes all the way back to 2012 introduction of the driver.
Fixes: cf35ad61aca2 ("iio: add mcp4725 I2C DAC driver")
>
> > Signed-off-by: Baek Kyu, Kim <pocj8ur4in@xxxxxxxxx>
>