]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
iio: dac: ds4424: support per-variant output range limits
authorOleksij Rempel <o.rempel@pengutronix.de>
Tue, 10 Feb 2026 13:51:07 +0000 (14:51 +0100)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sun, 22 Mar 2026 12:43:48 +0000 (12:43 +0000)
commit8d68801a696ce101349db6896c10afb5f8d1c228
treea01b9c580d605d78d329a3da68e3a1a8c249240a
parent1fa14dd130fae3feccdde112ed26f48042cf5d7b
iio: dac: ds4424: support per-variant output range limits

The DS4402/DS4404 variants operate with a 5-bit resolution (31 steps),
whereas the DS4422/DS4424 support 7-bit (127 steps).

Previously, the driver enforced a hardcoded 7-bit mask (DS4424_DAC_MASK)
for all variants. This allowed users to write values exceeding the 5-bit
range to DS4402/DS4404 devices, resulting in silent truncation or
undefined behavior.

Add a `result_mask` field to the chip_info structure to define the valid
data range for each variant. Use this mask to:
1. Correctly mask register values in read_raw().
2. Return -EINVAL in write_raw() if the input value exceeds the
   variant's capabilities.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/dac/ds4424.c