+/*
+ * 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)
+{
+ int i;
+ s32 ret;
+
+ for (i = 0; i < ARRAY_SIZE(mlx90614_iir_values); ++i) {
+ if (value == mlx90614_iir_values[i])
+ break;
+ }
+
+ if (i == ARRAY_SIZE(mlx90614_iir_values))
+ 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);
+ if (ret > 0)
+ return ret;
+
+ /* 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)));
+ return ret;
+}
+