diff options
author | Oleksandr Kravchenko | 2013-07-22 13:16:00 +0200 |
---|---|---|
committer | Jonathan Cameron | 2013-08-03 19:41:19 +0200 |
commit | d9a0134e7aa048f3de4477d93598974ea8ecae7a (patch) | |
tree | f680dd5219273ccd4844e04863387dcaa0f2365d /drivers/iio | |
parent | iio: adc: Update ti_am335x_adc Kconfig entry (diff) | |
download | kernel-qcow2-linux-d9a0134e7aa048f3de4477d93598974ea8ecae7a.tar.gz kernel-qcow2-linux-d9a0134e7aa048f3de4477d93598974ea8ecae7a.tar.xz kernel-qcow2-linux-d9a0134e7aa048f3de4477d93598974ea8ecae7a.zip |
iio: core: Avoid double minus in sysfs output
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@globallogic.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio')
-rw-r--r-- | drivers/iio/industrialio-core.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index d56d1229e2d6..97f0297b120f 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, "-%ld.%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, "-%ld.%09u\n", abs(val), -val2); else return sprintf(buf, "%d.%09u\n", val, val2); case IIO_VAL_FRACTIONAL: |