Re: [PATCH v2] iio: dac: mcp47feb02: reject out-of-range raw values
From: Andy Shevchenko
Date: Sun Oct 25 2026 - 17:36:56 EST
On Sun, Oct 25, 2026 at 09:18:56PM +0000, David Carlier wrote:
> mcp47feb02_write_raw() writes the user supplied raw value to the DAC
> register without checking it against the chip resolution. The parts
> are 8, 10 or 12 bit, and the bits above the resolution are not
> implemented, so writing 300 to out_voltage0_raw on an 8-bit part sets
> the output to code 44 instead of failing, and -1 is written as 0xffff.
>
> The out-of-range value is also cached in dac_data, so it is written
> back on resume and stored to EEPROM by store_eeprom.
>
> Return -EINVAL for values outside [0, 2^resolution - 1].
LGTM now,
Reviewed-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxx>
--
With Best Regards,
Andy Shevchenko