iio: st_sensors: make BDU optional
authorLinus Walleij <linus.walleij@linaro.org>
Thu, 30 Apr 2015 13:15:48 +0000 (15:15 +0200)
committerJonathan Cameron <jic23@kernel.org>
Thu, 7 May 2015 09:42:33 +0000 (10:42 +0100)
Not all sensors support BDU (block data update) and in fact a
bunch of the in-kernel sensor settings do not specify the
BDU address field. Make this optional.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
drivers/iio/common/st_sensors/st_sensors_core.c

index 5a01093b29a21d040ad000cb8ad56eb1db5742e5..cbeb5e01bc3ab461ad93bb97e921a2015e6e20c5 100644 (file)
@@ -344,11 +344,13 @@ int st_sensors_init_sensor(struct iio_dev *indio_dev,
                return err;
 
        /* set BDU */
-       err = st_sensors_write_data_with_mask(indio_dev,
+       if (sdata->sensor_settings->bdu.addr) {
+               err = st_sensors_write_data_with_mask(indio_dev,
                                        sdata->sensor_settings->bdu.addr,
                                        sdata->sensor_settings->bdu.mask, true);
-       if (err < 0)
-               return err;
+               if (err < 0)
+                       return err;
+       }
 
        err = st_sensors_set_axis_enable(indio_dev, ST_SENSORS_ENABLE_ALL_AXIS);