Skip to contentSkip to conversation

iio: core: Fix handling of 'dB'

PATCH Applied Mircea Caprioru 2 participants 2 messages Apr 1, 2020 – Apr 4, 2020 IIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iio: core: Fix handling of 'dB'

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")
---
 drivers/iio/industrialio-core.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/iio/industrialio-core.c +2 -5
index 157d95a24faa..7da9cd2a2b58 100644
@@ -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);
Signature · 1 line
2.17.1
maintainer Applied
#1 lore raw
Quoted 6 lines · On Wed, 1 Apr 2020 14:22:30 +0300 Mircea Caprioru <[email protected]>…

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")

Gah, I guess this messed up around the introduction of the character handling.

Applied to the fixes-togreg branch of iio.git.

Thanks,

Jonathan

Quoted 25 lines
---
 drivers/iio/industrialio-core.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/iio/industrialio-core.c +2 -5
index 157d95a24faa..7da9cd2a2b58 100644
@@ -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);