All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lars-Peter Clausen <lars@metafoo.de>
To: Oleksandr Kravchenko <x0199363@ti.com>
Cc: jic23@cam.ac.uk, linux-iio@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Oleksandr Kravchenko <o.v.kravchenko@globallogic.com>
Subject: Re: [PATCH] iio: core: Avoid double minus in sysfs output
Date: Thu, 18 Jul 2013 18:24:29 +0200	[thread overview]
Message-ID: <51E816BD.9010302@metafoo.de> (raw)
In-Reply-To: <1374162430-30709-1-git-send-email-x0199363@ti.com>

On 07/18/2013 05:47 PM, Oleksandr Kravchenko wrote:
> From: Oleksandr Kravchenko <o.v.kravchenko@globallogic.com>
> 
> This patch fixes the issue with double minus in output when
> reading channels from sysfs for IIO_VAL_INT_PLUS_MICRO and
> IIO_VAL_INT_PLUS_NANO cases. Until this patch if val and val2
> both are negatives output string contains "--" before
> digits. It is result of "-%d..." in sprintf() format.
> 

Hm, this might be a bug in a driver that is triggering this. The idea is
that val2 is only allowed to be negative if val is 0.

- Lars

> Signed-off-by: Oleksandr Kravchenko <o.v.kravchenko@globallogic.com>
> ---
>  drivers/iio/industrialio-core.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
> index d56d122..b3d3959 100644
> --- a/drivers/iio/industrialio-core.c
> +++ b/drivers/iio/industrialio-core.c
> @@ -383,14 +383,14 @@ static ssize_t iio_read_channel_info(struct device *dev,
>  		scale_db = true;
>  	case IIO_VAL_INT_PLUS_MICRO:
>  		if (val2 < 0)
> -			return sprintf(buf, "-%d.%06u%s\n", val, -val2,
> +			return sprintf(buf, "-%d.%06u%s\n", abs(val), -val2,
>  				scale_db ? " dB" : "");
>  		else
>  			return sprintf(buf, "%d.%06u%s\n", val, val2,
>  				scale_db ? " dB" : "");
>  	case IIO_VAL_INT_PLUS_NANO:
>  		if (val2 < 0)
> -			return sprintf(buf, "-%d.%09u\n", val, -val2);
> +			return sprintf(buf, "-%d.%09u\n", abs(val), -val2);
>  		else
>  			return sprintf(buf, "%d.%09u\n", val, val2);
>  	case IIO_VAL_FRACTIONAL:
> 


  reply	other threads:[~2013-07-18 16:23 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-18 15:47 [PATCH] iio: core: Avoid double minus in sysfs output Oleksandr Kravchenko
2013-07-18 16:24 ` Lars-Peter Clausen [this message]
2013-07-19  6:15   ` Oleksandr Kravchenko
2013-07-19 21:06     ` Jonathan Cameron
2013-07-22 10:51       ` Oleksandr Kravchenko
2013-07-22 10:57 Oleksandr Kravchenko
2013-07-22 11:16 Oleksandr Kravchenko
2013-07-27 11:51 ` Jonathan Cameron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=51E816BD.9010302@metafoo.de \
    --to=lars@metafoo.de \
    --cc=jic23@cam.ac.uk \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=o.v.kravchenko@globallogic.com \
    --cc=x0199363@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.