summaryrefslogtreecommitdiffstats
path: root/drivers/iio
diff options
context:
space:
mode:
authorTomasz Duszynski <tduszyns@gmail.com>2018-05-28 17:38:59 +0200
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2018-06-24 14:22:35 +0100
commit13399ff25f179811ce9c1df1523eb39f9e4a4772 (patch)
treef53428fe215038822f3578c62cd56c0d219ea5a3 /drivers/iio
parentce397d215ccd07b8ae3f71db689aedb85d56ab40 (diff)
downloadlinux-13399ff25f179811ce9c1df1523eb39f9e4a4772.tar.bz2
iio: pressure: bmp280: fix relative humidity unit
According to IIO ABI relative humidity reading should be returned in milli percent. This patch addresses that by applying proper scaling and returning integer instead of fractional format type specifier. Note that the fixes tag is before the driver was heavily refactored to introduce spi support, so the patch won't apply that far back. Signed-off-by: Tomasz Duszynski <tduszyns@gmail.com> Fixes: 14beaa8f5ab1 ("iio: pressure: bmp280: add humidity support") Acked-by: Matt Ranostay <matt.ranostay@konsulko.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/iio')
-rw-r--r--drivers/iio/pressure/bmp280-core.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/drivers/iio/pressure/bmp280-core.c b/drivers/iio/pressure/bmp280-core.c
index 5ec3e41b65f2..fe87d27779d9 100644
--- a/drivers/iio/pressure/bmp280-core.c
+++ b/drivers/iio/pressure/bmp280-core.c
@@ -415,10 +415,9 @@ static int bmp280_read_humid(struct bmp280_data *data, int *val, int *val2)
}
comp_humidity = bmp280_compensate_humidity(data, adc_humidity);
- *val = comp_humidity;
- *val2 = 1024;
+ *val = comp_humidity * 1000 / 1024;
- return IIO_VAL_FRACTIONAL;
+ return IIO_VAL_INT;
}
static int bmp280_read_raw(struct iio_dev *indio_dev,