[PATCH 4.9 040/130] iio: pressure: bmp280: fix relative humidity unit

From: Greg Kroah-Hartman
Date: Thu Aug 23 2018 - 04:07:54 EST


4.9-stable review patch. If anyone has any objections, please let me know.

------------------

From: Tomasz Duszynski <tduszyns@xxxxxxxxx>

[ Upstream commit 13399ff25f179811ce9c1df1523eb39f9e4a4772 ]

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@xxxxxxxxx>
Fixes: 14beaa8f5ab1 ("iio: pressure: bmp280: add humidity support")
Acked-by: Matt Ranostay <matt.ranostay@xxxxxxxxxxxx>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@xxxxxxxxxx>
Signed-off-by: Sasha Levin <alexander.levin@xxxxxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
drivers/iio/pressure/bmp280-core.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)

--- a/drivers/iio/pressure/bmp280-core.c
+++ b/drivers/iio/pressure/bmp280-core.c
@@ -347,10 +347,9 @@ static int bmp280_read_humid(struct bmp2
adc_humidity = be16_to_cpu(tmp);
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,