iio: pressure: bmp280: fix relative humidity unit
PATCH 1/1 iio: pressure: bmp280: fix relative humidity unit
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.
--- drivers/iio/pressure/bmp280-core.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/iio/pressure/bmp280-core.c +2 -3
@@ -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,
Signature · 1 line
2.17.0
Quoted 6 lines · Tomasz Duszynski
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.
*sigh* seems this is my mistake, but good catch. Slight nitpick below.. otherwise looks good
Quoted 10 lines
Signed-off-by Tomasz Duszynski <[email protected]>--- drivers/iio/pressure/bmp280-core.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)drivers/iio/pressure/bmp280-core.c +0
-0
drivers/iio/pressure/bmp280-core.c static int bmp280_read_humid(struct bmp280_data *data, int *val, int *val2) · line 418
Quoted 6 lines
drivers/iio/pressure/bmp280-core.c +1
-2@@ -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 ;
Minor nitpick that it would look cleaner as: (comp_humidity / 1024) * 1000
Quoted 13 lines
drivers/iio/pressure/bmp280-core.c +1
-2-return IIO_VAL_FRACTIONAL ; +return IIO_VAL_INT ; } static int bmp280_read_raw(struct iio_dev *indio_dev, --2.17.0
--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 24 lines · Matt Ranostay
Quoted 6 lines · Tomasz Duszynski
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.
*sigh* seems this is my mistake, but good catch. Slight nitpick below.. otherwise looks good
Quoted 13 lines
Signed-off-by Tomasz Duszynski <[email protected]>--- drivers/iio/pressure/bmp280-core.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)drivers/iio/pressure/bmp280-core.c +0
-0@@ -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);
Quoted 6 lines
drivers/iio/pressure/bmp280-core.c static int bmp280_read_humid(struct bmp280_data *data, int *val, int *val2) · line 418
Quoted 3 lines
drivers/iio/pressure/bmp280-core.c +1
-2- *val = comp_humidity; - *val2 =1024 ; + *val = comp_humidity *1000 /1024 ;Minor nitpick that it would look cleaner as: (
comp_humidity/ 1024) * 1000
be careful of integer division.
Quoted 10 lines
Quoted 8 lines
drivers/iio/pressure/bmp280-core.c +1
-2-return IIO_VAL_FRACTIONAL ; +return IIO_VAL_INT ; } static int bmp280_read_raw(struct iio_dev *indio_dev, --2.17.0
Signature · 2 lines
Regards Phil Reid
Quoted 38 lines · Phil Reid
Quoted 29 lines · Matt Ranostay
Quoted 7 lines · Tomasz Duszynski
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.
*sigh* seems this is my mistake, but good catch. Slight nitpick below.. otherwise looks good
Quoted 15 lines
Signed-off-by Tomasz Duszynski <[email protected]>--- drivers/iio/pressure/bmp280-core.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)drivers/iio/pressure/bmp280-core.c +0
-0@@ -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);Quoted 8 lines
drivers/iio/pressure/bmp280-core.c static int bmp280_read_humid(struct bmp280_data *data, int *val, int *val2) · line 418
Quoted 3 lines
drivers/iio/pressure/bmp280-core.c +1
-2- *val = comp_humidity; - *val2 =1024 ; + *val = comp_humidity *1000 /1024 ;Minor nitpick that it would look cleaner as: (
comp_humidity/ 1024) *
1000
Quoted 2 lines
be careful of integer division.
Ah yes good point. You will have to check if comp_humidity isn't zero or it is possible to have a divide-by-zero.
- Matt
Quoted 18 lines
Quoted 12 lines
Quoted 9 lines
drivers/iio/pressure/bmp280-core.c +1
-2-return IIO_VAL_FRACTIONAL ; +return IIO_VAL_INT ; } static int bmp280_read_raw(struct iio_dev *indio_dev, --2.17.0
--
Regards
Phil Reid
Quoted 39 lines · Matt Ranostay
Quoted 38 lines · Phil Reid
Quoted 37 lines · Matt Ranostay
Quoted 7 lines · Tomasz Duszynski
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.
*sigh* seems this is my mistake, but good catch. Slight nitpick below.. otherwise looks good
Quoted 11 lines
Signed-off-by Tomasz Duszynski <[email protected]>--- drivers/iio/pressure/bmp280-core.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)drivers/iio/pressure/bmp280-core.c +0
-0drivers/iio/pressure/bmp280-core.c static int bmp280_read_humid(struct bmp280_data · line 419
Quoted 7 lines
drivers/iio/pressure/bmp280-core.c +1
-2@@ -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 ;Minor nitpick that it would look cleaner as: (
comp_humidity/ 1024) *
1000
Quoted 5 lines
Quoted 2 lines
be careful of integer division.
Ah yes good point. You will have to check if
comp_humidityisn't zero or it is possible to have a divide-by-zero.
D'oh actually divide by zero would be an issue. But you'll want to be sure of possible overflows (doubt that would be an issue here).
However it may be better to just add the scaling factor of 1000 with IIO_CHAN_INFO_SCALE and make the processed value now a raw one.
Quoted 21 lines
- Matt
Quoted 18 lines
Quoted 12 lines
Quoted 9 lines
drivers/iio/pressure/bmp280-core.c +1
-2-return IIO_VAL_FRACTIONAL ; +return IIO_VAL_INT ; } static int bmp280_read_raw(struct iio_dev *indio_dev, --2.17.0
--
Regards
Phil Reid
Quoted 41 lines · Matt Ranostay
Quoted 39 lines · Matt Ranostay
Quoted 38 lines · Phil Reid
Quoted 37 lines · Matt Ranostay
Quoted 7 lines · Tomasz Duszynski
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.
*sigh* seems this is my mistake, but good catch. Slight nitpick below.. otherwise looks good
Quoted 11 lines
Signed-off-by Tomasz Duszynski <[email protected]>--- drivers/iio/pressure/bmp280-core.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)drivers/iio/pressure/bmp280-core.c +0
-0drivers/iio/pressure/bmp280-core.c static int bmp280_read_humid(struct bmp280_data · line 419
Quoted 7 lines
drivers/iio/pressure/bmp280-core.c +1
-2@@ -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 ;Minor nitpick that it would look cleaner as: (
comp_humidity/ 1024) *
1000
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
be careful of integer division.
Ah yes good point. You will have to check if
comp_humidityisn't zero or it is possible to have a divide-by-zero.D'oh actually divide by zero would be an issue. But you'll want to be sure of possible overflows (doubt that would be an issue here).
What kind of division-by-zero are you meaning? When would that happen in this case?
Quoted 3 lines
However it may be better to just add the scaling factor of 1000 with
IIO_CHAN_INFO_SCALEand make the processed value now a raw one.
Is measurement precision your concern here? I would not bother with that since the sensor is not a top-notch anyway. Even datasheet itself specifies error margin of +/-3% for relative humidity.
Quoted 22 lines
Quoted 22 lines
- Matt
Quoted 18 lines
Quoted 12 lines
Quoted 9 lines
drivers/iio/pressure/bmp280-core.c +1
-2-return IIO_VAL_FRACTIONAL ; +return IIO_VAL_INT ; } static int bmp280_read_raw(struct iio_dev *indio_dev, --2.17.0
--
Regards
Phil Reid
Quoted 45 lines · Tomasz Duszynski
Quoted 44 lines · Matt Ranostay
Quoted 42 lines · Matt Ranostay
Quoted 40 lines · Phil Reid
Quoted 29 lines · Matt Ranostay
Quoted 7 lines · Tomasz Duszynski
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.
*sigh* seems this is my mistake, but good catch. Slight nitpick below.. otherwise looks good
Quoted 15 lines
Signed-off-by Tomasz Duszynski <[email protected]>--- drivers/iio/pressure/bmp280-core.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)drivers/iio/pressure/bmp280-core.c +0
-0@@ -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);Quoted 8 lines
drivers/iio/pressure/bmp280-core.c static int bmp280_read_humid(struct bmp280_data *data, int *val, int *val2) · line 418
Quoted 3 lines
drivers/iio/pressure/bmp280-core.c +1
-2- *val = comp_humidity; - *val2 =1024 ; + *val = comp_humidity *1000 /1024 ;Minor nitpick that it would look cleaner as: (
comp_humidity/ 1024) *
1000be careful of integer division.
Quoted 9 lines
Quoted 5 lines
Quoted 2 lines
Ah yes good point. You will have to check if
comp_humidityisn't zero or it is possible to have a divide-by-zero.D'oh actually divide by zero would be an issue. But you'll want to be sure of possible overflows (doubt that would be an issue here).
What kind of division-by-zero are you meaning? When would that happen in this case?
I meant something like this:
10 / 1024 = 0
0 * 1000 = 0
10 * 1000 = 10000
10000 / 1024 = 9
patch looks like the right way to me
provided comp_humidity * 1000 is not going to overflow.
Quoted 32 lines
Quoted 3 lines
However it may be better to just add the scaling factor of 1000 with
IIO_CHAN_INFO_SCALEand make the processed value now a raw one.Is measurement precision your concern here? I would not bother with that since the sensor is not a top-notch anyway. Even datasheet itself specifies error margin of +/-3% for relative humidity.
Quoted 22 lines
Quoted 22 lines
- Matt
Quoted 18 lines
Quoted 12 lines
Quoted 9 lines
drivers/iio/pressure/bmp280-core.c +1
-2-return IIO_VAL_FRACTIONAL ; +return IIO_VAL_INT ; } static int bmp280_read_raw(struct iio_dev *indio_dev, --2.17.0
--
Regards
Phil Reid
Signature · 11 lines
Regards Phil Reid ElectroMagnetic Imaging Technology Pty Ltd Development of Geophysical Instrumentation & Software www.electromag.com.au 3 The Avenue, Midland WA 6056, AUSTRALIA Ph: +61 8 9250 8100 Fax: +61 8 9250 7100 Email: [email protected]
Quoted 71 lines · Phil Reid
Quoted 60 lines · Tomasz Duszynski
Quoted 58 lines · Matt Ranostay
Quoted 53 lines · Matt Ranostay
Quoted 45 lines · Phil Reid
Quoted 33 lines · Matt Ranostay
Quoted 8 lines · Tomasz Duszynski
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.
*sigh* seems this is my mistake, but good catch. Slight nitpick below.. otherwise looks good
Quoted 16 lines
Signed-off-by Tomasz Duszynski <[email protected]>--- drivers/iio/pressure/bmp280-core.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)drivers/iio/pressure/bmp280-core.c +0
-0@@ -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);Quoted 10 lines
drivers/iio/pressure/bmp280-core.c static int bmp280_read_humid(struct bmp280_data · line 420
Quoted 3 lines
drivers/iio/pressure/bmp280-core.c +1
-2- *val = comp_humidity; - *val2 =1024 ; + *val = comp_humidity *1000 /1024 ;Minor nitpick that it would look cleaner as: (
comp_humidity/ 1024)
*
1000Quoted 2 lines
be careful of integer division.
Ah yes good point. You will have to check if
comp_humidityisn't zero or it is possible to have a divide-by-zero.Quoted 7 lines
Quoted 2 lines
D'oh actually divide by zero would be an issue. But you'll want to be sure of possible overflows (doubt that would be an issue here).
What kind of division-by-zero are you meaning? When would that happen in this case?
I meant something like this:
Quoted 10 lines
10 / 1024 = 0
0 * 1000 = 010 * 1000 = 10000
10000 / 1024 = 9patch looks like the right way to me
providedcomp_humidity* 1000 is not going to overflow.
Ah right.. forgot about order of operations does matter in integer division.
Quoted 50 lines
Quoted 36 lines
Quoted 4 lines
However it may be better to just add the scaling factor of 1000 with
IIO_CHAN_INFO_SCALEand make the processed value now a raw one.Is measurement precision your concern here? I would not bother with that since the sensor is not a top-notch anyway. Even datasheet itself specifies
error margin of +/-3% for relative humidity.Quoted 23 lines
Quoted 23 lines
- Matt
Quoted 19 lines
Quoted 13 lines
Quoted 9 lines
drivers/iio/pressure/bmp280-core.c +1
-1-return IIO_VAL_FRACTIONAL ; +return IIO_VAL_INT ; }static int bmp280_read_raw(struct
iio_dev*indio_dev,
--
2.17.0--
Regards
Phil Reid--
Regards
Phil ReidElectroMagnetic Imaging Technology Pty Ltd Development of Geophysical Instrumentation & Software www.electromag.com.au
3 The Avenue, Midland WA 6056, AUSTRALIA
Ph: +61 8 9250 8100
Fax: +61 8 9250 7100
Email: [email protected]
Matt Ranostay
Acked-byQuoted 55 lines · Tomasz Duszynski
Quoted 41 lines · Matt Ranostay
Quoted 39 lines · Matt Ranostay
Quoted 38 lines · Phil Reid
Quoted 37 lines · Matt Ranostay
Quoted 7 lines · Tomasz Duszynski
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.
*sigh* seems this is my mistake, but good catch. Slight nitpick below.. otherwise looks good
Quoted 11 lines
Signed-off-by Tomasz Duszynski <[email protected]>--- drivers/iio/pressure/bmp280-core.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)drivers/iio/pressure/bmp280-core.c +0
-0drivers/iio/pressure/bmp280-core.c static int bmp280_read_humid(struct bmp280_data · line 419
Quoted 7 lines
drivers/iio/pressure/bmp280-core.c +1
-2@@ -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 ;Minor nitpick that it would look cleaner as: (
comp_humidity/ 1024) *
1000Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
be careful of integer division.
Ah yes good point. You will have to check if
comp_humidityisn't zero or it is possible to have a divide-by-zero.D'oh actually divide by zero would be an issue. But you'll want to be sure of possible overflows (doubt that would be an issue here).
What kind of division-by-zero are you meaning? When would that happen in this case?
Quoted 1 line
Quoted 6 lines
Quoted 2 lines
However it may be better to just add the scaling factor of 1000 with
IIO_CHAN_INFO_SCALEand make the processed value now a raw one.Is measurement precision your concern here? I would not bother with that since the sensor is not a top-notch anyway. Even datasheet itself specifies error margin of +/-3% for relative humidity.
As Phil mentioned the original patchset is okay as it is. Now I agree with him after thinking it through.
Quoted 23 lines
Quoted 23 lines
Quoted 23 lines
- Matt
Quoted 18 lines
Quoted 12 lines
Quoted 9 lines
drivers/iio/pressure/bmp280-core.c +1
-2-return IIO_VAL_FRACTIONAL ; +return IIO_VAL_INT ; } static int bmp280_read_raw(struct iio_dev *indio_dev, --2.17.0
--
Regards
Phil Reid
Quoted 59 lines · On Thu, 31 May 2018 10:06:50 +0800 Matt Ranostay <[email protected]>…
Quoted 58 lines · Tomasz Duszynski
Quoted 41 lines · Matt Ranostay
Quoted 39 lines · Matt Ranostay
Quoted 38 lines · Phil Reid
Quoted 37 lines · Matt Ranostay
Quoted 7 lines · Tomasz Duszynski
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.
*sigh* seems this is my mistake, but good catch. Slight nitpick below.. otherwise looks good
Quoted 11 lines
Signed-off-by Tomasz Duszynski <[email protected]>--- drivers/iio/pressure/bmp280-core.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)drivers/iio/pressure/bmp280-core.c +0
-0drivers/iio/pressure/bmp280-core.c static int bmp280_read_humid(struct bmp280_data · line 419
Quoted 7 lines
drivers/iio/pressure/bmp280-core.c +1
-2@@ -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 ;Minor nitpick that it would look cleaner as: (
comp_humidity/ 1024) *
1000Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
be careful of integer division.
Ah yes good point. You will have to check if
comp_humidityisn't zero or it is possible to have a divide-by-zero.D'oh actually divide by zero would be an issue. But you'll want to be sure of possible overflows (doubt that would be an issue here).
What kind of division-by-zero are you meaning? When would that happen in this case?
Quoted 3 lines
However it may be better to just add the scaling factor of 1000 with
IIO_CHAN_INFO_SCALEand make the processed value now a raw one.
Quoted 8 lines
Quoted 3 lines
Is measurement precision your concern here? I would not bother with that since the sensor is not a top-notch anyway. Even datasheet itself specifies error margin of +/-3% for relative humidity.
As Phil mentioned the original patchset is okay as it is. Now I agree with him after thinking it through.
Acked-by Matt Ranostay <[email protected]>
Applied to the fixes-togreg branch of iio.git.
Note this won't go upstream until after the merge window. It should also have had a relevant fixes tag.
I added the original humidity one of Matt's though the patch won't apply that far back due to splitting of code when SPI support was added. I added a note to that effect.
Jonathan
Quoted 29 lines
Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
- Matt
Quoted 14 lines
Quoted 12 lines
Quoted 9 lines
drivers/iio/pressure/bmp280-core.c +1
-2-return IIO_VAL_FRACTIONAL ; +return IIO_VAL_INT ; } static int bmp280_read_raw(struct iio_dev *indio_dev, --2.17.0
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
--
Regards
Phil Reid--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Jonathan Cameron
maintainerQuoted 44 lines · On Wed, 30 May 2018 15:20:37 +0800 Matt Ranostay <[email protected]>…
Quoted 42 lines · Matt Ranostay
Quoted 40 lines · Phil Reid
Quoted 29 lines · Matt Ranostay
Quoted 7 lines · Tomasz Duszynski
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.
*sigh* seems this is my mistake, but good catch. Slight nitpick below.. otherwise looks good
Quoted 15 lines
Signed-off-by Tomasz Duszynski <[email protected]>--- drivers/iio/pressure/bmp280-core.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)drivers/iio/pressure/bmp280-core.c +0
-0@@ -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);Quoted 8 lines
drivers/iio/pressure/bmp280-core.c static int bmp280_read_humid(struct bmp280_data *data, int *val, int *val2) · line 418
Quoted 3 lines
drivers/iio/pressure/bmp280-core.c +1
-2- *val = comp_humidity; - *val2 =1024 ; + *val = comp_humidity *1000 /1024 ;Minor nitpick that it would look cleaner as: (
comp_humidity/ 1024) *
1000be careful of integer division.
Quoted 9 lines
Quoted 2 lines
Ah yes good point. You will have to check if
comp_humidityisn't zero or it is possible to have a divide-by-zero.D'oh actually divide by zero would be an issue. But you'll want to be sure of possible overflows (doubt that would be an issue here).
However it may be better to just add the scaling factor of 1000 with
IIO_CHAN_INFO_SCALEand make the processed value now a raw one.
Don't do that. It would be an ABI change. Whilst we can hope that everyone is using a nice library that would cope with this, there is no guarantee they are.
Jonathan
Quoted 21 lines
Quoted 21 lines
- Matt
Quoted 18 lines
Quoted 12 lines
Quoted 9 lines
drivers/iio/pressure/bmp280-core.c +1
-2-return IIO_VAL_FRACTIONAL ; +return IIO_VAL_INT ; } static int bmp280_read_raw(struct iio_dev *indio_dev, --2.17.0
--
Regards
Phil Reid
Jonathan Cameron
maintainerQuoted 7 lines · On Mon, 28 May 2018 17:38:59 +0200 Tomasz Duszynski <[email protected]> wrote:
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 <[email protected]>
I'll be wanting input from Linus on this as he seems to be the last person to have taken particular interest in the driver.
Quoted 9 lines
--- drivers/iio/pressure/bmp280-core.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)drivers/iio/pressure/bmp280-core.c +0
-0
drivers/iio/pressure/bmp280-core.c static int bmp280_read_humid(struct bmp280_data *data, int *val, int *val2) · line 418
Quoted 6 lines
drivers/iio/pressure/bmp280-core.c +1
-2@@ -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 ;
Why not just *val = *val * 1000 and leave the rest alone?
Quoted 6 lines
drivers/iio/pressure/bmp280-core.c +1
-1-return IIO_VAL_FRACTIONAL ; +return IIO_VAL_INT ; } static int bmp280_read_raw(struct iio_dev *indio_dev,
Quoted 6 lines · On Sun, 3 Jun 2018 15:41:54 +0100 Jonathan Cameron <[email protected]> wrote:
Quoted 3 lines · On Mon, 28 May 2018 17:38:59 +0200 Tomasz Duszynski <[email protected]> wrote:
According to IIO ABI relative humidity reading should be returned in milli percent.
Quoted 7 lines
Quoted 4 lines
This patch addresses that by applying proper scaling and returning integer instead of fractional format type specifier.
Signed-off-by Tomasz Duszynski <[email protected]>I'll be wanting input from Linus on this as he seems to be the last person to have taken particular interest in the driver.
Sorry, my email had 'stalled' for some reason so I didn't see the rest of the thread.
Please ignore.
J
Quoted 30 lines
Quoted 10 lines
--- drivers/iio/pressure/bmp280-core.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)drivers/iio/pressure/bmp280-core.c +0
-0drivers/iio/pressure/bmp280-core.c static int bmp280_read_humid(struct bmp280_data *data, int *val, int *val2) · line 418
Quoted 6 lines
drivers/iio/pressure/bmp280-core.c +1
-2@@ -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 ;Why not just *val = *val * 1000 and leave the rest alone?
drivers/iio/pressure/bmp280-core.c static int bmp280_read_humid(struct bmp280_data *data, int *val, int *val2) · line 423
Quoted 6 lines
drivers/iio/pressure/bmp280-core.c +1
-1-return IIO_VAL_FRACTIONAL ; +return IIO_VAL_INT ; } static int bmp280_read_raw(struct iio_dev *indio_dev,--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html