Skip to content

Commit 85ac6d9

Browse files
javiercarrascocruzjic23
authored andcommitted
iio: adc: MCP3564: fix calib_bias and calib_scale range checks
The current implementation uses the AND (&&) operator to check if the value to write for IIO_CHAN_INFO_CALIBBIAS and IIO_CHAN_INFO_CALIBSCALE is within the valid ranges. The evaluated values are the lower and upper limits of the ranges, so this operation always evaluates to false. The OR (||) operator must be used instead. Signed-off-by: Javier Carrasco <[email protected]> Reviewed-by: Marius Cristea <[email protected]> Link: https://lore.kernel.org/r/[email protected] Cc: <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]>
1 parent 59b75dc commit 85ac6d9

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/iio/adc/mcp3564.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,7 @@ static int mcp3564_write_raw(struct iio_dev *indio_dev,
918918
mutex_unlock(&adc->lock);
919919
return ret;
920920
case IIO_CHAN_INFO_CALIBBIAS:
921-
if (val < mcp3564_calib_bias[0] && val > mcp3564_calib_bias[2])
921+
if (val < mcp3564_calib_bias[0] || val > mcp3564_calib_bias[2])
922922
return -EINVAL;
923923

924924
mutex_lock(&adc->lock);
@@ -928,7 +928,7 @@ static int mcp3564_write_raw(struct iio_dev *indio_dev,
928928
mutex_unlock(&adc->lock);
929929
return ret;
930930
case IIO_CHAN_INFO_CALIBSCALE:
931-
if (val < mcp3564_calib_scale[0] && val > mcp3564_calib_scale[2])
931+
if (val < mcp3564_calib_scale[0] || val > mcp3564_calib_scale[2])
932932
return -EINVAL;
933933

934934
if (adc->calib_scale == val)

0 commit comments

Comments
 (0)