Re: [PATCH v3 4/8] iio: temperature: ltc2983: Use fwnode_property_present() for optional properties

From: Andy Shevchenko

Date: Tue Jun 02 2026 - 19:26:07 EST


On Thu, May 21, 2026 at 07:42:57PM +0300, Liviu Stan 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.

...

const char *propname;

propname = ...;

> + if (fwnode_property_present(child, "adi,sensor-oc-current-microamp")) {
> + ret = fwnode_property_read_u32(child,
> + "adi,sensor-oc-current-microamp",
> + &oc_current);

if (fwnode_property_present(child, propname)) {
ret = fwnode_property_read_u32(child, propname, &oc_current);

> + if (ret)
> + return dev_err_ptr_probe(dev, ret,
> + "Failed to read adi,sensor-oc-current-microamp\n");

return dev_err_ptr_probe(dev, ret,
"Failed to read %s\n", propname);

In the same way below may be amended.

--
With Best Regards,
Andy Shevchenko