Skip to contentSkip to conversation

iio: mlx90614: Implement filter configuration

PATCH Superseded Crt Mori 2 participants 3 messages Aug 17, 2015

Subsystems (2)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Crt Mori

author maintainer
#0 lore raw

PATCH v4 1/1 iio: mlx90614: Implement filter configuration

Implemented Low pass 3db frequency filter which configures FIR and IIR values within the configuration register of EEPROM. For more standardized interface we have fixed the FIR value to 1024, while changes in IIR value are directly connected to filter responses. The new datasheet version will provide a simplified table (also in reStructured text format below) with this change, to provide quick overview of possible settings.

Below sensor timings (bandwidth) are calculated for 3db frequency low pass filter.

+--------------------+-----------------+
| Filter setting (%) | Band width (Hz) |
|  (rounded to 1.0)  |                 |
+====================+=================+
|         13         |      0.15       |
+--------------------+-----------------+
|         17         |      0.20       |
+--------------------+-----------------+
|         25         |      0.31       |
+--------------------+-----------------+
|         50         |      0.77       |
+--------------------+-----------------+
|         57         |      0.86       |
+--------------------+-----------------+
|         67         |      1.10       |
+--------------------+-----------------+
|         80         |      1.53       |
+--------------------+-----------------+
|        100         |      7.23       |
+--------------------+-----------------+

The diff is made towards togreg branch. Added myself to MAINTAINERS and authors as per discussion with Jonathan.

---
 MAINTAINERS                        |  7 +++
 drivers/iio/temperature/mlx90614.c | 89 ++++++++++++++++++++++++++++++++++++--
 2 files changed, 93 insertions(+), 3 deletions(-)
MAINTAINERS +7 -0
index 8133cef..f658890 100644
@@ -6739,6 +6739,13 @@ S:	Supported
 F:	include/linux/mlx5/
 F:	drivers/infiniband/hw/mlx5/
 
+MELEXIS MLX90614 DRIVER
+M:	Crt Mori <[email protected]>
+L:	[email protected]
+W:	http://www.melexis.com
+S:	Supported
+F:	drivers/iio/temperature/mlx90614.c
+
 MN88472 MEDIA DRIVER
 M:	Antti Palosaari <[email protected]>
 L:	[email protected]
drivers/iio/temperature/mlx90614.c +86 -3

160 lines not on this page · raw message

Signature · 1 line
2.1.4
#1 lore raw
Quoted 7 lines · Crt Mori

Implemented Low pass 3db frequency filter which configures FIR and IIR values within the configuration register of EEPROM. For more standardized interface we have fixed the FIR value to 1024, while changes in IIR value are directly connected to filter responses. The new datasheet version will provide a simplified table (also in reStructured text format below) with this change, to provide quick overview of possible settings.

see comment below

Quoted 102 lines

Below sensor timings (bandwidth) are calculated for 3db frequency low pass filter.

+--------------------+-----------------+
| Filter setting (%) | Band width (Hz) |
|  (rounded to 1.0)  |                 |
+====================+=================+
|         13         |      0.15       |
+--------------------+-----------------+
|         17         |      0.20       |
+--------------------+-----------------+
|         25         |      0.31       |
+--------------------+-----------------+
|         50         |      0.77       |
+--------------------+-----------------+
|         57         |      0.86       |
+--------------------+-----------------+
|         67         |      1.10       |
+--------------------+-----------------+
|         80         |      1.53       |
+--------------------+-----------------+
|        100         |      7.23       |
+--------------------+-----------------+

The diff is made towards togreg branch. Added myself to MAINTAINERS and authors as per discussion with Jonathan.

---
 MAINTAINERS                        |  7 +++
 drivers/iio/temperature/mlx90614.c | 89 ++++++++++++++++++++++++++++++++++++--
 2 files changed, 93 insertions(+), 3 deletions(-)
MAINTAINERS +7 -0
index 8133cef..f658890 100644
@@ -6739,6 +6739,13 @@ S:	Supported
 F:	include/linux/mlx5/
 F:	drivers/infiniband/hw/mlx5/
 
+MELEXIS MLX90614 DRIVER
+M:	Crt Mori <[email protected]>
+L:	[email protected]
+W:	http://www.melexis.com
+S:	Supported
+F:	drivers/iio/temperature/mlx90614.c
+
 MN88472 MEDIA DRIVER
 M:	Antti Palosaari <[email protected]>
 L:	[email protected]
drivers/iio/temperature/mlx90614.c +16 -1
index 5d033a5..08e2bbf 100644
@@ -3,6 +3,7 @@
  *
  * Copyright (c) 2014 Peter Meerwald <[email protected]>
  * Copyright (c) 2015 Essensium NV
+ * Copyright (c) 2015 Melexis
  *
  * This file is subject to the terms and conditions of version 2 of
  * the GNU General Public License.  See the file COPYING in the main
@@ -20,7 +21,6 @@
  * always has a pull-up so we do not need an extra GPIO to drive it high.  If
  * the "wakeup" GPIO is not given, power management will be disabled.
  *
- * TODO: filter configuration
  */
 
 #include <linux/err.h>
@@ -32,6 +32,7 @@
 #include <linux/pm_runtime.h>
 
 #include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
 
 #define MLX90614_OP_RAM		0x00
 #define MLX90614_OP_EEPROM	0x20
@@ -79,6 +80,20 @@ struct mlx90614_data {
 	unsigned long ready_timestamp; /* in jiffies */
 };
 
+/* Bandwidth values for IIR filtering */
+static const int mlx90614_iir_values[] = {77, 31, 20, 15, 723, 153, 110, 86};
+static IIO_CONST_ATTR(in_temp_object_filter_low_pass_3db_frequency_available,
+		      "0.15 0.20 0.31 0.77 0.86 1.10 1.53 7.23");
+
+static struct attribute *mlx90614_attributes[] = {
+	&iio_const_attr_in_temp_object_filter_low_pass_3db_frequency_available.dev_attr.attr,
+	NULL,
+};
+
+static const struct attribute_group mlx90614_attr_group = {
+	.attrs = mlx90614_attributes,
+};
+
 /*
  * Erase an address and write word.
  * The mutex must be locked before calling.
@@ -117,6 +132,41 @@ static s32 mlx90614_write_word(const struct i2c_client *client, u8 command,
 	return ret;

drivers/iio/temperature/mlx90614.c static s32 mlx90614_write_word(const struct i2c_client *client, u8 command, · line 142

Quoted 10 lines
drivers/iio/temperature/mlx90614.c +8 -0
 }
 
+/*
+ * Find the IIR value inside mlx90614_iir_values array and return its position
+ * which is equivalent to the bit value in sensor register
+ */
+static inline s32 mlx90614_iir_search(const struct i2c_client *client,
+				      int value)
+{
+	u8 i;

I'd rather use int for the loop variable

drivers/iio/temperature/mlx90614.c static s32 mlx90614_write_word(const struct i2c_client *client, u8 command, · line 150

Quoted 8 lines
drivers/iio/temperature/mlx90614.c +8 -0
+	s32 ret;
+
+	for (i = 0; i < ARRAY_SIZE(mlx90614_iir_values); ++i) {
+		if (value == mlx90614_iir_values[i])
+			break;
+	}
+
+	if (value != mlx90614_iir_values[i])

this is an out-of-bound access beyond _iir_values

drivers/iio/temperature/mlx90614.c static s32 mlx90614_write_word(const struct i2c_client *client, u8 command, · line 158

Quoted 8 lines
drivers/iio/temperature/mlx90614.c +8 -0
+		return -EINVAL;
+
+	/*
+	 * CONFIG register values must not be changed so
+	 * we must read them before we actually write
+	 * changes
+	 */
+	ret = i2c_smbus_read_word_data(client, MLX90614_CONFIG);

I'd rather do
if (ret < 0)
return ret;

drivers/iio/temperature/mlx90614.c static s32 mlx90614_write_word(const struct i2c_client *client, u8 command, · line 165

Quoted 7 lines
drivers/iio/temperature/mlx90614.c +7 -0
+	if (ret >= 0) {
+		/* Write changed values */
+		ret = mlx90614_write_word(client, MLX90614_CONFIG,
+				(i << MLX90614_CONFIG_IIR_SHIFT) |
+				(((u16) ((0x7 << MLX90614_CONFIG_FIR_SHIFT) |
+				((u16) ret & (~((u16) MLX90614_CONFIG_FIR_MASK))))) &
+				(~(u16) MLX90614_CONFIG_IIR_MASK)));

this is still a mess, ehm, not very readable

Quoted 14 lines
drivers/iio/temperature/mlx90614.c +7 -0
+	}
+	return ret;
+}
+
 #ifdef CONFIG_PM
 /*
  * If @startup is true, make sure MLX90614_TIMING_STARTUP ms have elapsed since
@@ -236,6 +286,21 @@ static int mlx90614_read_raw(struct iio_dev *indio_dev,
 			*val2 = ret * MLX90614_CONST_EMISSIVITY_RESOLUTION;
 		}
 		return IIO_VAL_INT_PLUS_NANO;
+	case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY: /* IIR setting with
+							     FIR = 1024 */
+		mlx90614_power_get(data, false);

drivers/iio/temperature/mlx90614.c static int mlx90614_read_raw(struct iio_dev *indio_dev, · line 301

Quoted 10 lines
drivers/iio/temperature/mlx90614.c +10 -0
+		mutex_lock(&data->lock);
+		ret = i2c_smbus_read_word_data(data->client, MLX90614_CONFIG);
+		mutex_unlock(&data->lock);
+		mlx90614_power_put(data);
+
+		if (ret < 0)
+			return ret;
+
+		*val = mlx90614_iir_values[ret & MLX90614_CONFIG_IIR_MASK] / 100;
+		*val2 = mlx90614_iir_values[ret & MLX90614_CONFIG_IIR_MASK] % 100 *

probably add parenthesis and don't rely on operator precedence for clarity

Quoted 69 lines
drivers/iio/temperature/mlx90614.c +22 -2
+			10000;
+		return IIO_VAL_INT_PLUS_MICRO;
 	default:
 		return -EINVAL;
 	}
@@ -263,6 +328,18 @@ static int mlx90614_write_raw(struct iio_dev *indio_dev,
 		mlx90614_power_put(data);
 
 		return ret;
+	case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY: /* IIR Filter setting */
+		if (val < 0 || val2 < 0)
+			return -EINVAL;
+
+		mlx90614_power_get(data, false);
+		mutex_lock(&data->lock);
+		ret = mlx90614_iir_search(data->client,
+					  val * 100 + val2 / 10000);
+		mutex_unlock(&data->lock);
+		mlx90614_power_put(data);
+
+		return ret;
 	default:
 		return -EINVAL;
 	}
@@ -275,6 +352,8 @@ static int mlx90614_write_raw_get_fmt(struct iio_dev *indio_dev,
 	switch (mask) {
 	case IIO_CHAN_INFO_CALIBEMISSIVITY:
 		return IIO_VAL_INT_PLUS_NANO;
+	case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY:
+		return IIO_VAL_INT_PLUS_MICRO;
 	default:
 		return -EINVAL;
 	}
@@ -294,7 +373,8 @@ static const struct iio_chan_spec mlx90614_channels[] = {
 		.modified = 1,
 		.channel2 = IIO_MOD_TEMP_OBJECT,
 		.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
-		    BIT(IIO_CHAN_INFO_CALIBEMISSIVITY),
+		    BIT(IIO_CHAN_INFO_CALIBEMISSIVITY) |
+			BIT(IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY),
 		.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) |
 		    BIT(IIO_CHAN_INFO_SCALE),
 	},
@@ -305,7 +385,8 @@ static const struct iio_chan_spec mlx90614_channels[] = {
 		.channel = 1,
 		.channel2 = IIO_MOD_TEMP_OBJECT,
 		.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
-		    BIT(IIO_CHAN_INFO_CALIBEMISSIVITY),
+		    BIT(IIO_CHAN_INFO_CALIBEMISSIVITY) |
+			BIT(IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY),
 		.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) |
 		    BIT(IIO_CHAN_INFO_SCALE),
 	},
@@ -315,6 +396,7 @@ static const struct iio_info mlx90614_info = {
 	.read_raw = mlx90614_read_raw,
 	.write_raw = mlx90614_write_raw,
 	.write_raw_get_fmt = mlx90614_write_raw_get_fmt,
+	.attrs = &mlx90614_attr_group,
 	.driver_module = THIS_MODULE,
 };
 
@@ -569,5 +651,6 @@ module_i2c_driver(mlx90614_driver);
 
 MODULE_AUTHOR("Peter Meerwald <[email protected]>");
 MODULE_AUTHOR("Vianney le Clément de Saint-Marcq <[email protected]>");
+MODULE_AUTHOR("Crt Mori <[email protected]>");
 MODULE_DESCRIPTION("Melexis MLX90614 contactless IR temperature sensor driver");
 MODULE_LICENSE("GPL");
Signature · 2 lines
Peter Meerwald
+43-664-2444418 (mobile)
author maintainer
#2 lore raw
Quoted 10 lines · Peter Meerwald
Quoted 7 lines · Crt Mori

Implemented Low pass 3db frequency filter which configures FIR and IIR values within the configuration register of EEPROM. For more standardized interface we have fixed the FIR value to 1024, while changes in IIR value are directly connected to filter responses. The new datasheet version will provide a simplified table (also in reStructured text format below) with this change, to provide quick overview of possible settings.

Quoted 2 lines

see comment below

Thanks for checking. My replies inline below.

Quoted 7 lines
Quoted 7 lines

Below sensor timings (bandwidth) are calculated for 3db frequency low pass filter.

+--------------------+-----------------+
| Filter setting (%) | Band width (Hz) |
|  (rounded to 1.0)  |                 |
+=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+

Quoted 17 lines
Quoted 17 lines
|         13         |      0.15       |
+--------------------+-----------------+
|         17         |      0.20       |
+--------------------+-----------------+
|         25         |      0.31       |
+--------------------+-----------------+
|         50         |      0.77       |
+--------------------+-----------------+
|         57         |      0.86       |
+--------------------+-----------------+
|         67         |      1.10       |
+--------------------+-----------------+
|         80         |      1.53       |
+--------------------+-----------------+
|        100         |      7.23       |
+--------------------+-----------------+
Quoted 7 lines
Quoted 7 lines

The diff is made towards togreg branch. Added myself to MAINTAINERS and authors as per discussion with Jonathan.

---
 MAINTAINERS                        |  7 +++

drivers/iio/temperature/mlx90614.c | 89 +++++++++++++++++++++++++++++++=

+++++--

Quoted 10 lines
Quoted 10 lines
 2 files changed, 93 insertions(+), 3 deletions(-)
MAINTAINERS +0 -0
index 8133cef..f658890 100644
@@ -6739,6 +6739,13 @@ S:     Supported
 F:   include/linux/mlx5/
 F:   drivers/infiniband/hw/mlx5/
 
Quoted 11 lines

drivers/iio/temperatur=

Quoted 11 lines
MAINTAINERS +7 -0
+MELEXIS MLX90614 DRIVER
+M:   Crt Mori <[email protected]>
+L:   [email protected]
+W:   http://www.melexis.com
+S:   Supported
+F:   drivers/iio/temperature/mlx90614.c
+
 MN88472 MEDIA DRIVER
 M:   Antti Palosaari <[email protected]>
 L:   [email protected]
drivers/iio/temperatur= renamed from drivers/iio/temperature/mlx90614.c +0 -0

e/mlx90614.c

Quoted 5 lines
Quoted 5 lines

index 5d033a5..08e2bbf 100644

drivers/iio/temperature/mlx90614.c +0 -0
@@ -3,6 +3,7 @@
  *
Quoted 8 lines

drivers/iio/temperature/mlx90614.c line 21

Quoted 8 lines
drivers/iio/temperature/mlx90614.c +1 -0
  * Copyright (c) 2014 Peter Meerwald <[email protected]>
  * Copyright (c) 2015 Essensium NV
+ * Copyright (c) 2015 Melexis
  *
  * This file is subject to the terms and conditions of version 2 of
  * the GNU General Public License.  See the file COPYING in the main
@@ -20,7 +21,6 @@
  * always has a pull-up so we do not need an extra GPIO to drive it hig=

h. If

Quoted 12 lines
Quoted 12 lines
drivers/iio/temperature/mlx90614.c +1 -1
  * the "wakeup" GPIO is not given, power management will be disabled.
  *
- * TODO: filter configuration
  */
 
 #include <linux/err.h>
@@ -32,6 +32,7 @@
 #include <linux/pm_runtime.h>
 
 #include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
 
Quoted 8 lines

drivers/iio/temperature/mlx90614.c struct mlx90614_data { · line 84

Quoted 8 lines
drivers/iio/temperature/mlx90614.c +2 -0
 #define MLX90614_OP_RAM              0x00
 #define MLX90614_OP_EEPROM   0x20
@@ -79,6 +80,20 @@ struct mlx90614_data {
      unsigned long ready_timestamp; /* in jiffies */
 };
 
+/* Bandwidth values for IIR filtering */
+static const int mlx90614_iir_values[] =3D {77, 31, 20, 15, 723, 153, 1=

10, 86};

Quoted 1 line

drivers/iio/temperature/mlx90614.c struct mlx90614_data { · line 85

Quoted 1 line
drivers/iio/temperature/mlx90614.c +1 -0
+static IIO_CONST_ATTR(in_temp_object_filter_low_pass_3db_frequency_avai=

lable,

Quoted 4 lines

drivers/iio/temperature/mlx90614.c struct mlx90614_data {

Quoted 4 lines
drivers/iio/temperature/mlx90614.c +4 -0
+                   "0.15 0.20 0.31 0.77 0.86 1.10 1.53 7.23");
+
+static struct attribute *mlx90614_attributes[] =3D {
+     &iio_const_attr_in_temp_object_filter_low_pass_3db_frequency_avail=

able.dev_attr.attr,

Quoted 11 lines

drivers/iio/temperature/mlx90614.c static s32 mlx90614_write_word(const struct i2c_cli=

Quoted 11 lines
drivers/iio/temperature/mlx90614.c +7 -0
+     NULL,
+};
+
+static const struct attribute_group mlx90614_attr_group =3D {
+     .attrs =3D mlx90614_attributes,
+};
+
 /*
  * Erase an address and write word.
  * The mutex must be locked before calling.
@@ -117,6 +132,41 @@ static s32 mlx90614_write_word(const struct i2c_cli=

ent *client, u8 command,

Quoted 5 lines

drivers/iio/temperature/mlx90614.c static s32 mlx90614_write_word(const struct i2c_client *client, u8 command,

Quoted 5 lines
drivers/iio/temperature/mlx90614.c +2 -0
      return ret;
 }
 
+/*
+ * Find the IIR value inside mlx90614_iir_values array and return its p=

osition

Quoted 9 lines

drivers/iio/temperature/mlx90614.c static s32 mlx90614_write_word(const struct i2c_client *client, u8 command, · line 142

Quoted 6 lines
drivers/iio/temperature/mlx90614.c +6 -0
+ * which is equivalent to the bit value in sensor register
+ */
+static inline s32 mlx90614_iir_search(const struct i2c_client *client,
+                                   int value)
+{
+     u8 i;

I'd rather use int for the loop variable

ok, bad habbit of mine to use minimal stuff.

Quoted 11 lines

drivers/iio/temperature/mlx90614.c static s32 mlx90614_write_word(const struct i2c_client *client, u8 command,

Quoted 8 lines
drivers/iio/temperature/mlx90614.c +8 -0
+     s32 ret;
+
+     for (i =3D 0; i < ARRAY_SIZE(mlx90614_iir_values); ++i) {
+             if (value =3D=3D mlx90614_iir_values[i])
+                     break;
+     }
+
+     if (value !=3D mlx90614_iir_values[i])

this is an out-of-bound access beyond _iir_values

will change to something like i =3D=3D ARRAY_SIZE(mlx90614_iir_values)

Quoted 9 lines

drivers/iio/temperature/mlx90614.c static s32 mlx90614_write_word(const struct i2c_client *client, u8 command,

Quoted 8 lines
drivers/iio/temperature/mlx90614.c +8 -0
+             return -EINVAL;
+
+     /*
+      * CONFIG register values must not be changed so
+      * we must read them before we actually write
+      * changes
+      */
+     ret =3D i2c_smbus_read_word_data(client, MLX90614_CONFIG);
Quoted 4 lines

I'd rather do
if (ret < 0)
return ret;

thanks - slipped my view.

Quoted 5 lines

drivers/iio/temperature/mlx90614.c static s32 mlx90614_write_word(const struct i2c_cli= · line 163

Quoted 5 lines
drivers/iio/temperature/mlx90614.c +5 -0
+     if (ret >=3D 0) {
+             /* Write changed values */
+             ret =3D mlx90614_write_word(client, MLX90614_CONFIG,
+                             (i << MLX90614_CONFIG_IIR_SHIFT) |
+                             (((u16) ((0x7 << MLX90614_CONFIG_FIR_SHIFT=

) |

Quoted 1 line

drivers/iio/temperature/mlx90614.c static s32 mlx90614_write_word(const struct i2c_cli= · line 164

Quoted 1 line
drivers/iio/temperature/mlx90614.c +1 -0
+                             ((u16) ret & (~((u16) MLX90614_CONFIG_FIR_=

MASK))))) &

Quoted 4 lines

drivers/iio/temperature/mlx90614.c static s32 mlx90614_write_word(const struct i2c_client *client, u8 command, · line 165

Quoted 1 line
drivers/iio/temperature/mlx90614.c +1 -0
+                             (~(u16) MLX90614_CONFIG_IIR_MASK)));

this is still a mess, ehm, not very readable

Except for splitting this up (fir shift and mask in separate variable) or as nested macro
I doubt I can make it more readable. I also think compiler does handle this nicely without
additional variables.
I could add a comment up there which explains that we fix FIR to 1024, with that 0x7
and shift and application of FIR mask, then afterwards we apply IIR value with IIR mask.

Quoted 7 lines

drivers/iio/temperature/mlx90614.c static s32 mlx90614_write_word(const struct i2c_client *client, u8 command,

Quoted 7 lines
drivers/iio/temperature/mlx90614.c +4 -0
+     }
+     return ret;
+}
+
 #ifdef CONFIG_PM
 /*
  * If @startup is true, make sure MLX90614_TIMING_STARTUP ms have elaps=

ed since

Quoted 1 line

drivers/iio/temperature/mlx90614.c static int mlx90614_read_raw(struct iio_dev *indio_=

Quoted 1 line
drivers/iio/temperature/mlx90614.c +0 -0
@@ -236,6 +286,21 @@ static int mlx90614_read_raw(struct iio_dev *indio_=

dev,

Quoted 1 line

drivers/iio/temperature/mlx90614.c static int mlx90614_read_raw(struct iio_dev *indio_= · line 286

Quoted 1 line
drivers/iio/temperature/mlx90614.c +0 -0
                      *val2 =3D ret * MLX90614_CONST_EMISSIVITY_RESOLUTI=

ON;

Quoted 3 lines

drivers/iio/temperature/mlx90614.c static int mlx90614_read_raw(struct iio_dev *indio_dev,

Quoted 3 lines
drivers/iio/temperature/mlx90614.c +1 -0
              }
              return IIO_VAL_INT_PLUS_NANO;
+     case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY: /* IIR setting w=

ith

Quoted 1 line

drivers/iio/temperature/mlx90614.c static int mlx90614_read_raw(struct iio_dev *indio_= · line 290

Quoted 1 line
drivers/iio/temperature/mlx90614.c +1 -0
+                                                          FIR =3D 1024 =

*/

Quoted 3 lines

drivers/iio/temperature/mlx90614.c static int mlx90614_read_raw(struct iio_dev *indio_dev,

Quoted 3 lines
drivers/iio/temperature/mlx90614.c +3 -0
+             mlx90614_power_get(data, false);
+             mutex_lock(&data->lock);
+             ret =3D i2c_smbus_read_word_data(data->client, MLX90614_CO=

NFIG);

Quoted 7 lines

drivers/iio/temperature/mlx90614.c static int mlx90614_read_raw(struct iio_dev *indio_dev,

Quoted 7 lines
drivers/iio/temperature/mlx90614.c +7 -0
+             mutex_unlock(&data->lock);
+             mlx90614_power_put(data);
+
+             if (ret < 0)
+                     return ret;
+
+             *val =3D mlx90614_iir_values[ret & MLX90614_CONFIG_IIR_MAS=

K] / 100;

Quoted 1 line

drivers/iio/temperature/mlx90614.c static int mlx90614_read_raw(struct iio_dev *indio_= · line 301

Quoted 1 line
drivers/iio/temperature/mlx90614.c +1 -0
+             *val2 =3D mlx90614_iir_values[ret & MLX90614_CONFIG_IIR_MA=

SK] % 100 *

Quoted 2 lines

probably add parenthesis and don't rely on operator precedence for clarit=

y

Quoted 1 line

OK, I thought point was to rely on operator precedence to avoid additional parenthesis.

Quoted 6 lines

drivers/iio/temperature/mlx90614.c static int mlx90614_write_raw(struct iio_dev *indio=

Quoted 6 lines
drivers/iio/temperature/mlx90614.c +2 -0
+                     10000;
+             return IIO_VAL_INT_PLUS_MICRO;
      default:
              return -EINVAL;
      }
@@ -263,6 +328,18 @@ static int mlx90614_write_raw(struct iio_dev *indio=

_dev,

Quoted 4 lines

drivers/iio/temperature/mlx90614.c static int mlx90614_write_raw(struct iio_dev *indio_dev,

Quoted 4 lines
drivers/iio/temperature/mlx90614.c +1 -0
              mlx90614_power_put(data);
 
              return ret;
+     case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY: /* IIR Filter se=

tting */

Quoted 7 lines
Quoted 7 lines
drivers/iio/temperature/mlx90614.c +7 -0
+             if (val < 0 || val2 < 0)
+                     return -EINVAL;
+
+             mlx90614_power_get(data, false);
+             mutex_lock(&data->lock);
+             ret =3D mlx90614_iir_search(data->client,
+                                       val * 100 + val2 / 10000);
Quoted 8 lines

drivers/iio/temperature/mlx90614.c static int mlx90614_write_raw_get_fmt(struct iio_dev=

Quoted 8 lines
drivers/iio/temperature/mlx90614.c +4 -0
+             mutex_unlock(&data->lock);
+             mlx90614_power_put(data);
+
+             return ret;
      default:
              return -EINVAL;
      }
@@ -275,6 +352,8 @@ static int mlx90614_write_raw_get_fmt(struct iio_dev=

*indio_dev,

Quoted 9 lines

drivers/iio/temperature/mlx90614.c static const struct iio_chan_spec mlx90614_channels[=

Quoted 9 lines
drivers/iio/temperature/mlx90614.c +2 -0
      switch (mask) {
      case IIO_CHAN_INFO_CALIBEMISSIVITY:
              return IIO_VAL_INT_PLUS_NANO;
+     case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY:
+             return IIO_VAL_INT_PLUS_MICRO;
      default:
              return -EINVAL;
      }
@@ -294,7 +373,8 @@ static const struct iio_chan_spec mlx90614_channels[=

] =3D {

Quoted 10 lines

drivers/iio/temperature/mlx90614.c static const struct iio_chan_spec mlx90614_channels[=

Quoted 10 lines
drivers/iio/temperature/mlx90614.c +2 -1
              .modified =3D 1,
              .channel2 =3D IIO_MOD_TEMP_OBJECT,
              .info_mask_separate =3D BIT(IIO_CHAN_INFO_RAW) |
-                 BIT(IIO_CHAN_INFO_CALIBEMISSIVITY),
+                 BIT(IIO_CHAN_INFO_CALIBEMISSIVITY) |
+                     BIT(IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY),
              .info_mask_shared_by_type =3D BIT(IIO_CHAN_INFO_OFFSET) |
                  BIT(IIO_CHAN_INFO_SCALE),
      },
@@ -305,7 +385,8 @@ static const struct iio_chan_spec mlx90614_channels[=

] =3D {

Quoted 17 lines
Quoted 17 lines
drivers/iio/temperature/mlx90614.c +3 -1
              .channel =3D 1,
              .channel2 =3D IIO_MOD_TEMP_OBJECT,
              .info_mask_separate =3D BIT(IIO_CHAN_INFO_RAW) |
-                 BIT(IIO_CHAN_INFO_CALIBEMISSIVITY),
+                 BIT(IIO_CHAN_INFO_CALIBEMISSIVITY) |
+                     BIT(IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY),
              .info_mask_shared_by_type =3D BIT(IIO_CHAN_INFO_OFFSET) |
                  BIT(IIO_CHAN_INFO_SCALE),
      },
@@ -315,6 +396,7 @@ static const struct iio_info mlx90614_info =3D {
      .read_raw =3D mlx90614_read_raw,
      .write_raw =3D mlx90614_write_raw,
      .write_raw_get_fmt =3D mlx90614_write_raw_get_fmt,
+     .attrs =3D &mlx90614_attr_group,
      .driver_module =3D THIS_MODULE,
 };
 
Quoted 4 lines

drivers/iio/temperature/mlx90614.c module_i2c_driver(mlx90614_driver); · line 653

Quoted 4 lines
drivers/iio/temperature/mlx90614.c +0 -0
@@ -569,5 +651,6 @@ module_i2c_driver(mlx90614_driver);
 
 MODULE_AUTHOR("Peter Meerwald <[email protected]>");
 MODULE_AUTHOR("Vianney le Cl=C3=A9ment de Saint-Marcq <vianney.leclemen=

[email protected]>");

Quoted 2 lines

drivers/iio/temperature/mlx90614.c module_i2c_driver(mlx90614_driver); · line 655

Quoted 2 lines
drivers/iio/temperature/mlx90614.c +1 -0
+MODULE_AUTHOR("Crt Mori <[email protected]>");
 MODULE_DESCRIPTION("Melexis MLX90614 contactless IR temperature sensor =

driver");

Quoted 7 lines

drivers/iio/temperature/mlx90614.c module_i2c_driver(mlx90614_driver); · line 656

Quoted 2 lines
drivers/iio/temperature/mlx90614.c +0 -0
 MODULE_LICENSE("GPL");

--

Peter Meerwald
+43-664-2444418 (mobile)