iio: chemical: bme680: Add check for val2 in the write_raw function
authorHimanshu Jha <himanshujha199640@gmail.com>
Sat, 11 Aug 2018 10:26:36 +0000 (15:56 +0530)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sun, 19 Aug 2018 19:07:25 +0000 (20:07 +0100)
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>
drivers/iio/chemical/bme680_core.c

index 5ddeffb29fb03f349d394731f136002d046c1094..87666ce8915f826087ea8586dfc870ebf759f029 100644 (file)
@@ -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:
        {