diff mbox series

iio/gyro/bmg160: Use millidegrees for temperature scale

Message ID 1549981549-19786-1-git-send-email-mike.looijmans@topic.nl (mailing list archive)
State New, archived
Headers show
Series iio/gyro/bmg160: Use millidegrees for temperature scale | expand

Commit Message

Mike Looijmans Feb. 12, 2019, 2:25 p.m. UTC
Standard unit for temperature is millidegrees Celcius, whereas this driver
was reporting in degrees. Fix the scale factor in the driver.

Signed-off-by: Mike Looijmans <mike.looijmans@topic.nl>
---
 drivers/iio/gyro/bmg160_core.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Tomasz Duszynski Feb. 12, 2019, 5 p.m. UTC | #1
On Tue, Feb 12, 2019 at 03:25:49PM +0100, Mike Looijmans wrote:
> Standard unit for temperature is millidegrees Celcius, whereas this driver
> was reporting in degrees. Fix the scale factor in the driver.
>
> Signed-off-by: Mike Looijmans <mike.looijmans@topic.nl>
> ---
>  drivers/iio/gyro/bmg160_core.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/iio/gyro/bmg160_core.c b/drivers/iio/gyro/bmg160_core.c
> index 63ca316..ad7f8cb 100644
> --- a/drivers/iio/gyro/bmg160_core.c
> +++ b/drivers/iio/gyro/bmg160_core.c
> @@ -585,8 +585,9 @@ static int bmg160_read_raw(struct iio_dev *indio_dev,
>  		*val = 0;
>  		switch (chan->type) {
>  		case IIO_TEMP:
> -			*val2 = 500000;
> -			return IIO_VAL_INT_PLUS_MICRO;
> +			*val = 500;
> +			*val2 = 0;
> +			return IIO_VAL_INT;

You are returning integer type to iio so there's no point in touching
val2. iio will ignore it anyway.

>  		case IIO_ANGL_VEL:
>  		{
>  			int i;
> --
> 1.9.1
>
Mike Looijmans Feb. 13, 2019, 6:58 a.m. UTC | #2
On 12-02-19 18:00, Tomasz Duszynski wrote:
> On Tue, Feb 12, 2019 at 03:25:49PM +0100, Mike Looijmans wrote:
>> Standard unit for temperature is millidegrees Celcius, whereas this driver
>> was reporting in degrees. Fix the scale factor in the driver.
>>
>> Signed-off-by: Mike Looijmans <mike.looijmans@topic.nl>
>> ---
>>   drivers/iio/gyro/bmg160_core.c | 5 +++--
>>   1 file changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/iio/gyro/bmg160_core.c b/drivers/iio/gyro/bmg160_core.c
>> index 63ca316..ad7f8cb 100644
>> --- a/drivers/iio/gyro/bmg160_core.c
>> +++ b/drivers/iio/gyro/bmg160_core.c
>> @@ -585,8 +585,9 @@ static int bmg160_read_raw(struct iio_dev *indio_dev,
>>   		*val = 0;
>>   		switch (chan->type) {
>>   		case IIO_TEMP:
>> -			*val2 = 500000;
>> -			return IIO_VAL_INT_PLUS_MICRO;
>> +			*val = 500;
>> +			*val2 = 0;
>> +			return IIO_VAL_INT;
> 
> You are returning integer type to iio so there's no point in touching
> val2. iio will ignore it anyway.

Indeed, I'll post a v2 for that.

> 
>>   		case IIO_ANGL_VEL:
>>   		{
>>   			int i;
>> --
>> 1.9.1
>>
diff mbox series

Patch

diff --git a/drivers/iio/gyro/bmg160_core.c b/drivers/iio/gyro/bmg160_core.c
index 63ca316..ad7f8cb 100644
--- a/drivers/iio/gyro/bmg160_core.c
+++ b/drivers/iio/gyro/bmg160_core.c
@@ -585,8 +585,9 @@  static int bmg160_read_raw(struct iio_dev *indio_dev,
 		*val = 0;
 		switch (chan->type) {
 		case IIO_TEMP:
-			*val2 = 500000;
-			return IIO_VAL_INT_PLUS_MICRO;
+			*val = 500;
+			*val2 = 0;
+			return IIO_VAL_INT;
 		case IIO_ANGL_VEL:
 		{
 			int i;