All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iio: mlx90614: Define magic numbers
@ 2015-07-05 18:07 Crt Mori
  2015-07-19 11:33 ` Jonathan Cameron
  0 siblings, 1 reply; 8+ messages in thread
From: Crt Mori @ 2015-07-05 18:07 UTC (permalink / raw)
  To: linux-iio
  Cc: Peter Meerwald, Vianney le Clément de Saint-Marcq,
	Johnathan Iain Cameron

Translates the magic constant numbers to named macros and add some
additional comments about their meaning.

The diff is made towards togreg branch as that branch seems to have the
most recent updates of mlx90614 driver (many are yet to be merged).

Signed-off-by: Crt Mori <cmo@melexis.com>
Acked-by: Peter Meerwald <pmeerw@pmeerw.net>
---
 drivers/iio/temperature/mlx90614.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/drivers/iio/temperature/mlx90614.c
b/drivers/iio/temperature/mlx90614.c
index cb2e8ad..909278a 100644
--- a/drivers/iio/temperature/mlx90614.c
+++ b/drivers/iio/temperature/mlx90614.c
@@ -65,6 +65,13 @@

 #define MLX90614_AUTOSLEEP_DELAY 5000 /* default autosleep delay */

+/* Magic constants */
+#define MLX90614_CONST_OFFSET_DEC -13657 /* decimal part of the
Kelvin offset */
+#define MLX90614_CONST_OFFSET_REM 500000 /* remainder of offset (273.15*50) */
+#define MLX90614_CONST_SCALE 20 /* Scale in milliKelvin (0.02 * 1000) */
+#define MLX90614_CONST_RAW_EMISSIVITY_MAX 65535 /* max value for emissivity */
+#define MLX90614_CONST_EMISSIVITY_RESOLUTION 15259 /* 1/65535 ~ 0.000015259 */
+
 struct mlx90614_data {
        struct i2c_client *client;
        struct mutex lock; /* for EEPROM access only */
@@ -204,11 +211,11 @@ static int mlx90614_read_raw(struct iio_dev *indio_dev,
                *val = ret;
                return IIO_VAL_INT;
        case IIO_CHAN_INFO_OFFSET:
-               *val = 13657;
-               *val2 = 500000;
+               *val = MLX90614_CONST_OFFSET_DEC;
+               *val2 = MLX90614_CONST_OFFSET_REM;
                return IIO_VAL_INT_PLUS_MICRO;
        case IIO_CHAN_INFO_SCALE:
-               *val = 20;
+               *val = MLX90614_CONST_SCALE;
                return IIO_VAL_INT;
        case IIO_CHAN_INFO_CALIBEMISSIVITY: /* 1/65535 / LSB */
                mlx90614_power_get(data, false);
@@ -221,12 +228,12 @@ static int mlx90614_read_raw(struct iio_dev *indio_dev,
                if (ret < 0)
                        return ret;

-               if (ret == 65535) {
+               if (ret == MLX90614_CONST_RAW_EMISSIVITY_MAX) {
                        *val = 1;
                        *val2 = 0;
                } else {
                        *val = 0;
-                       *val2 = ret * 15259; /* 1/65535 ~ 0.000015259 */
+                       *val2 = ret * MLX90614_CONST_EMISSIVITY_RESOLUTION;
                }
                return IIO_VAL_INT_PLUS_NANO;
        default:
@@ -245,7 +252,8 @@ static int mlx90614_write_raw(struct iio_dev *indio_dev,
        case IIO_CHAN_INFO_CALIBEMISSIVITY: /* 1/65535 / LSB */
                if (val < 0 || val2 < 0 || val > 1 || (val == 1 && val2 != 0))
                        return -EINVAL;
-               val = val * 65535 + val2 / 15259; /* 1/65535 ~ 0.000015259 */
+               val = val * MLX90614_CONST_RAW_EMISSIVITY_MAX +
+                       val2 / MLX90614_CONST_EMISSIVITY_RESOLUTION;

                mlx90614_power_get(data, false);
                mutex_lock(&data->lock);

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

* Re: [PATCH] iio: mlx90614: Define magic numbers
  2015-07-05 18:07 [PATCH] iio: mlx90614: Define magic numbers Crt Mori
@ 2015-07-19 11:33 ` Jonathan Cameron
  2015-07-19 20:14   ` Crt Mori
  0 siblings, 1 reply; 8+ messages in thread
From: Jonathan Cameron @ 2015-07-19 11:33 UTC (permalink / raw)
  To: Crt Mori, linux-iio
  Cc: Peter Meerwald, Vianney le Clément de Saint-Marcq

On 05/07/15 19:07, Crt Mori wrote:
> Translates the magic constant numbers to named macros and add some
> additional comments about their meaning.
> 
> The diff is made towards togreg branch as that branch seems to have the
> most recent updates of mlx90614 driver (many are yet to be merged).
> 
> Signed-off-by: Crt Mori <cmo@melexis.com>
> Acked-by: Peter Meerwald <pmeerw@pmeerw.net>
Crt,

This patch is malformed, probably as a result of your email client.
It seems to have replaced tabs with spaces meaning I can't apply this
without doing it line by line.

Could you take a look at Documentation/SubmittingPatches and the advice
in there on how to lure an email client into not messing things up.

If you can't persuade that to work, I will take the occasional attachment.

Otherwise, the patch looks fine.

Jonathan
> ---
>  drivers/iio/temperature/mlx90614.c | 20 ++++++++++++++------
>  1 file changed, 14 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/iio/temperature/mlx90614.c
> b/drivers/iio/temperature/mlx90614.c
> index cb2e8ad..909278a 100644
> --- a/drivers/iio/temperature/mlx90614.c
> +++ b/drivers/iio/temperature/mlx90614.c
> @@ -65,6 +65,13 @@
> 
>  #define MLX90614_AUTOSLEEP_DELAY 5000 /* default autosleep delay */
> 
> +/* Magic constants */
> +#define MLX90614_CONST_OFFSET_DEC -13657 /* decimal part of the
> Kelvin offset */
> +#define MLX90614_CONST_OFFSET_REM 500000 /* remainder of offset (273.15*50) */
> +#define MLX90614_CONST_SCALE 20 /* Scale in milliKelvin (0.02 * 1000) */
> +#define MLX90614_CONST_RAW_EMISSIVITY_MAX 65535 /* max value for emissivity */
> +#define MLX90614_CONST_EMISSIVITY_RESOLUTION 15259 /* 1/65535 ~ 0.000015259 */
> +
>  struct mlx90614_data {
>         struct i2c_client *client;
>         struct mutex lock; /* for EEPROM access only */
> @@ -204,11 +211,11 @@ static int mlx90614_read_raw(struct iio_dev *indio_dev,
>                 *val = ret;
>                 return IIO_VAL_INT;
>         case IIO_CHAN_INFO_OFFSET:
> -               *val = 13657;
> -               *val2 = 500000;
> +               *val = MLX90614_CONST_OFFSET_DEC;
> +               *val2 = MLX90614_CONST_OFFSET_REM;
>                 return IIO_VAL_INT_PLUS_MICRO;
>         case IIO_CHAN_INFO_SCALE:
> -               *val = 20;
> +               *val = MLX90614_CONST_SCALE;
>                 return IIO_VAL_INT;
>         case IIO_CHAN_INFO_CALIBEMISSIVITY: /* 1/65535 / LSB */
>                 mlx90614_power_get(data, false);
> @@ -221,12 +228,12 @@ static int mlx90614_read_raw(struct iio_dev *indio_dev,
>                 if (ret < 0)
>                         return ret;
> 
> -               if (ret == 65535) {
> +               if (ret == MLX90614_CONST_RAW_EMISSIVITY_MAX) {
>                         *val = 1;
>                         *val2 = 0;
>                 } else {
>                         *val = 0;
> -                       *val2 = ret * 15259; /* 1/65535 ~ 0.000015259 */
> +                       *val2 = ret * MLX90614_CONST_EMISSIVITY_RESOLUTION;
>                 }
>                 return IIO_VAL_INT_PLUS_NANO;
>         default:
> @@ -245,7 +252,8 @@ static int mlx90614_write_raw(struct iio_dev *indio_dev,
>         case IIO_CHAN_INFO_CALIBEMISSIVITY: /* 1/65535 / LSB */
>                 if (val < 0 || val2 < 0 || val > 1 || (val == 1 && val2 != 0))
>                         return -EINVAL;
> -               val = val * 65535 + val2 / 15259; /* 1/65535 ~ 0.000015259 */
> +               val = val * MLX90614_CONST_RAW_EMISSIVITY_MAX +
> +                       val2 / MLX90614_CONST_EMISSIVITY_RESOLUTION;
> 
>                 mlx90614_power_get(data, false);
>                 mutex_lock(&data->lock);
> 


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

* Re: [PATCH] iio: mlx90614: Define magic numbers
  2015-07-19 11:33 ` Jonathan Cameron
@ 2015-07-19 20:14   ` Crt Mori
  2015-07-20 17:56     ` Jonathan Cameron
  0 siblings, 1 reply; 8+ messages in thread
From: Crt Mori @ 2015-07-19 20:14 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: linux-iio, Peter Meerwald, Vianney le Clément de Saint-Marcq

[-- Attachment #1: Type: text/plain, Size: 6743 bytes --]

Translates the magic constant numbers to named macros and add some
additional comments about their meaning.

The diff is made towards togreg branch as that branch seems to have the
most recent updates of mlx90614 driver (many are yet to be merged).

Signed-off-by: Crt Mori <cmo@melexis.com>
Acked-by: Peter Meerwald <pmeerw@pmeerw.net>
---
 drivers/iio/temperature/mlx90614.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/drivers/iio/temperature/mlx90614.c
b/drivers/iio/temperature/mlx90614.c
index cb2e8ad..909278a 100644
--- a/drivers/iio/temperature/mlx90614.c
+++ b/drivers/iio/temperature/mlx90614.c
@@ -65,6 +65,13 @@

 #define MLX90614_AUTOSLEEP_DELAY 5000 /* default autosleep delay */

+/* Magic constants */
+#define MLX90614_CONST_OFFSET_DEC -13657 /* decimal part of the
Kelvin offset */
+#define MLX90614_CONST_OFFSET_REM 500000 /* remainder of offset
(273.15*50) */
+#define MLX90614_CONST_SCALE 20 /* Scale in milliKelvin (0.02 * 1000) */
+#define MLX90614_CONST_RAW_EMISSIVITY_MAX 65535 /* max value for
emissivity */
+#define MLX90614_CONST_EMISSIVITY_RESOLUTION 15259 /* 1/65535 ~
0.000015259 */
+
 struct mlx90614_data {
struct i2c_client *client;
struct mutex lock; /* for EEPROM access only */
@@ -204,11 +211,11 @@ static int mlx90614_read_raw(struct iio_dev
*indio_dev,
*val = ret;
return IIO_VAL_INT;
case IIO_CHAN_INFO_OFFSET:
- *val = 13657;
- *val2 = 500000;
+ *val = MLX90614_CONST_OFFSET_DEC;
+ *val2 = MLX90614_CONST_OFFSET_REM;
return IIO_VAL_INT_PLUS_MICRO;
case IIO_CHAN_INFO_SCALE:
- *val = 20;
+ *val = MLX90614_CONST_SCALE;
return IIO_VAL_INT;
case IIO_CHAN_INFO_CALIBEMISSIVITY: /* 1/65535 / LSB */
mlx90614_power_get(data, false);
@@ -221,12 +228,12 @@ static int mlx90614_read_raw(struct iio_dev
*indio_dev,
if (ret < 0)
return ret;

- if (ret == 65535) {
+ if (ret == MLX90614_CONST_RAW_EMISSIVITY_MAX) {
*val = 1;
*val2 = 0;
} else {
*val = 0;
- *val2 = ret * 15259; /* 1/65535 ~ 0.000015259 */
+ *val2 = ret * MLX90614_CONST_EMISSIVITY_RESOLUTION;
}
return IIO_VAL_INT_PLUS_NANO;
default:
@@ -245,7 +252,8 @@ static int mlx90614_write_raw(struct iio_dev *indio_dev,
case IIO_CHAN_INFO_CALIBEMISSIVITY: /* 1/65535 / LSB */
if (val < 0 || val2 < 0 || val > 1 || (val == 1 && val2 != 0))
return -EINVAL;
- val = val * 65535 + val2 / 15259; /* 1/65535 ~ 0.000015259 */
+ val = val * MLX90614_CONST_RAW_EMISSIVITY_MAX +
+ val2 / MLX90614_CONST_EMISSIVITY_RESOLUTION;

mlx90614_power_get(data, false);
mutex_lock(&data->lock);


On 19 July 2015 at 13:33, Jonathan Cameron <jic23@kernel.org> wrote:

> On 05/07/15 19:07, Crt Mori wrote:
> > Translates the magic constant numbers to named macros and add some
> > additional comments about their meaning.
> >
> > The diff is made towards togreg branch as that branch seems to have the
> > most recent updates of mlx90614 driver (many are yet to be merged).
> >
> > Signed-off-by: Crt Mori <cmo@melexis.com>
> > Acked-by: Peter Meerwald <pmeerw@pmeerw.net>
> Crt,
>
> This patch is malformed, probably as a result of your email client.
> It seems to have replaced tabs with spaces meaning I can't apply this
> without doing it line by line.
>
> Could you take a look at Documentation/SubmittingPatches and the advice
> in there on how to lure an email client into not messing things up.
>
> If you can't persuade that to work, I will take the occasional attachment.
>
> Otherwise, the patch looks fine.
>
Jonathan
>
I hope it is now OK? I needed to turn off google's mail mode, and
apparently plain text
mode also translates tabs into spaces. I have now fixed the tabs and I hope
they are
also sent. Please let me know - I will otherwise just pull some mail client
and get it
working.

Crt


> > ---
> >  drivers/iio/temperature/mlx90614.c | 20 ++++++++++++++------
> >  1 file changed, 14 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/iio/temperature/mlx90614.c
> > b/drivers/iio/temperature/mlx90614.c
> > index cb2e8ad..909278a 100644
> > --- a/drivers/iio/temperature/mlx90614.c
> > +++ b/drivers/iio/temperature/mlx90614.c
> > @@ -65,6 +65,13 @@
> >
> >  #define MLX90614_AUTOSLEEP_DELAY 5000 /* default autosleep delay */
> >
> > +/* Magic constants */
> > +#define MLX90614_CONST_OFFSET_DEC -13657 /* decimal part of the
> > Kelvin offset */
> > +#define MLX90614_CONST_OFFSET_REM 500000 /* remainder of offset
> (273.15*50) */
> > +#define MLX90614_CONST_SCALE 20 /* Scale in milliKelvin (0.02 * 1000) */
> > +#define MLX90614_CONST_RAW_EMISSIVITY_MAX 65535 /* max value for
> emissivity */
> > +#define MLX90614_CONST_EMISSIVITY_RESOLUTION 15259 /* 1/65535 ~
> 0.000015259 */
> > +
> >  struct mlx90614_data {
> >         struct i2c_client *client;
> >         struct mutex lock; /* for EEPROM access only */
> > @@ -204,11 +211,11 @@ static int mlx90614_read_raw(struct iio_dev
> *indio_dev,
> >                 *val = ret;
> >                 return IIO_VAL_INT;
> >         case IIO_CHAN_INFO_OFFSET:
> > -               *val = 13657;
> > -               *val2 = 500000;
> > +               *val = MLX90614_CONST_OFFSET_DEC;
> > +               *val2 = MLX90614_CONST_OFFSET_REM;
> >                 return IIO_VAL_INT_PLUS_MICRO;
> >         case IIO_CHAN_INFO_SCALE:
> > -               *val = 20;
> > +               *val = MLX90614_CONST_SCALE;
> >                 return IIO_VAL_INT;
> >         case IIO_CHAN_INFO_CALIBEMISSIVITY: /* 1/65535 / LSB */
> >                 mlx90614_power_get(data, false);
> > @@ -221,12 +228,12 @@ static int mlx90614_read_raw(struct iio_dev
> *indio_dev,
> >                 if (ret < 0)
> >                         return ret;
> >
> > -               if (ret == 65535) {
> > +               if (ret == MLX90614_CONST_RAW_EMISSIVITY_MAX) {
> >                         *val = 1;
> >                         *val2 = 0;
> >                 } else {
> >                         *val = 0;
> > -                       *val2 = ret * 15259; /* 1/65535 ~ 0.000015259 */
> > +                       *val2 = ret *
> MLX90614_CONST_EMISSIVITY_RESOLUTION;
> >                 }
> >                 return IIO_VAL_INT_PLUS_NANO;
> >         default:
> > @@ -245,7 +252,8 @@ static int mlx90614_write_raw(struct iio_dev
> *indio_dev,
> >         case IIO_CHAN_INFO_CALIBEMISSIVITY: /* 1/65535 / LSB */
> >                 if (val < 0 || val2 < 0 || val > 1 || (val == 1 && val2
> != 0))
> >                         return -EINVAL;
> > -               val = val * 65535 + val2 / 15259; /* 1/65535 ~
> 0.000015259 */
> > +               val = val * MLX90614_CONST_RAW_EMISSIVITY_MAX +
> > +                       val2 / MLX90614_CONST_EMISSIVITY_RESOLUTION;
> >
> >                 mlx90614_power_get(data, false);
> >                 mutex_lock(&data->lock);
> >
>
>

[-- Attachment #2: Type: text/html, Size: 11478 bytes --]

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

* Re: [PATCH] iio: mlx90614: Define magic numbers
  2015-07-19 20:14   ` Crt Mori
@ 2015-07-20 17:56     ` Jonathan Cameron
  2015-07-20 19:09       ` Crt Mori
  0 siblings, 1 reply; 8+ messages in thread
From: Jonathan Cameron @ 2015-07-20 17:56 UTC (permalink / raw)
  To: Crt Mori
  Cc: linux-iio, Peter Meerwald, Vianney le Clément de Saint-Marcq

On 19/07/15 21:14, Crt Mori wrote:
> Translates the magic constant numbers to named macros and add some
> additional comments about their meaning.
> 
> The diff is made towards togreg branch as that branch seems to have the
> most recent updates of mlx90614 driver (many are yet to be merged).
> 
> Signed-off-by: Crt Mori <cmo@melexis.com <mailto:cmo@melexis.com>>
> Acked-by: Peter Meerwald <pmeerw@pmeerw.net <mailto:pmeerw@pmeerw.net>>
Hi Crt,

Sorry to be a pain.  Could you send this as a fresh patch on it's own.
It's tricky to use standard tools to pull it out of an email like this.

Also, could you check the spacing below as I think your email client
may have eaten some.

J
> ---
>  drivers/iio/temperature/mlx90614.c | 20 ++++++++++++++------
>  1 file changed, 14 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/iio/temperature/mlx90614.c
> b/drivers/iio/temperature/mlx90614.c
> index cb2e8ad..909278a 100644
> --- a/drivers/iio/temperature/mlx90614.c
> +++ b/drivers/iio/temperature/mlx90614.c
> @@ -65,6 +65,13 @@
> 
>  #define MLX90614_AUTOSLEEP_DELAY 5000 /* default autosleep delay */
> 
> +/* Magic constants */
> +#define MLX90614_CONST_OFFSET_DEC -13657 /* decimal part of the
> Kelvin offset */
> +#define MLX90614_CONST_OFFSET_REM 500000 /* remainder of offset (273.15*50) */
> +#define MLX90614_CONST_SCALE 20 /* Scale in milliKelvin (0.02 * 1000) */
> +#define MLX90614_CONST_RAW_EMISSIVITY_MAX 65535 /* max value for emissivity */
> +#define MLX90614_CONST_EMISSIVITY_RESOLUTION 15259 /* 1/65535 ~ 0.000015259 */
> +
>  struct mlx90614_data {
> struct i2c_client *client;
> struct mutex lock; /* for EEPROM access only */
> @@ -204,11 +211,11 @@ static int mlx90614_read_raw(struct iio_dev *indio_dev,
> *val = ret;
> return IIO_VAL_INT;
> case IIO_CHAN_INFO_OFFSET:
> -*val = 13657;
> -*val2 = 500000;
> +*val = MLX90614_CONST_OFFSET_DEC;
> +*val2 = MLX90614_CONST_OFFSET_REM;
> return IIO_VAL_INT_PLUS_MICRO;
> case IIO_CHAN_INFO_SCALE:
> -*val = 20;
> +*val = MLX90614_CONST_SCALE;
> return IIO_VAL_INT;
> case IIO_CHAN_INFO_CALIBEMISSIVITY: /* 1/65535 / LSB */
> mlx90614_power_get(data, false);
> @@ -221,12 +228,12 @@ static int mlx90614_read_raw(struct iio_dev *indio_dev,
> if (ret < 0)
> return ret;
> 
> -if (ret == 65535) {
> +if (ret == MLX90614_CONST_RAW_EMISSIVITY_MAX) {
> *val = 1;
> *val2 = 0;
> } else {
> *val = 0;
> -*val2 = ret * 15259; /* 1/65535 ~ 0.000015259 */
> +*val2 = ret * MLX90614_CONST_EMISSIVITY_RESOLUTION;
> }
> return IIO_VAL_INT_PLUS_NANO;
> default:
> @@ -245,7 +252,8 @@ static int mlx90614_write_raw(struct iio_dev *indio_dev,
> case IIO_CHAN_INFO_CALIBEMISSIVITY: /* 1/65535 / LSB */
> if (val < 0 || val2 < 0 || val > 1 || (val == 1 && val2 != 0))
> return -EINVAL;
> -val = val * 65535 + val2 / 15259; /* 1/65535 ~ 0.000015259 */
> +val = val * MLX90614_CONST_RAW_EMISSIVITY_MAX +
> +val2 / MLX90614_CONST_EMISSIVITY_RESOLUTION;
> 
> mlx90614_power_get(data, false);
> mutex_lock(&data->lock);
> 
> 
> On 19 July 2015 at 13:33, Jonathan Cameron <jic23@kernel.org <mailto:jic23@kernel.org>> wrote:
> 
>     On 05/07/15 19:07, Crt Mori wrote:
>     > Translates the magic constant numbers to named macros and add some
>     > additional comments about their meaning.
>     >
>     > The diff is made towards togreg branch as that branch seems to have the
>     > most recent updates of mlx90614 driver (many are yet to be merged).
>     >
>     > Signed-off-by: Crt Mori <cmo@melexis.com <mailto:cmo@melexis.com>>
>     > Acked-by: Peter Meerwald <pmeerw@pmeerw.net <mailto:pmeerw@pmeerw.net>>
>     Crt,
> 
>     This patch is malformed, probably as a result of your email client.
>     It seems to have replaced tabs with spaces meaning I can't apply this
>     without doing it line by line.
> 
>     Could you take a look at Documentation/SubmittingPatches and the advice
>     in there on how to lure an email client into not messing things up.
> 
>     If you can't persuade that to work, I will take the occasional attachment.
> 
>     Otherwise, the patch looks fine. 
> 
>     Jonathan
> 
> I hope it is now OK? I needed to turn off google's mail mode, and apparently plain text
> mode also translates tabs into spaces. I have now fixed the tabs and I hope they are
> also sent. Please let me know - I will otherwise just pull some mail client and get it
> working.
> 
> Crt
>  
> 
>     > ---
>     >  drivers/iio/temperature/mlx90614.c | 20 ++++++++++++++------
>     >  1 file changed, 14 insertions(+), 6 deletions(-)
>     >
>     > diff --git a/drivers/iio/temperature/mlx90614.c
>     > b/drivers/iio/temperature/mlx90614.c
>     > index cb2e8ad..909278a 100644
>     > --- a/drivers/iio/temperature/mlx90614.c
>     > +++ b/drivers/iio/temperature/mlx90614.c
>     > @@ -65,6 +65,13 @@
>     >
>     >  #define MLX90614_AUTOSLEEP_DELAY 5000 /* default autosleep delay */
>     >
>     > +/* Magic constants */
>     > +#define MLX90614_CONST_OFFSET_DEC -13657 /* decimal part of the
>     > Kelvin offset */
>     > +#define MLX90614_CONST_OFFSET_REM 500000 /* remainder of offset (273.15*50) */
>     > +#define MLX90614_CONST_SCALE 20 /* Scale in milliKelvin (0.02 * 1000) */
>     > +#define MLX90614_CONST_RAW_EMISSIVITY_MAX 65535 /* max value for emissivity */
>     > +#define MLX90614_CONST_EMISSIVITY_RESOLUTION 15259 /* 1/65535 ~ 0.000015259 */
>     > +
>     >  struct mlx90614_data {
>     >         struct i2c_client *client;
>     >         struct mutex lock; /* for EEPROM access only */
>     > @@ -204,11 +211,11 @@ static int mlx90614_read_raw(struct iio_dev *indio_dev,
>     >                 *val = ret;
>     >                 return IIO_VAL_INT;
>     >         case IIO_CHAN_INFO_OFFSET:
>     > -               *val = 13657;
>     > -               *val2 = 500000;
>     > +               *val = MLX90614_CONST_OFFSET_DEC;
>     > +               *val2 = MLX90614_CONST_OFFSET_REM;
>     >                 return IIO_VAL_INT_PLUS_MICRO;
>     >         case IIO_CHAN_INFO_SCALE:
>     > -               *val = 20;
>     > +               *val = MLX90614_CONST_SCALE;
>     >                 return IIO_VAL_INT;
>     >         case IIO_CHAN_INFO_CALIBEMISSIVITY: /* 1/65535 / LSB */
>     >                 mlx90614_power_get(data, false);
>     > @@ -221,12 +228,12 @@ static int mlx90614_read_raw(struct iio_dev *indio_dev,
>     >                 if (ret < 0)
>     >                         return ret;
>     >
>     > -               if (ret == 65535) {
>     > +               if (ret == MLX90614_CONST_RAW_EMISSIVITY_MAX) {
>     >                         *val = 1;
>     >                         *val2 = 0;
>     >                 } else {
>     >                         *val = 0;
>     > -                       *val2 = ret * 15259; /* 1/65535 ~ 0.000015259 */
>     > +                       *val2 = ret * MLX90614_CONST_EMISSIVITY_RESOLUTION;
>     >                 }
>     >                 return IIO_VAL_INT_PLUS_NANO;
>     >         default:
>     > @@ -245,7 +252,8 @@ static int mlx90614_write_raw(struct iio_dev *indio_dev,
>     >         case IIO_CHAN_INFO_CALIBEMISSIVITY: /* 1/65535 / LSB */
>     >                 if (val < 0 || val2 < 0 || val > 1 || (val == 1 && val2 != 0))
>     >                         return -EINVAL;
>     > -               val = val * 65535 + val2 / 15259; /* 1/65535 ~ 0.000015259 */
>     > +               val = val * MLX90614_CONST_RAW_EMISSIVITY_MAX +
>     > +                       val2 / MLX90614_CONST_EMISSIVITY_RESOLUTION;
>     >
>     >                 mlx90614_power_get(data, false);
>     >                 mutex_lock(&data->lock);
>     >
> 
> 


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

* [PATCH] iio: mlx90614: Define magic numbers
@ 2015-07-20 19:06 Crt Mori
  0 siblings, 0 replies; 8+ messages in thread
From: Crt Mori @ 2015-07-20 19:06 UTC (permalink / raw)
  To: Johnathan Iain Cameron, linux-iio, Peter Meerwald,
	Vianney le Clément de Saint-Marcq

[-- Attachment #1: Type: text/plain, Size: 2567 bytes --]

Translates the magic constant numbers to named macros and add some
additional comments about their meaning.

The diff is made towards togreg branch as that branch seems to have the
most recent updates of mlx90614 driver (many are yet to be merged).

Signed-off-by: Crt Mori <cmo@melexis.com>
Acked-by: Peter Meerwald <pmeerw@pmeerw.net>
---
 drivers/iio/temperature/mlx90614.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/drivers/iio/temperature/mlx90614.c
b/drivers/iio/temperature/mlx90614.c
index cb2e8ad..4590f83 100644
--- a/drivers/iio/temperature/mlx90614.c
+++ b/drivers/iio/temperature/mlx90614.c
@@ -65,6 +65,13 @@

 #define MLX90614_AUTOSLEEP_DELAY 5000 /* default autosleep delay */

+/* Magic constants */
+#define MLX90614_CONST_OFFSET_DEC -13657 /* decimal part of the Kelvin
offset */
+#define MLX90614_CONST_OFFSET_REM 500000 /* remainder of offset
(273.15*50) */
+#define MLX90614_CONST_SCALE 20 /* Scale in milliKelvin (0.02 * 1000) */
+#define MLX90614_CONST_RAW_EMISSIVITY_MAX 65535 /* max value for
emissivity */
+#define MLX90614_CONST_EMISSIVITY_RESOLUTION 15259 /* 1/65535 ~
0.000015259 */
+
 struct mlx90614_data {
  struct i2c_client *client;
  struct mutex lock; /* for EEPROM access only */
@@ -204,11 +211,11 @@ static int mlx90614_read_raw(struct iio_dev
*indio_dev,
  *val = ret;
  return IIO_VAL_INT;
  case IIO_CHAN_INFO_OFFSET:
- *val = 13657;
- *val2 = 500000;
+ *val = MLX90614_CONST_OFFSET_DEC;
+ *val2 = MLX90614_CONST_OFFSET_REM;
  return IIO_VAL_INT_PLUS_MICRO;
  case IIO_CHAN_INFO_SCALE:
- *val = 20;
+ *val = MLX90614_CONST_SCALE;
  return IIO_VAL_INT;
  case IIO_CHAN_INFO_CALIBEMISSIVITY: /* 1/65535 / LSB */
  mlx90614_power_get(data, false);
@@ -221,12 +228,12 @@ static int mlx90614_read_raw(struct iio_dev
*indio_dev,
  if (ret < 0)
  return ret;

- if (ret == 65535) {
+ if (ret == MLX90614_CONST_RAW_EMISSIVITY_MAX) {
  *val = 1;
  *val2 = 0;
  } else {
  *val = 0;
- *val2 = ret * 15259; /* 1/65535 ~ 0.000015259 */
+ *val2 = ret * MLX90614_CONST_EMISSIVITY_RESOLUTION;
  }
  return IIO_VAL_INT_PLUS_NANO;
  default:
@@ -245,7 +252,8 @@ static int mlx90614_write_raw(struct iio_dev *indio_dev,
  case IIO_CHAN_INFO_CALIBEMISSIVITY: /* 1/65535 / LSB */
  if (val < 0 || val2 < 0 || val > 1 || (val == 1 && val2 != 0))
  return -EINVAL;
- val = val * 65535 + val2 / 15259; /* 1/65535 ~ 0.000015259 */
+ val = val * MLX90614_CONST_RAW_EMISSIVITY_MAX +
+ val2 / MLX90614_CONST_EMISSIVITY_RESOLUTION;

  mlx90614_power_get(data, false);
  mutex_lock(&data->lock);
-- 
2.1.4

[-- Attachment #2: Type: text/html, Size: 5233 bytes --]

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

* Re: [PATCH] iio: mlx90614: Define magic numbers
  2015-07-20 17:56     ` Jonathan Cameron
@ 2015-07-20 19:09       ` Crt Mori
  0 siblings, 0 replies; 8+ messages in thread
From: Crt Mori @ 2015-07-20 19:09 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: linux-iio, Peter Meerwald, Vianney le Clément de Saint-Marcq

On 20 July 2015 at 19:56, Jonathan Cameron <jic23@kernel.org> wrote:
> On 19/07/15 21:14, Crt Mori wrote:
>> Translates the magic constant numbers to named macros and add some
>> additional comments about their meaning.
>>
>> The diff is made towards togreg branch as that branch seems to have the
>> most recent updates of mlx90614 driver (many are yet to be merged).
>>
>> Signed-off-by: Crt Mori <cmo@melexis.com <mailto:cmo@melexis.com>>
>> Acked-by: Peter Meerwald <pmeerw@pmeerw.net <mailto:pmeerw@pmeerw.net>>
> Hi Crt,
>
> Sorry to be a pain.  Could you send this as a fresh patch on it's own.
> It's tricky to use standard tools to pull it out of an email like this.
>
> Also, could you check the spacing below as I think your email client
> may have eaten some.
>
> J
No problem. I gotta master this gmail with patches if I want to send
stuff in future. I hope
other patches came through in better state. I hope it got through now OK.

Crt

>> ---
>>  drivers/iio/temperature/mlx90614.c | 20 ++++++++++++++------
>>  1 file changed, 14 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/iio/temperature/mlx90614.c
>> b/drivers/iio/temperature/mlx90614.c
>> index cb2e8ad..909278a 100644
>> --- a/drivers/iio/temperature/mlx90614.c
>> +++ b/drivers/iio/temperature/mlx90614.c
>> @@ -65,6 +65,13 @@
>>
>>  #define MLX90614_AUTOSLEEP_DELAY 5000 /* default autosleep delay */
>>
>> +/* Magic constants */
>> +#define MLX90614_CONST_OFFSET_DEC -13657 /* decimal part of the
>> Kelvin offset */
>> +#define MLX90614_CONST_OFFSET_REM 500000 /* remainder of offset (273.15*50) */
>> +#define MLX90614_CONST_SCALE 20 /* Scale in milliKelvin (0.02 * 1000) */
>> +#define MLX90614_CONST_RAW_EMISSIVITY_MAX 65535 /* max value for emissivity */
>> +#define MLX90614_CONST_EMISSIVITY_RESOLUTION 15259 /* 1/65535 ~ 0.000015259 */
>> +
>>  struct mlx90614_data {
>> struct i2c_client *client;
>> struct mutex lock; /* for EEPROM access only */
>> @@ -204,11 +211,11 @@ static int mlx90614_read_raw(struct iio_dev *indio_dev,
>> *val = ret;
>> return IIO_VAL_INT;
>> case IIO_CHAN_INFO_OFFSET:
>> -*val = 13657;
>> -*val2 = 500000;
>> +*val = MLX90614_CONST_OFFSET_DEC;
>> +*val2 = MLX90614_CONST_OFFSET_REM;
>> return IIO_VAL_INT_PLUS_MICRO;
>> case IIO_CHAN_INFO_SCALE:
>> -*val = 20;
>> +*val = MLX90614_CONST_SCALE;
>> return IIO_VAL_INT;
>> case IIO_CHAN_INFO_CALIBEMISSIVITY: /* 1/65535 / LSB */
>> mlx90614_power_get(data, false);
>> @@ -221,12 +228,12 @@ static int mlx90614_read_raw(struct iio_dev *indio_dev,
>> if (ret < 0)
>> return ret;
>>
>> -if (ret == 65535) {
>> +if (ret == MLX90614_CONST_RAW_EMISSIVITY_MAX) {
>> *val = 1;
>> *val2 = 0;
>> } else {
>> *val = 0;
>> -*val2 = ret * 15259; /* 1/65535 ~ 0.000015259 */
>> +*val2 = ret * MLX90614_CONST_EMISSIVITY_RESOLUTION;
>> }
>> return IIO_VAL_INT_PLUS_NANO;
>> default:
>> @@ -245,7 +252,8 @@ static int mlx90614_write_raw(struct iio_dev *indio_dev,
>> case IIO_CHAN_INFO_CALIBEMISSIVITY: /* 1/65535 / LSB */
>> if (val < 0 || val2 < 0 || val > 1 || (val == 1 && val2 != 0))
>> return -EINVAL;
>> -val = val * 65535 + val2 / 15259; /* 1/65535 ~ 0.000015259 */
>> +val = val * MLX90614_CONST_RAW_EMISSIVITY_MAX +
>> +val2 / MLX90614_CONST_EMISSIVITY_RESOLUTION;
>>
>> mlx90614_power_get(data, false);
>> mutex_lock(&data->lock);
>>
>>
>> On 19 July 2015 at 13:33, Jonathan Cameron <jic23@kernel.org <mailto:jic23@kernel.org>> wrote:
>>
>>     On 05/07/15 19:07, Crt Mori wrote:
>>     > Translates the magic constant numbers to named macros and add some
>>     > additional comments about their meaning.
>>     >
>>     > The diff is made towards togreg branch as that branch seems to have the
>>     > most recent updates of mlx90614 driver (many are yet to be merged).
>>     >
>>     > Signed-off-by: Crt Mori <cmo@melexis.com <mailto:cmo@melexis.com>>
>>     > Acked-by: Peter Meerwald <pmeerw@pmeerw.net <mailto:pmeerw@pmeerw.net>>
>>     Crt,
>>
>>     This patch is malformed, probably as a result of your email client.
>>     It seems to have replaced tabs with spaces meaning I can't apply this
>>     without doing it line by line.
>>
>>     Could you take a look at Documentation/SubmittingPatches and the advice
>>     in there on how to lure an email client into not messing things up.
>>
>>     If you can't persuade that to work, I will take the occasional attachment.
>>
>>     Otherwise, the patch looks fine.
>>
>>     Jonathan
>>
>> I hope it is now OK? I needed to turn off google's mail mode, and apparently plain text
>> mode also translates tabs into spaces. I have now fixed the tabs and I hope they are
>> also sent. Please let me know - I will otherwise just pull some mail client and get it
>> working.
>>
>> Crt
>>
>>
>>     > ---
>>     >  drivers/iio/temperature/mlx90614.c | 20 ++++++++++++++------
>>     >  1 file changed, 14 insertions(+), 6 deletions(-)
>>     >
>>     > diff --git a/drivers/iio/temperature/mlx90614.c
>>     > b/drivers/iio/temperature/mlx90614.c
>>     > index cb2e8ad..909278a 100644
>>     > --- a/drivers/iio/temperature/mlx90614.c
>>     > +++ b/drivers/iio/temperature/mlx90614.c
>>     > @@ -65,6 +65,13 @@
>>     >
>>     >  #define MLX90614_AUTOSLEEP_DELAY 5000 /* default autosleep delay */
>>     >
>>     > +/* Magic constants */
>>     > +#define MLX90614_CONST_OFFSET_DEC -13657 /* decimal part of the
>>     > Kelvin offset */
>>     > +#define MLX90614_CONST_OFFSET_REM 500000 /* remainder of offset (273.15*50) */
>>     > +#define MLX90614_CONST_SCALE 20 /* Scale in milliKelvin (0.02 * 1000) */
>>     > +#define MLX90614_CONST_RAW_EMISSIVITY_MAX 65535 /* max value for emissivity */
>>     > +#define MLX90614_CONST_EMISSIVITY_RESOLUTION 15259 /* 1/65535 ~ 0.000015259 */
>>     > +
>>     >  struct mlx90614_data {
>>     >         struct i2c_client *client;
>>     >         struct mutex lock; /* for EEPROM access only */
>>     > @@ -204,11 +211,11 @@ static int mlx90614_read_raw(struct iio_dev *indio_dev,
>>     >                 *val = ret;
>>     >                 return IIO_VAL_INT;
>>     >         case IIO_CHAN_INFO_OFFSET:
>>     > -               *val = 13657;
>>     > -               *val2 = 500000;
>>     > +               *val = MLX90614_CONST_OFFSET_DEC;
>>     > +               *val2 = MLX90614_CONST_OFFSET_REM;
>>     >                 return IIO_VAL_INT_PLUS_MICRO;
>>     >         case IIO_CHAN_INFO_SCALE:
>>     > -               *val = 20;
>>     > +               *val = MLX90614_CONST_SCALE;
>>     >                 return IIO_VAL_INT;
>>     >         case IIO_CHAN_INFO_CALIBEMISSIVITY: /* 1/65535 / LSB */
>>     >                 mlx90614_power_get(data, false);
>>     > @@ -221,12 +228,12 @@ static int mlx90614_read_raw(struct iio_dev *indio_dev,
>>     >                 if (ret < 0)
>>     >                         return ret;
>>     >
>>     > -               if (ret == 65535) {
>>     > +               if (ret == MLX90614_CONST_RAW_EMISSIVITY_MAX) {
>>     >                         *val = 1;
>>     >                         *val2 = 0;
>>     >                 } else {
>>     >                         *val = 0;
>>     > -                       *val2 = ret * 15259; /* 1/65535 ~ 0.000015259 */
>>     > +                       *val2 = ret * MLX90614_CONST_EMISSIVITY_RESOLUTION;
>>     >                 }
>>     >                 return IIO_VAL_INT_PLUS_NANO;
>>     >         default:
>>     > @@ -245,7 +252,8 @@ static int mlx90614_write_raw(struct iio_dev *indio_dev,
>>     >         case IIO_CHAN_INFO_CALIBEMISSIVITY: /* 1/65535 / LSB */
>>     >                 if (val < 0 || val2 < 0 || val > 1 || (val == 1 && val2 != 0))
>>     >                         return -EINVAL;
>>     > -               val = val * 65535 + val2 / 15259; /* 1/65535 ~ 0.000015259 */
>>     > +               val = val * MLX90614_CONST_RAW_EMISSIVITY_MAX +
>>     > +                       val2 / MLX90614_CONST_EMISSIVITY_RESOLUTION;
>>     >
>>     >                 mlx90614_power_get(data, false);
>>     >                 mutex_lock(&data->lock);
>>     >
>>
>>
>

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

* [PATCH] iio: mlx90614: Define magic numbers
@ 2015-07-20 19:38 Crt Mori
  2015-08-02 16:50 ` Jonathan Cameron
  0 siblings, 1 reply; 8+ messages in thread
From: Crt Mori @ 2015-07-20 19:38 UTC (permalink / raw)
  To: jic23, linux-iio, pmeerw, vianney.leclement; +Cc: Crt Mori

Translates the magic constant numbers to named macros and add some
additional comments about their meaning.

The diff is made towards togreg branch as that branch seems to have the
most recent updates of mlx90614 driver (many are yet to be merged).

Signed-off-by: Crt Mori <cmo@melexis.com>
Acked-by: Peter Meerwald <pmeerw@pmeerw.net>
---
 drivers/iio/temperature/mlx90614.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/drivers/iio/temperature/mlx90614.c b/drivers/iio/temperature/mlx90614.c
index cb2e8ad..4590f83 100644
--- a/drivers/iio/temperature/mlx90614.c
+++ b/drivers/iio/temperature/mlx90614.c
@@ -65,6 +65,13 @@
 
 #define MLX90614_AUTOSLEEP_DELAY 5000 /* default autosleep delay */
 
+/* Magic constants */
+#define MLX90614_CONST_OFFSET_DEC -13657 /* decimal part of the Kelvin offset */
+#define MLX90614_CONST_OFFSET_REM 500000 /* remainder of offset (273.15*50) */
+#define MLX90614_CONST_SCALE 20 /* Scale in milliKelvin (0.02 * 1000) */
+#define MLX90614_CONST_RAW_EMISSIVITY_MAX 65535 /* max value for emissivity */
+#define MLX90614_CONST_EMISSIVITY_RESOLUTION 15259 /* 1/65535 ~ 0.000015259 */
+
 struct mlx90614_data {
 	struct i2c_client *client;
 	struct mutex lock; /* for EEPROM access only */
@@ -204,11 +211,11 @@ static int mlx90614_read_raw(struct iio_dev *indio_dev,
 		*val = ret;
 		return IIO_VAL_INT;
 	case IIO_CHAN_INFO_OFFSET:
-		*val = 13657;
-		*val2 = 500000;
+		*val = MLX90614_CONST_OFFSET_DEC;
+		*val2 = MLX90614_CONST_OFFSET_REM;
 		return IIO_VAL_INT_PLUS_MICRO;
 	case IIO_CHAN_INFO_SCALE:
-		*val = 20;
+		*val = MLX90614_CONST_SCALE;
 		return IIO_VAL_INT;
 	case IIO_CHAN_INFO_CALIBEMISSIVITY: /* 1/65535 / LSB */
 		mlx90614_power_get(data, false);
@@ -221,12 +228,12 @@ static int mlx90614_read_raw(struct iio_dev *indio_dev,
 		if (ret < 0)
 			return ret;
 
-		if (ret == 65535) {
+		if (ret == MLX90614_CONST_RAW_EMISSIVITY_MAX) {
 			*val = 1;
 			*val2 = 0;
 		} else {
 			*val = 0;
-			*val2 = ret * 15259; /* 1/65535 ~ 0.000015259 */
+			*val2 = ret * MLX90614_CONST_EMISSIVITY_RESOLUTION;
 		}
 		return IIO_VAL_INT_PLUS_NANO;
 	default:
@@ -245,7 +252,8 @@ static int mlx90614_write_raw(struct iio_dev *indio_dev,
 	case IIO_CHAN_INFO_CALIBEMISSIVITY: /* 1/65535 / LSB */
 		if (val < 0 || val2 < 0 || val > 1 || (val == 1 && val2 != 0))
 			return -EINVAL;
-		val = val * 65535 + val2 / 15259; /* 1/65535 ~ 0.000015259 */
+		val = val * MLX90614_CONST_RAW_EMISSIVITY_MAX +
+			val2 / MLX90614_CONST_EMISSIVITY_RESOLUTION;
 
 		mlx90614_power_get(data, false);
 		mutex_lock(&data->lock);
-- 
2.1.4

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

* Re: [PATCH] iio: mlx90614: Define magic numbers
  2015-07-20 19:38 Crt Mori
@ 2015-08-02 16:50 ` Jonathan Cameron
  0 siblings, 0 replies; 8+ messages in thread
From: Jonathan Cameron @ 2015-08-02 16:50 UTC (permalink / raw)
  To: Crt Mori, linux-iio, pmeerw, vianney.leclement

On 20/07/15 20:38, Crt Mori wrote:
> Translates the magic constant numbers to named macros and add some
> additional comments about their meaning.
> 
> The diff is made towards togreg branch as that branch seems to have the
> most recent updates of mlx90614 driver (many are yet to be merged).
> 
> Signed-off-by: Crt Mori <cmo@melexis.com>
> Acked-by: Peter Meerwald <pmeerw@pmeerw.net>
Applied to the togreg branch of iio.git - initially pushed out as
testing for the autobuilders to play with it.
Should get a pull request out to Greg later in the week,

Jonathan
> ---
>  drivers/iio/temperature/mlx90614.c | 20 ++++++++++++++------
>  1 file changed, 14 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/iio/temperature/mlx90614.c b/drivers/iio/temperature/mlx90614.c
> index cb2e8ad..4590f83 100644
> --- a/drivers/iio/temperature/mlx90614.c
> +++ b/drivers/iio/temperature/mlx90614.c
> @@ -65,6 +65,13 @@
>  
>  #define MLX90614_AUTOSLEEP_DELAY 5000 /* default autosleep delay */
>  
> +/* Magic constants */
> +#define MLX90614_CONST_OFFSET_DEC -13657 /* decimal part of the Kelvin offset */
> +#define MLX90614_CONST_OFFSET_REM 500000 /* remainder of offset (273.15*50) */
> +#define MLX90614_CONST_SCALE 20 /* Scale in milliKelvin (0.02 * 1000) */
> +#define MLX90614_CONST_RAW_EMISSIVITY_MAX 65535 /* max value for emissivity */
> +#define MLX90614_CONST_EMISSIVITY_RESOLUTION 15259 /* 1/65535 ~ 0.000015259 */
> +
>  struct mlx90614_data {
>  	struct i2c_client *client;
>  	struct mutex lock; /* for EEPROM access only */
> @@ -204,11 +211,11 @@ static int mlx90614_read_raw(struct iio_dev *indio_dev,
>  		*val = ret;
>  		return IIO_VAL_INT;
>  	case IIO_CHAN_INFO_OFFSET:
> -		*val = 13657;
> -		*val2 = 500000;
> +		*val = MLX90614_CONST_OFFSET_DEC;
> +		*val2 = MLX90614_CONST_OFFSET_REM;
>  		return IIO_VAL_INT_PLUS_MICRO;
>  	case IIO_CHAN_INFO_SCALE:
> -		*val = 20;
> +		*val = MLX90614_CONST_SCALE;
>  		return IIO_VAL_INT;
>  	case IIO_CHAN_INFO_CALIBEMISSIVITY: /* 1/65535 / LSB */
>  		mlx90614_power_get(data, false);
> @@ -221,12 +228,12 @@ static int mlx90614_read_raw(struct iio_dev *indio_dev,
>  		if (ret < 0)
>  			return ret;
>  
> -		if (ret == 65535) {
> +		if (ret == MLX90614_CONST_RAW_EMISSIVITY_MAX) {
>  			*val = 1;
>  			*val2 = 0;
>  		} else {
>  			*val = 0;
> -			*val2 = ret * 15259; /* 1/65535 ~ 0.000015259 */
> +			*val2 = ret * MLX90614_CONST_EMISSIVITY_RESOLUTION;
>  		}
>  		return IIO_VAL_INT_PLUS_NANO;
>  	default:
> @@ -245,7 +252,8 @@ static int mlx90614_write_raw(struct iio_dev *indio_dev,
>  	case IIO_CHAN_INFO_CALIBEMISSIVITY: /* 1/65535 / LSB */
>  		if (val < 0 || val2 < 0 || val > 1 || (val == 1 && val2 != 0))
>  			return -EINVAL;
> -		val = val * 65535 + val2 / 15259; /* 1/65535 ~ 0.000015259 */
> +		val = val * MLX90614_CONST_RAW_EMISSIVITY_MAX +
> +			val2 / MLX90614_CONST_EMISSIVITY_RESOLUTION;
>  
>  		mlx90614_power_get(data, false);
>  		mutex_lock(&data->lock);
> 


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

end of thread, other threads:[~2015-08-02 16:50 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-05 18:07 [PATCH] iio: mlx90614: Define magic numbers Crt Mori
2015-07-19 11:33 ` Jonathan Cameron
2015-07-19 20:14   ` Crt Mori
2015-07-20 17:56     ` Jonathan Cameron
2015-07-20 19:09       ` Crt Mori
  -- strict thread matches above, loose matches on Subject: below --
2015-07-20 19:06 Crt Mori
2015-07-20 19:38 Crt Mori
2015-08-02 16:50 ` Jonathan Cameron

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.