iio: st-sensors: add support for single full scale device
authorGiuseppe Barba <giuseppe.barba@st.com>
Tue, 21 Jul 2015 08:35:42 +0000 (10:35 +0200)
committerJonathan Cameron <jic23@kernel.org>
Thu, 23 Jul 2015 19:43:10 +0000 (20:43 +0100)
Some sensors could have only one full scale value. This means that the
sensor hasn't a full scale register. This commit add a check on the
configured full scale address to support such kind of sensors.

Signed-off-by: Giuseppe Barba <giuseppe.barba@st.com>
Acked-by: Denis Ciocca <denis.ciocca@st.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
drivers/iio/common/st_sensors/st_sensors_core.c

index d44bf16808592131fa3af1a5dab89385568230b2..2e7fdb502645b66f7042220c7d06df7166bde5c4 100644 (file)
@@ -126,6 +126,9 @@ static int st_sensors_set_fullscale(struct iio_dev *indio_dev, unsigned int fs)
        int err, i = 0;
        struct st_sensor_data *sdata = iio_priv(indio_dev);
 
+       if (sdata->sensor_settings->fs.addr == 0)
+               return 0;
+
        err = st_sensors_match_fs(sdata->sensor_settings, fs, &i);
        if (err < 0)
                goto st_accel_set_fullscale_error;