]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
hwmon: (ltc4282) Add default rsense value
authorNuno Sá <nuno.sa@analog.com>
Wed, 4 Mar 2026 10:17:48 +0000 (10:17 +0000)
committerGuenter Roeck <linux@roeck-us.net>
Tue, 31 Mar 2026 02:45:05 +0000 (19:45 -0700)
Instead of failing probe when the "adi,rsense-nano-ohms" firmware property
is not provided, default rsense to (NANO/MILLI), or 1 milli-Ohm. This
allows the device to probe without requiring firmware properties, which
might be useful for some high level testing.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20260304-hwmon-ltc4282-minor-improvs-v1-2-344622924d3a@analog.com
[groeck: Clarify that the default is 1 milli-Ohm. No functional change.]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/ltc4282.c

index db6534e6799113565da39a574ae5e949b528e7b7..b9084424160d665e5d2923e46d0d1ab2772ac870 100644 (file)
@@ -1328,15 +1328,16 @@ static int ltc4282_setup(struct ltc4282_state *st, struct device *dev)
        if (ret)
                return ret;
 
+       /* default to 1 milli-ohm so we can probe without FW properties */
+       st->rsense = 1 * (NANO / MILLI);
        ret = device_property_read_u32(dev, "adi,rsense-nano-ohms",
                                       &st->rsense);
-       if (ret)
-               return dev_err_probe(dev, ret,
-                                    "Failed to read adi,rsense-nano-ohms\n");
-       if (st->rsense < CENTI)
-               return dev_err_probe(dev, -EINVAL,
-                                    "adi,rsense-nano-ohms too small (< %lu)\n",
-                                    CENTI);
+       if (!ret) {
+               if (st->rsense < CENTI)
+                       return dev_err_probe(dev, -EINVAL,
+                                            "adi,rsense-nano-ohms too small (< %lu)\n",
+                                            CENTI);
+       }
 
        /*
         * The resolution for rsense is tenths of micro (eg: 62.5 uOhm) which