Skip to content

Commit

Permalink
iio: pressure: bmp280: fix relative humidity unit
Browse files Browse the repository at this point in the history
[ Upstream commit 13399ff ]

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 <[email protected]>
Fixes: 14beaa8 ("iio: pressure: bmp280: add humidity support")
Acked-by: Matt Ranostay <[email protected]>
Signed-off-by: Jonathan Cameron <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
tduszynski authored and gregkh committed Aug 24, 2018
1 parent 42e2fa5 commit 17722c4
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions drivers/iio/pressure/bmp280-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 17722c4

Please sign in to comment.