summaryrefslogtreecommitdiff
path: root/drivers/iio/chemical
diff options
context:
space:
mode:
authorHimanshu Jha <himanshujha199640@gmail.com>2018-08-11 15:56:36 +0530
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2018-08-19 20:07:25 +0100
commit892e62fab4983656d3ca5df4e83fdf2b496c06e4 (patch)
treeae9ed0ca9d8c9cf9012f34ac5bbc2561e8d9205b /drivers/iio/chemical
parent010de20412fc40dabfbab926358ecd9c4486dd0d (diff)
iio: chemical: bme680: Add check for val2 in the write_raw function
val2 is responsible for the floating part of the number to be written to the device. We don't need the floating part while writing the oversampling ratio for BME680 since the available oversampling ratios are pure natural numbers. So, add a sanity check to make sure val2 is 0. Signed-off-by: Himanshu Jha <himanshujha199640@gmail.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/iio/chemical')
-rw-r--r--drivers/iio/chemical/bme680_core.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/iio/chemical/bme680_core.c b/drivers/iio/chemical/bme680_core.c
index 5ddeffb29fb0..87666ce8915f 100644
--- a/drivers/iio/chemical/bme680_core.c
+++ b/drivers/iio/chemical/bme680_core.c
@@ -800,6 +800,9 @@ static int bme680_write_raw(struct iio_dev *indio_dev,
{
struct bme680_data *data = iio_priv(indio_dev);
+ if (val2 != 0)
+ return -EINVAL;
+
switch (mask) {
case IIO_CHAN_INFO_OVERSAMPLING_RATIO:
{