linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iio: pressure: bmp280: fix relative humidity unit
@ 2018-05-28 15:38 Tomasz Duszynski
  2018-05-30  0:44 ` Matt Ranostay
  2018-06-03 14:41 ` Jonathan Cameron
  0 siblings, 2 replies; 13+ messages in thread
From: Tomasz Duszynski @ 2018-05-28 15:38 UTC (permalink / raw)
  To: linux-iio; +Cc: jic23, linus.walleij

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.

Signed-off-by: Tomasz Duszynski <tduszyns@gmail.com>
---
 drivers/iio/pressure/bmp280-core.c | 5 ++---
 1 file 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,
-- 
2.17.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2018-06-03 14:59 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-28 15:38 [PATCH] iio: pressure: bmp280: fix relative humidity unit Tomasz Duszynski
2018-05-30  0:44 ` Matt Ranostay
2018-05-30  1:17   ` Phil Reid
2018-05-30  5:05     ` Matt Ranostay
2018-05-30  7:20       ` Matt Ranostay
2018-05-30 14:23         ` Tomasz Duszynski
2018-05-30 23:31           ` Phil Reid
2018-05-31  1:04             ` Matt Ranostay
2018-05-31  2:06           ` Matt Ranostay
2018-06-03 14:59             ` Jonathan Cameron
2018-06-03 14:45         ` Jonathan Cameron
2018-06-03 14:41 ` Jonathan Cameron
2018-06-03 14:43   ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).