linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iio: core: Fix handling of 'dB'
@ 2020-04-01 11:22 Mircea Caprioru
  2020-04-04 16:46 ` Jonathan Cameron
  0 siblings, 1 reply; 2+ messages in thread
From: Mircea Caprioru @ 2020-04-01 11:22 UTC (permalink / raw)
  To: jic23
  Cc: Michael.Hennerich, alexandru.ardelean, lars, gregkh,
	linux-kernel, linux-iio, Mircea Caprioru

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>
---
 drivers/iio/industrialio-core.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
index 157d95a24faa..7da9cd2a2b58 100644
--- a/drivers/iio/industrialio-core.c
+++ b/drivers/iio/industrialio-core.c
@@ -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);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] iio: core: Fix handling of 'dB'
  2020-04-01 11:22 [PATCH] iio: core: Fix handling of 'dB' Mircea Caprioru
@ 2020-04-04 16:46 ` Jonathan Cameron
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2020-04-04 16:46 UTC (permalink / raw)
  To: Mircea Caprioru
  Cc: Michael.Hennerich, alexandru.ardelean, lars, gregkh,
	linux-kernel, linux-iio

On Wed, 1 Apr 2020 14:22:30 +0300
Mircea Caprioru <mircea.caprioru@analog.com> wrote:

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

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

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

Thanks,

Jonathan

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-04-04 16:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-01 11:22 [PATCH] iio: core: Fix handling of 'dB' Mircea Caprioru
2020-04-04 16:46 ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).