mirror of
https://github.com/torvalds/linux.git
synced 2026-05-25 07:33:19 +02:00
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 <javier.carrasco.cruz@gmail.com> Reviewed-by: Marius Cristea <marius.cristea@microchip.com> Link: https://lore.kernel.org/r/20231201-mcp3564_range_checks-v1-1-68f4436e22b0@gmail.com Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This commit is contained in:
parent
59b75dcb09
commit
85ac6d92fd
|
|
@ -918,7 +918,7 @@ static int mcp3564_write_raw(struct iio_dev *indio_dev,
|
|||
mutex_unlock(&adc->lock);
|
||||
return ret;
|
||||
case IIO_CHAN_INFO_CALIBBIAS:
|
||||
if (val < mcp3564_calib_bias[0] && val > mcp3564_calib_bias[2])
|
||||
if (val < mcp3564_calib_bias[0] || val > mcp3564_calib_bias[2])
|
||||
return -EINVAL;
|
||||
|
||||
mutex_lock(&adc->lock);
|
||||
|
|
@ -928,7 +928,7 @@ static int mcp3564_write_raw(struct iio_dev *indio_dev,
|
|||
mutex_unlock(&adc->lock);
|
||||
return ret;
|
||||
case IIO_CHAN_INFO_CALIBSCALE:
|
||||
if (val < mcp3564_calib_scale[0] && val > mcp3564_calib_scale[2])
|
||||
if (val < mcp3564_calib_scale[0] || val > mcp3564_calib_scale[2])
|
||||
return -EINVAL;
|
||||
|
||||
if (adc->calib_scale == val)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user