Skip to contentSkip to conversation

iio: temperature: mlx90614: Fix dual channel probe condition check

PATCH In review Salah Triki 3 participants 5 messages Sep 17 – Oct 19

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iio: temperature: mlx90614: Fix dual channel probe condition check

In mlx90614_probe_num_ir_sensors(), the check on chip_info->dual_channel is inverted.

Currently, if dual_channel is true (MLX90614), the function returns 0 immediately without checking op_eeprom_config1. This forces all MLX90614 devices to be registered as single sensor (num_channels = 2), making the second object temperature channel inaccessible.

Conversely, if dual_channel is false (MLX90615), the function skips the early return and performs an unnecessary SMBus read on EEPROM CONFIG1 even though MLX90615 does not support dual channel operation.

Fix this by negating the condition so that single-channel chips return early with 0, while dual-channel capable chips (MLX90614) proceed to read the EEPROM configuration register to detect whether 1 or 2 object channels are present.

Fixes 3d5ead238bc8 ("iio: mlx90614: Factor our register IO and constants into model specific descriptor")
Assisted-by LLM
---
 drivers/iio/temperature/mlx90614.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/temperature/mlx90614.c +1 -1
index 27d6ab5f5d7a..4f79da1f905e 100644
@@ -565,7 +565,7 @@ static int mlx90614_probe_num_ir_sensors(struct i2c_client *client)
 	const struct mlx_chip_info *chip_info = data->chip_info;
 	s32 ret;
 
-	if (chip_info->dual_channel)
+	if (!chip_info->dual_channel)
 		return 0;
 
 	ret = i2c_smbus_read_word_data(client, chip_info->op_eeprom_config1);
Signature · 1 line
2.43.0
maintainer
#1 lore raw

So this fix is for the MLX90615, which is registered as single channel operation? Did you test on 90614 as well?

Best regards,
Crt

Crt Mori

Melexis Technologies NV
Transportstraat 1
3980 Tessenderlo

Mobile: +32 492 46 22 15
E-mail: [email protected]
Website: www.melexis.com

----------------------------------------------------------
The contents of this e-mail are CONFIDENTIAL AND PROPRIETARY. Please read our disclaimer at http://www.melexis.com/mailpolicy

Quoted 41 lines · Salah Triki

In mlx90614_probe_num_ir_sensors(), the check on chip_info->dual_channel is inverted.

Currently, if dual_channel is true (MLX90614), the function returns 0 immediately without checking op_eeprom_config1. This forces all MLX90614 devices to be registered as single sensor (num_channels = 2), making the second object temperature channel inaccessible.

Conversely, if dual_channel is false (MLX90615), the function skips the early return and performs an unnecessary SMBus read on EEPROM CONFIG1 even though MLX90615 does not support dual channel operation.

Fix this by negating the condition so that single-channel chips return early with 0, while dual-channel capable chips (MLX90614) proceed to read the EEPROM configuration register to detect whether 1 or 2 object channels are present.

Fixes 3d5ead238bc8 ("iio: mlx90614: Factor our register IO and constants into model specific descriptor")
Assisted-by LLM
---
 drivers/iio/temperature/mlx90614.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/temperature/mlx90614.c +1 -2
index 27d6ab5f5d7a..4f79da1f905e 100644
@@ -565,7 +565,7 @@ static int mlx90614_probe_num_ir_sensors(struct i2c_client *client)
        const struct mlx_chip_info *chip_info = data->chip_info;
        s32 ret;
 
-       if (chip_info->dual_channel)
+       if (!chip_info->dual_channel)
                return 0;
 
        ret = i2c_smbus_read_word_data(client, chip_info->op_eeprom_config1);
--

2.43.0

#2 lore raw

Hi Crt,

Thanks for your feedback.

Actually, the patch primarily fixes the behavior for the MLX90614.

In the current codebase, MLX90614 has chip_info->dual_channel = true. Because mlx90614_probe_num_ir_sensors() checks
if (chip_info->dual_channel), it returns 0 immediately for MLX90614 without reading the EEPROM CONFIG1 register. As a result, dual-channel MLX90614 sensors are incorrectly registered as single-channel devices.

For MLX90615 (dual_channel = false), the condition was bypassed, causing an unnecessary SMBus read to EEPROM CONFIG1, even though MLX90615 only supports a single object channel.

By changing the check to if (!chip_info->dual_channel), we fix both issues:
1. MLX90614 correctly reads EEPROM CONFIG1 to detect whether it operates in single or dual channel mode.
2. MLX90615 skips the EEPROM read entirely.

I don't have physical hardware to test this on; this bug was spotted via code inspection.

Best regards,
Salah

Quoted 63 lines · Crt Mori

So this fix is for the MLX90615, which is registered as single channel operation? Did you test on 90614 as well?

Best regards,
Crt

Crt Mori

Melexis Technologies NV
Transportstraat 1
3980 Tessenderlo

Mobile: +32 492 46 22 15
E-mail: [email protected]
Website: www.melexis.com

----------------------------------------------------------
The contents of this e-mail are CONFIDENTIAL AND PROPRIETARY. Please read our disclaimer at http://www.melexis.com/mailpolicy

Quoted 41 lines · Salah Triki

In mlx90614_probe_num_ir_sensors(), the check on chip_info->dual_channel is inverted.

Currently, if dual_channel is true (MLX90614), the function returns 0 immediately without checking op_eeprom_config1. This forces all MLX90614 devices to be registered as single sensor (num_channels = 2), making the second object temperature channel inaccessible.

Conversely, if dual_channel is false (MLX90615), the function skips the early return and performs an unnecessary SMBus read on EEPROM CONFIG1 even though MLX90615 does not support dual channel operation.

Fix this by negating the condition so that single-channel chips return early with 0, while dual-channel capable chips (MLX90614) proceed to read the EEPROM configuration register to detect whether 1 or 2 object channels are present.

Fixes 3d5ead238bc8 ("iio: mlx90614: Factor our register IO and constants into model specific descriptor")
Assisted-by LLM
---
 drivers/iio/temperature/mlx90614.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/temperature/mlx90614.c +1 -2
index 27d6ab5f5d7a..4f79da1f905e 100644
@@ -565,7 +565,7 @@ static int mlx90614_probe_num_ir_sensors(struct i2c_client *client)
        const struct mlx_chip_info *chip_info = data->chip_info;
        s32 ret;
 
-       if (chip_info->dual_channel)
+       if (!chip_info->dual_channel)
                return 0;
 
        ret = i2c_smbus_read_word_data(client, chip_info->op_eeprom_config1);
--

2.43.0

maintainer
#3 lore raw
Quoted 16 lines · On Thu, 17 Sep 2026 14:16:15 +0100 Salah Triki <[email protected]> wrote:

Hi Crt,

Thanks for your feedback.

Actually, the patch primarily fixes the behavior for the MLX90614.

In the current codebase, MLX90614 has chip_info->dual_channel = true. Because mlx90614_probe_num_ir_sensors() checks
if (chip_info->dual_channel), it returns 0 immediately for MLX90614 without reading the EEPROM CONFIG1 register. As a result, dual-channel MLX90614 sensors are incorrectly registered as single-channel devices.

For MLX90615 (dual_channel = false), the condition was bypassed, causing an unnecessary SMBus read to EEPROM CONFIG1, even though MLX90615 only supports a single object channel.

Quoted 8 lines

By changing the check to if (!chip_info->dual_channel), we fix both issues:
1. MLX90614 correctly reads EEPROM CONFIG1 to detect whether it operates in single or dual channel mode.
2. MLX90615 skips the EEPROM read entirely.

I don't have physical hardware to test this on; this bug was spotted via code inspection.

Explanation makes sense to me and as Crt hasn't come back with a reply, I'll assuming Crt has no objections (shout if not!)

Applied and marked stable

Thanks,

Jonathan

Quoted 68 lines

Best regards,
Salah

Quoted 63 lines · Crt Mori

So this fix is for the MLX90615, which is registered as single channel operation? Did you test on 90614 as well?

Best regards,
Crt

Crt Mori

Melexis Technologies NV
Transportstraat 1
3980 Tessenderlo

Mobile: +32 492 46 22 15
E-mail: [email protected]
Website: www.melexis.com

----------------------------------------------------------
The contents of this e-mail are CONFIDENTIAL AND PROPRIETARY. Please read our disclaimer at http://www.melexis.com/mailpolicy

Quoted 41 lines · Salah Triki

In mlx90614_probe_num_ir_sensors(), the check on chip_info->dual_channel is inverted.

Currently, if dual_channel is true (MLX90614), the function returns 0 immediately without checking op_eeprom_config1. This forces all MLX90614 devices to be registered as single sensor (num_channels = 2), making the second object temperature channel inaccessible.

Conversely, if dual_channel is false (MLX90615), the function skips the early return and performs an unnecessary SMBus read on EEPROM CONFIG1 even though MLX90615 does not support dual channel operation.

Fix this by negating the condition so that single-channel chips return early with 0, while dual-channel capable chips (MLX90614) proceed to read the EEPROM configuration register to detect whether 1 or 2 object channels are present.

Fixes 3d5ead238bc8 ("iio: mlx90614: Factor our register IO and constants into model specific descriptor")
Assisted-by LLM
---
 drivers/iio/temperature/mlx90614.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/temperature/mlx90614.c +1 -2
index 27d6ab5f5d7a..4f79da1f905e 100644
@@ -565,7 +565,7 @@ static int mlx90614_probe_num_ir_sensors(struct i2c_client *client)
        const struct mlx_chip_info *chip_info = data->chip_info;
        s32 ret;
 
-       if (chip_info->dual_channel)
+       if (!chip_info->dual_channel)
                return 0;
 
        ret = i2c_smbus_read_word_data(client, chip_info->op_eeprom_config1);
--

2.43.0

maintainer
#4 lore raw

Hi,
No objections, but I wanted to test it and can't find the time for this sorry. I don't think I have seen a single channel MLX90614 when I wrote a driver, so maybe that is something that came with 90615 patches or later.

Best regards,
Crt

Quoted 107 lines · Jonathan Cameron
Quoted 16 lines · On Thu, 17 Sep 2026 14:16:15 +0100 Salah Triki <[email protected]> wrote:

Hi Crt,

Thanks for your feedback.

Actually, the patch primarily fixes the behavior for the MLX90614.

In the current codebase, MLX90614 has chip_info->dual_channel = true. Because mlx90614_probe_num_ir_sensors() checks
if (chip_info->dual_channel), it returns 0 immediately for MLX90614 without reading the EEPROM CONFIG1 register. As a result, dual-channel MLX90614 sensors are incorrectly registered as single-channel devices.

For MLX90615 (dual_channel = false), the condition was bypassed, causing an unnecessary SMBus read to EEPROM CONFIG1, even though MLX90615 only supports a single object channel.

Quoted 8 lines

By changing the check to if (!chip_info->dual_channel), we fix both issues:
1. MLX90614 correctly reads EEPROM CONFIG1 to detect whether it operates in single or dual channel mode.
2. MLX90615 skips the EEPROM read entirely.

I don't have physical hardware to test this on; this bug was spotted via code inspection.

Explanation makes sense to me and as Crt hasn't come back with a reply, I'll assuming Crt has no objections (shout if not!)

Applied and marked stable

Thanks,

Jonathan

Quoted 68 lines

Best regards,
Salah

Quoted 63 lines · Crt Mori

So this fix is for the MLX90615, which is registered as single channel operation? Did you test on 90614 as well?

Best regards,
Crt

Crt Mori

Melexis Technologies NV
Transportstraat 1
3980 Tessenderlo

Mobile: +32 492 46 22 15
E-mail: [email protected]
Website: www.melexis.com

----------------------------------------------------------
The contents of this e-mail are CONFIDENTIAL AND PROPRIETARY. Please read our disclaimer at http://www.melexis.com/mailpolicy

Quoted 41 lines · Salah Triki

In mlx90614_probe_num_ir_sensors(), the check on chip_info->dual_channel is inverted.

Currently, if dual_channel is true (MLX90614), the function returns 0 immediately without checking op_eeprom_config1. This forces all MLX90614 devices to be registered as single sensor (num_channels = 2), making the second object temperature channel inaccessible.

Conversely, if dual_channel is false (MLX90615), the function skips the early return and performs an unnecessary SMBus read on EEPROM CONFIG1 even though MLX90615 does not support dual channel operation.

Fix this by negating the condition so that single-channel chips return early with 0, while dual-channel capable chips (MLX90614) proceed to read the EEPROM configuration register to detect whether 1 or 2 object channels are present.

Fixes 3d5ead238bc8 ("iio: mlx90614: Factor our register IO and constants into model specific descriptor")
Assisted-by LLM
---
 drivers/iio/temperature/mlx90614.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/temperature/mlx90614.c +1 -2
index 27d6ab5f5d7a..4f79da1f905e 100644
@@ -565,7 +565,7 @@ static int mlx90614_probe_num_ir_sensors(struct i2c_client *client)
        const struct mlx_chip_info *chip_info = data->chip_info;
        s32 ret;
 
-       if (chip_info->dual_channel)
+       if (!chip_info->dual_channel)
                return 0;
 
        ret = i2c_smbus_read_word_data(client, chip_info->op_eeprom_config1);
--

2.43.0