]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
hwmon: (ina2xx) make regulator 'vs' support optional
authorCiprian Marian Costea <ciprianmarian.costea@oss.nxp.com>
Wed, 9 Apr 2025 07:45:29 +0000 (10:45 +0300)
committerGuenter Roeck <linux@roeck-us.net>
Wed, 23 Apr 2025 14:18:27 +0000 (07:18 -0700)
According to the 'ti,ina2xx' binding, the 'vs-supply' property is
optional. Use devm_regulator_get_enable_optional() to avoid a kernel
warning message if the property is not provided.

Co-developed-by: Florin Buica <florin.buica@nxp.com>
Tested-by: Enric Balletbo i Serra <eballetbo@kernel.org>
Signed-off-by: Florin Buica <florin.buica@nxp.com>
Signed-off-by: Ciprian Marian Costea <ciprianmarian.costea@oss.nxp.com>
Link: https://lore.kernel.org/r/20250409074529.2233733-1-ciprianmarian.costea@oss.nxp.com
[groeck: Use standard multi-line comment]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/ina2xx.c

index 345fe7db9de94a276cab1a7256b1d5a1a216d13e..bc3c1f7314b3e36c6d9d4e96e681b8cd40e2bf37 100644 (file)
@@ -959,8 +959,12 @@ static int ina2xx_probe(struct i2c_client *client)
                return PTR_ERR(data->regmap);
        }
 
-       ret = devm_regulator_get_enable(dev, "vs");
-       if (ret)
+       /*
+        * Regulator core returns -ENODEV if the 'vs' is not available.
+        * Hence the check for -ENODEV return code is necessary.
+        */
+       ret = devm_regulator_get_enable_optional(dev, "vs");
+       if (ret < 0 && ret != -ENODEV)
                return dev_err_probe(dev, ret, "failed to enable vs regulator\n");
 
        ret = ina2xx_init(dev, data);