Re: [PATCH v2 4/7] iio: temperature: ltc2983: Use fwnode_property_present() for optional properties
From: Jonathan Cameron
Date: Sat May 16 2026 - 12:53:37 EST
On Thu, 14 May 2026 17:46:51 +0300
Liviu Stan <liviu.stan@xxxxxxxxxx> wrote:
> Checking fwnode_property_read_u32() return value with if (!ret)
> silently swallows meaningful error codes when a property is present
> but malformed. Use fwnode_property_present() first so that absence
> uses the default while a present but unreadable property returns
> a proper error.
>
Fixes: f110f3188e5639c81c457b2b831d40dfe3891bdb ("iio: temperature: Add support for LTC2983")
Same again. Not a fix. It's hardening against unexpected errors.
Also, sashiko calls out an issue with n_wires and default value of 0.
The binding says default is 2.
that was always present but is worth a fix potentially:
https://sashiko.dev/#/patchset/20260514144712.64374-1-liviu.stan%40analog.com
> Signed-off-by: Liviu Stan <liviu.stan@xxxxxxxxxx>
> ---
> Changes in v2:
> - New patch.
>
> drivers/iio/temperature/ltc2983.c | 18 ++++++++++++++----
> 1 file changed, 14 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/iio/temperature/ltc2983.c b/drivers/iio/temperature/ltc2983.c
> index f42777c1f3c2..bf435e965c6d 100644
> --- a/drivers/iio/temperature/ltc2983.c
> +++ b/drivers/iio/temperature/ltc2983.c
> @@ -669,8 +669,14 @@ ltc2983_thermocouple_new(const struct fwnode_handle *child, struct ltc2983_data
> if (fwnode_property_read_bool(child, "adi,single-ended"))
> thermo->sensor_config = LTC2983_THERMOCOUPLE_SGL(1);
>
> - ret = fwnode_property_read_u32(child, "adi,sensor-oc-current-microamp", &oc_current);
> - if (!ret) {
> + if (fwnode_property_present(child, "adi,sensor-oc-current-microamp")) {
> + ret = fwnode_property_read_u32(child,
> + "adi,sensor-oc-current-microamp",
> + &oc_current);
> + if (ret)
> + return dev_err_ptr_probe(dev, ret,
> + "Failed to read adi,sensor-oc-current-microamp\n");
> +
> switch (oc_current) {
> case 10:
> thermo->sensor_config |=
> @@ -760,8 +766,12 @@ ltc2983_rtd_new(const struct fwnode_handle *child, struct ltc2983_data *st,
> return dev_err_ptr_probe(dev, ret,
> "Property reg must be given\n");
>
> - ret = fwnode_property_read_u32(child, "adi,number-of-wires", &n_wires);
> - if (!ret) {
> + if (fwnode_property_present(child, "adi,number-of-wires")) {
> + ret = fwnode_property_read_u32(child, "adi,number-of-wires", &n_wires);
> + if (ret)
> + return dev_err_ptr_probe(dev, ret,
> + "Failed to read adi,number-of-wires\n");
> +
> switch (n_wires) {
> case 2:
> rtd->sensor_config = LTC2983_RTD_N_WIRES(0);