mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-15 15:15:47 +00:00
iio:chemical:bme680: Fix, report temperature in millidegrees
The standard unit for temperature is millidegrees Celcius. Adapt the
driver to report in millidegrees instead of degrees.
Signed-off-by: Mike Looijmans <mike.looijmans@topic.nl>
Fixes: 1b3bd85927
("iio: chemical: Add support for Bosch BME680 sensor");
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This commit is contained in:
parent
831d2fefdf
commit
9436f45dd5
1 changed files with 7 additions and 9 deletions
|
@ -583,8 +583,7 @@ static int bme680_gas_config(struct bme680_data *data)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int bme680_read_temp(struct bme680_data *data,
|
static int bme680_read_temp(struct bme680_data *data, int *val)
|
||||||
int *val, int *val2)
|
|
||||||
{
|
{
|
||||||
struct device *dev = regmap_get_device(data->regmap);
|
struct device *dev = regmap_get_device(data->regmap);
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -617,10 +616,9 @@ static int bme680_read_temp(struct bme680_data *data,
|
||||||
* compensate_press/compensate_humid to get compensated
|
* compensate_press/compensate_humid to get compensated
|
||||||
* pressure/humidity readings.
|
* pressure/humidity readings.
|
||||||
*/
|
*/
|
||||||
if (val && val2) {
|
if (val) {
|
||||||
*val = comp_temp;
|
*val = comp_temp * 10; /* Centidegrees to millidegrees */
|
||||||
*val2 = 100;
|
return IIO_VAL_INT;
|
||||||
return IIO_VAL_FRACTIONAL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -635,7 +633,7 @@ static int bme680_read_press(struct bme680_data *data,
|
||||||
s32 adc_press;
|
s32 adc_press;
|
||||||
|
|
||||||
/* Read and compensate temperature to get a reading of t_fine */
|
/* Read and compensate temperature to get a reading of t_fine */
|
||||||
ret = bme680_read_temp(data, NULL, NULL);
|
ret = bme680_read_temp(data, NULL);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
@ -668,7 +666,7 @@ static int bme680_read_humid(struct bme680_data *data,
|
||||||
u32 comp_humidity;
|
u32 comp_humidity;
|
||||||
|
|
||||||
/* Read and compensate temperature to get a reading of t_fine */
|
/* Read and compensate temperature to get a reading of t_fine */
|
||||||
ret = bme680_read_temp(data, NULL, NULL);
|
ret = bme680_read_temp(data, NULL);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
@ -761,7 +759,7 @@ static int bme680_read_raw(struct iio_dev *indio_dev,
|
||||||
case IIO_CHAN_INFO_PROCESSED:
|
case IIO_CHAN_INFO_PROCESSED:
|
||||||
switch (chan->type) {
|
switch (chan->type) {
|
||||||
case IIO_TEMP:
|
case IIO_TEMP:
|
||||||
return bme680_read_temp(data, val, val2);
|
return bme680_read_temp(data, val);
|
||||||
case IIO_PRESSURE:
|
case IIO_PRESSURE:
|
||||||
return bme680_read_press(data, val, val2);
|
return bme680_read_press(data, val, val2);
|
||||||
case IIO_HUMIDITYRELATIVE:
|
case IIO_HUMIDITYRELATIVE:
|
||||||
|
|
Loading…
Reference in a new issue