iio: core: Fix handling of 'dB'
authorMircea Caprioru <mircea.caprioru@analog.com>
Wed, 1 Apr 2020 11:22:30 +0000 (14:22 +0300)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sun, 19 Apr 2020 16:50:01 +0000 (17:50 +0100)
This patch fixes the call to iio_str_to_fixpoint when using 'dB' sufix.
Before this the scale_db was not used when parsing the string written to
the attribute and it failed with invalid value.

Fixes: b8528224741b ("iio: core: Handle 'dB' suffix in core")
Signed-off-by: Mircea Caprioru <mircea.caprioru@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/industrialio-core.c

index eac63c1..38adb60 100644 (file)
@@ -909,14 +909,11 @@ static ssize_t iio_write_channel_info(struct device *dev,
                        return -EINVAL;
                integer = ch;
        } else {
-               ret = iio_str_to_fixpoint(buf, fract_mult, &integer, &fract);
+               ret = __iio_str_to_fixpoint(buf, fract_mult, &integer, &fract,
+                                           scale_db);
                if (ret)
                        return ret;
        }
-       ret = __iio_str_to_fixpoint(buf, fract_mult, &integer, &fract,
-                                   scale_db);
-       if (ret)
-               return ret;
 
        ret = indio_dev->info->write_raw(indio_dev, this_attr->c,
                                         integer, fract, this_attr->address);