Linux-IIO Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] iio: chemical: bme680: Fix pressure and humidity ABI mismatch
@ 2019-08-08 15:43 Himanshu Jha
  2019-08-11  8:32 ` Jonathan Cameron
  0 siblings, 1 reply; 2+ messages in thread
From: Himanshu Jha @ 2019-08-08 15:43 UTC (permalink / raw)
  To: jic23
  Cc: linux-iio, linux-kernel, knaack.h, lars, pmeerw, dpfrey,
	mike.looijmans, Himanshu Jha

Standard ABI for reporting pressure is kilopascal and for
relative humidity it is millipercent.

What:           /sys/bus/iio/devices/iio:deviceX/in_pressureY_input
What:           /sys/bus/iio/devices/iio:deviceX/in_pressure_input
KernelVersion:  3.8
Contact:        linux-iio@vger.kernel.org
Description:
                Scaled pressure measurement from channel Y, in kilopascal.

What:           /sys/bus/iio/devices/iio:deviceX/in_humidityrelative_input
KernelVersion:  3.14
Contact:        linux-iio@vger.kernel.org
Description:
                Scaled humidity measurement in milli percent.

Currently pressure is reported in hectopascal(hPa) and relative humidity
in percent. Hence fix this ABI mismatch conforming to the standard ABI.

Fixes: 1b3bd8592780 ("iio: chemical: Add support for Bosch BME680 sensor")
Signed-off-by: Himanshu Jha <himanshujha199640@gmail.com>
---

While cleaning this mess I wonder about the gas channel and there
exists no `in_resistance_input` in standard ABI :-(

We only have:

What:           /sys/bus/iio/devices/iio:deviceX/in_resistance_raw
What:           /sys/bus/iio/devices/iio:deviceX/in_resistanceX_raw
What:           /sys/bus/iio/devices/iio:deviceX/out_resistance_raw
What:           /sys/bus/iio/devices/iio:deviceX/out_resistanceX_raw
KernelVersion:  4.3
Contact:        linux-iio@vger.kernel.org
Description:
                Raw (unscaled no offset etc.) resistance reading that can be processed
                into an ohm value.

The sensor outputs processed value which is reported as is.

So, does it need a new ABI ?

 drivers/iio/chemical/bme680_core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/chemical/bme680_core.c b/drivers/iio/chemical/bme680_core.c
index ccde4c65ff93..28cc96d1e3c8 100644
--- a/drivers/iio/chemical/bme680_core.c
+++ b/drivers/iio/chemical/bme680_core.c
@@ -670,7 +670,7 @@ static int bme680_read_press(struct bme680_data *data,
 	}
 
 	*val = bme680_compensate_press(data, adc_press);
-	*val2 = 100;
+	*val2 = 1000;
 	return IIO_VAL_FRACTIONAL;
 }
 
@@ -704,7 +704,7 @@ static int bme680_read_humid(struct bme680_data *data,
 	comp_humidity = bme680_compensate_humid(data, adc_humidity);
 
 	*val = comp_humidity;
-	*val2 = 1000;
+	*val2 = 1000000;
 	return IIO_VAL_FRACTIONAL;
 }
 
-- 
2.17.1


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

* Re: [PATCH] iio: chemical: bme680: Fix pressure and humidity ABI mismatch
  2019-08-08 15:43 [PATCH] iio: chemical: bme680: Fix pressure and humidity ABI mismatch Himanshu Jha
@ 2019-08-11  8:32 ` Jonathan Cameron
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2019-08-11  8:32 UTC (permalink / raw)
  To: Himanshu Jha
  Cc: linux-iio, linux-kernel, knaack.h, lars, pmeerw, dpfrey, mike.looijmans

On Thu,  8 Aug 2019 21:13:50 +0530
Himanshu Jha <himanshujha199640@gmail.com> wrote:

> Standard ABI for reporting pressure is kilopascal and for
> relative humidity it is millipercent.
> 
> What:           /sys/bus/iio/devices/iio:deviceX/in_pressureY_input
> What:           /sys/bus/iio/devices/iio:deviceX/in_pressure_input
> KernelVersion:  3.8
> Contact:        linux-iio@vger.kernel.org
> Description:
>                 Scaled pressure measurement from channel Y, in kilopascal.
> 
> What:           /sys/bus/iio/devices/iio:deviceX/in_humidityrelative_input
> KernelVersion:  3.14
> Contact:        linux-iio@vger.kernel.org
> Description:
>                 Scaled humidity measurement in milli percent.
> 
> Currently pressure is reported in hectopascal(hPa) and relative humidity
> in percent. Hence fix this ABI mismatch conforming to the standard ABI.
> 
> Fixes: 1b3bd8592780 ("iio: chemical: Add support for Bosch BME680 sensor")
> Signed-off-by: Himanshu Jha <himanshujha199640@gmail.com>

Hopefully any users will cope with their scripts getting broken
by this.

I'm going to let this one sit for a little longer to give others time
to take a look.

Give me a poke if it looks like I've lost it down the back of the sofa
in a week or two.

Thanks,

Jonathan


> ---
> 
> While cleaning this mess I wonder about the gas channel and there
> exists no `in_resistance_input` in standard ABI :-(
> 
> We only have:
> 
> What:           /sys/bus/iio/devices/iio:deviceX/in_resistance_raw
> What:           /sys/bus/iio/devices/iio:deviceX/in_resistanceX_raw
> What:           /sys/bus/iio/devices/iio:deviceX/out_resistance_raw
> What:           /sys/bus/iio/devices/iio:deviceX/out_resistanceX_raw
> KernelVersion:  4.3
> Contact:        linux-iio@vger.kernel.org
> Description:
>                 Raw (unscaled no offset etc.) resistance reading that can be processed
>                 into an ohm value.
> 
> The sensor outputs processed value which is reported as is.
> 
> So, does it need a new ABI ?

New documentation as the ABI is clearly already there.   Good for completeness
but that description for _raw makes it obvious what the units will be etc so
hopefully we don't have any disagreement between drivers.


> 
>  drivers/iio/chemical/bme680_core.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/chemical/bme680_core.c b/drivers/iio/chemical/bme680_core.c
> index ccde4c65ff93..28cc96d1e3c8 100644
> --- a/drivers/iio/chemical/bme680_core.c
> +++ b/drivers/iio/chemical/bme680_core.c
> @@ -670,7 +670,7 @@ static int bme680_read_press(struct bme680_data *data,
>  	}
>  
>  	*val = bme680_compensate_press(data, adc_press);
> -	*val2 = 100;
> +	*val2 = 1000;
>  	return IIO_VAL_FRACTIONAL;
>  }
>  
> @@ -704,7 +704,7 @@ static int bme680_read_humid(struct bme680_data *data,
>  	comp_humidity = bme680_compensate_humid(data, adc_humidity);
>  
>  	*val = comp_humidity;
> -	*val2 = 1000;
> +	*val2 = 1000000;
>  	return IIO_VAL_FRACTIONAL;
>  }
>  


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

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-08 15:43 [PATCH] iio: chemical: bme680: Fix pressure and humidity ABI mismatch Himanshu Jha
2019-08-11  8:32 ` Jonathan Cameron

Linux-IIO Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-iio/0 linux-iio/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-iio linux-iio/ https://lore.kernel.org/linux-iio \
		linux-iio@vger.kernel.org linux-iio@archiver.kernel.org
	public-inbox-index linux-iio


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-iio


AGPL code for this site: git clone https://public-inbox.org/ public-inbox