Re: [PATCH v2 4/5] iio: mcp9600: Add support for dtbinding of thermocouple-type
From: David Lechner
Date: Wed Aug 13 2025 - 17:19:23 EST
On 8/13/25 10:15 AM, Ben Collins wrote:
> Adds dtbinding check for thermocouple-type and sets sensor config
> to match. Add iio info attribute to show state as well.
>
> Signed-off-by: Ben Collins <bcollins@xxxxxxxxxx>
> ---
...
> @@ -447,6 +492,20 @@ static int mcp9600_probe(struct i2c_client *client)
> data = iio_priv(indio_dev);
> data->client = client;
>
> + /* Accept type from dt with default of Type-K. */
> + data->thermocouple_type = THERMOCOUPLE_TYPE_K;
> + ret = device_property_read_u32(&client->dev, "thermocouple-type",
> + &data->thermocouple_type);
ret is not checked. We should either check it or drop it and add
a comment explaining why it is OK to ignore the return value.
Typically, for optional properties, we would ignore only -EINVAL
meaning the property is not present and fail on other errors.
We also need another dt-bindings patch to add the default in the
bindings.
> + if (data->thermocouple_type >= ARRAY_SIZE(mcp9600_type_map))
> + return dev_err_probe(&client->dev, -EINVAL,
> + "Invalid thermocouple-type property %d.\n",
> + data->thermocouple_type);
> +
> + /* Set initial config. */
> + ret = mcp9600_config(data);
> + if (ret < 0)
> + return ret;
> +
> ch_sel = mcp9600_probe_alerts(indio_dev);
> if (ch_sel < 0)
> return ch_sel;