Re: [PATCH v1 1/1] hwmon: (isl28022) Don't check for specific errors when parsing properties
From: Geert Uytterhoeven
Date: Thu Feb 19 2026 - 09:22:31 EST
Hi Andy,
CC devicetree
On Thu, 19 Feb 2026 at 15:06, Andy Shevchenko
<andriy.shevchenko@xxxxxxxxxxxxxxx> wrote:
> Instead of checking for the specific error codes (that can be considered
> a layering violation to some extent) check for the property existence first
> and then either parse it, or apply a default value.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
Thanks for your patch!
> --- a/drivers/hwmon/isl28022.c
> +++ b/drivers/hwmon/isl28022.c
> @@ -337,21 +337,28 @@ DEFINE_SHOW_ATTRIBUTE(shunt_voltage);
> */
> static int isl28022_read_properties(struct device *dev, struct isl28022_data *data)
> {
> + const char *propname;
> u32 val;
> int err;
>
> - err = device_property_read_u32(dev, "shunt-resistor-micro-ohms", &val);
> - if (err == -EINVAL)
> + propname = "shunt-resistor-micro-ohms";
> + if (device_property_present(dev, propname)) {
> + err = device_property_read_u32(dev, propname, &val);
> + if (err)
> + return err;
> + } else {
> val = 10000;
> - else if (err < 0)
> - return err;
> + }
> data->shunt = val;
IIRC, we have removed superfluous presence checks all over the tree
during the past few years? E.g. of_property_read_*() is documented to
return -EINVAL if a property does not exist.
So this patch looks like a step back to me...
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds