[<prev] [next>] [day] [month] [year] [list]
Message-ID: <1374490631-11924-1-git-send-email-x0199363@ti.com>
Date: Mon, 22 Jul 2013 13:57:11 +0300
From: Oleksandr Kravchenko <x0199363@...com>
To: <jic23@....ac.uk>
CC: <linux-iio@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
Oleksandr Kravchenko <o.v.kravchenko@...ballogic.com>
Subject: [PATCH] iio: core: Avoid double minus in sysfs output
From: Oleksandr Kravchenko <o.v.kravchenko@...ballogic.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.
Signed-off-by: Oleksandr Kravchenko <o.v.kravchenko@...ballogic.com>
---
drivers/iio/industrialio-core.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
index d56d122..455c24b 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,
- scale_db ? " dB" : "");
+ return sprintf(buf, "-%d.%06u%s\n", (int)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", (int)abs(val), -val2);
else
return sprintf(buf, "%d.%09u\n", val, val2);
case IIO_VAL_FRACTIONAL:
--
1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists