Skip to content

Commit 5187e03

Browse files
oleremjic23
authored andcommitted
iio: dac: ds4424: reject -128 RAW value
The DS442x DAC uses sign-magnitude encoding, so -128 cannot be represented in hardware (7-bit magnitude). Previously, passing -128 resulted in a truncated value that programmed 0mA (magnitude 0) instead of the expected maximum negative current, effectively failing silently. Reject -128 to avoid producing the wrong current. Fixes: d632a2b ("iio: dac: ds4422/ds4424 dac driver") Cc: stable@vger.kernel.org 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>
1 parent 7ef74d9 commit 5187e03

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

drivers/iio/dac/ds4424.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ static int ds4424_write_raw(struct iio_dev *indio_dev,
140140

141141
switch (mask) {
142142
case IIO_CHAN_INFO_RAW:
143-
if (val < S8_MIN || val > S8_MAX)
143+
if (val <= S8_MIN || val > S8_MAX)
144144
return -EINVAL;
145145

146146
if (val > 0) {

0 commit comments

Comments
 (0)