Skip to content

Commit c370118

Browse files
William Breathitt Grayjic23
authored andcommitted
iio: dac: cio-dac: Fix max DAC write value check for 12-bit
The CIO-DAC series of devices only supports DAC values up to 12-bit rather than 16-bit. Trying to write a 16-bit value results in only the lower 12 bits affecting the DAC output which is not what the user expects. Instead, adjust the DAC write value check to reject values larger than 12-bit so that they fail explicitly as invalid for the user. Fixes: 3b8df5f ("iio: Add IIO support for the Measurement Computing CIO-DAC family") Cc: stable@vger.kernel.org Signed-off-by: William Breathitt Gray <william.gray@linaro.org> Link: https://lore.kernel.org/r/20230311002248.8548-1-william.gray@linaro.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
1 parent 099cc90 commit c370118

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/iio/dac/cio-dac.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ static int cio_dac_write_raw(struct iio_dev *indio_dev,
6666
if (mask != IIO_CHAN_INFO_RAW)
6767
return -EINVAL;
6868

69-
/* DAC can only accept up to a 16-bit value */
70-
if ((unsigned int)val > 65535)
69+
/* DAC can only accept up to a 12-bit value */
70+
if ((unsigned int)val > 4095)
7171
return -EINVAL;
7272

7373
priv->chan_out_states[chan->channel] = val;

0 commit comments

Comments
 (0)