linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iio/gyro/bmg160: Use millidegrees for temperature scale
@ 2019-02-12 14:25 Mike Looijmans
  2019-02-12 17:00 ` Tomasz Duszynski
  2019-02-13  7:41 ` [PATCH v2] " Mike Looijmans
  0 siblings, 2 replies; 5+ messages in thread
From: Mike Looijmans @ 2019-02-12 14:25 UTC (permalink / raw)
  To: linux-iio; +Cc: linux-kernel, jic23, knaack.h, lars, pmeerw, Mike Looijmans

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;
 		case IIO_ANGL_VEL:
 		{
 			int i;
-- 
1.9.1


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

* Re: [PATCH] iio/gyro/bmg160: Use millidegrees for temperature scale
  2019-02-12 14:25 [PATCH] iio/gyro/bmg160: Use millidegrees for temperature scale Mike Looijmans
@ 2019-02-12 17:00 ` Tomasz Duszynski
  2019-02-13  6:58   ` Mike Looijmans
  2019-02-13  7:41 ` [PATCH v2] " Mike Looijmans
  1 sibling, 1 reply; 5+ messages in thread
From: Tomasz Duszynski @ 2019-02-12 17:00 UTC (permalink / raw)
  To: Mike Looijmans; +Cc: linux-iio, linux-kernel, jic23, knaack.h, lars, pmeerw

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
>

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

* Re: [PATCH] iio/gyro/bmg160: Use millidegrees for temperature scale
  2019-02-12 17:00 ` Tomasz Duszynski
@ 2019-02-13  6:58   ` Mike Looijmans
  0 siblings, 0 replies; 5+ messages in thread
From: Mike Looijmans @ 2019-02-13  6:58 UTC (permalink / raw)
  To: Tomasz Duszynski; +Cc: linux-iio, linux-kernel, jic23, knaack.h, lars, pmeerw

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
>>


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

* [PATCH v2] iio/gyro/bmg160: Use millidegrees for temperature scale
  2019-02-12 14:25 [PATCH] iio/gyro/bmg160: Use millidegrees for temperature scale Mike Looijmans
  2019-02-12 17:00 ` Tomasz Duszynski
@ 2019-02-13  7:41 ` Mike Looijmans
  2019-02-20 12:10   ` Jonathan Cameron
  1 sibling, 1 reply; 5+ messages in thread
From: Mike Looijmans @ 2019-02-13  7:41 UTC (permalink / raw)
  To: linux-iio; +Cc: linux-kernel, jic23, knaack.h, lars, pmeerw, Mike Looijmans

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>
---
v2: Don't touch val2 when returning IIO_VAL_INT
    Only touch val when returning a value

 drivers/iio/gyro/bmg160_core.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/gyro/bmg160_core.c b/drivers/iio/gyro/bmg160_core.c
index 63ca316..92c07ab 100644
--- a/drivers/iio/gyro/bmg160_core.c
+++ b/drivers/iio/gyro/bmg160_core.c
@@ -582,11 +582,10 @@ static int bmg160_read_raw(struct iio_dev *indio_dev,
 	case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY:
 		return bmg160_get_filter(data, val);
 	case IIO_CHAN_INFO_SCALE:
-		*val = 0;
 		switch (chan->type) {
 		case IIO_TEMP:
-			*val2 = 500000;
-			return IIO_VAL_INT_PLUS_MICRO;
+			*val = 500;
+			return IIO_VAL_INT;
 		case IIO_ANGL_VEL:
 		{
 			int i;
@@ -594,6 +593,7 @@ static int bmg160_read_raw(struct iio_dev *indio_dev,
 			for (i = 0; i < ARRAY_SIZE(bmg160_scale_table); ++i) {
 				if (bmg160_scale_table[i].dps_range ==
 							data->dps_range) {
+					*val = 0;
 					*val2 = bmg160_scale_table[i].scale;
 					return IIO_VAL_INT_PLUS_MICRO;
 				}
-- 
1.9.1


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

* Re: [PATCH v2] iio/gyro/bmg160: Use millidegrees for temperature scale
  2019-02-13  7:41 ` [PATCH v2] " Mike Looijmans
@ 2019-02-20 12:10   ` Jonathan Cameron
  0 siblings, 0 replies; 5+ messages in thread
From: Jonathan Cameron @ 2019-02-20 12:10 UTC (permalink / raw)
  To: Mike Looijmans; +Cc: linux-iio, linux-kernel, knaack.h, lars, pmeerw

On Wed, 13 Feb 2019 08:41:47 +0100
Mike Looijmans <mike.looijmans@topic.nl> 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>
Applied to the fixes-togreg branch of iio.git and marked for stable.

Thanks,

Jonathan
> ---
> v2: Don't touch val2 when returning IIO_VAL_INT
>     Only touch val when returning a value
> 
>  drivers/iio/gyro/bmg160_core.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/iio/gyro/bmg160_core.c b/drivers/iio/gyro/bmg160_core.c
> index 63ca316..92c07ab 100644
> --- a/drivers/iio/gyro/bmg160_core.c
> +++ b/drivers/iio/gyro/bmg160_core.c
> @@ -582,11 +582,10 @@ static int bmg160_read_raw(struct iio_dev *indio_dev,
>  	case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY:
>  		return bmg160_get_filter(data, val);
>  	case IIO_CHAN_INFO_SCALE:
> -		*val = 0;
>  		switch (chan->type) {
>  		case IIO_TEMP:
> -			*val2 = 500000;
> -			return IIO_VAL_INT_PLUS_MICRO;
> +			*val = 500;
> +			return IIO_VAL_INT;
>  		case IIO_ANGL_VEL:
>  		{
>  			int i;
> @@ -594,6 +593,7 @@ static int bmg160_read_raw(struct iio_dev *indio_dev,
>  			for (i = 0; i < ARRAY_SIZE(bmg160_scale_table); ++i) {
>  				if (bmg160_scale_table[i].dps_range ==
>  							data->dps_range) {
> +					*val = 0;
>  					*val2 = bmg160_scale_table[i].scale;
>  					return IIO_VAL_INT_PLUS_MICRO;
>  				}


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

end of thread, other threads:[~2019-02-20 12:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-12 14:25 [PATCH] iio/gyro/bmg160: Use millidegrees for temperature scale Mike Looijmans
2019-02-12 17:00 ` Tomasz Duszynski
2019-02-13  6:58   ` Mike Looijmans
2019-02-13  7:41 ` [PATCH v2] " Mike Looijmans
2019-02-20 12:10   ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).