]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
hwmon: (tmp102) add vcc regulator support
authorPeter Korsgaard <peter@korsgaard.com>
Thu, 17 Apr 2025 18:04:26 +0000 (20:04 +0200)
committerGuenter Roeck <linux@roeck-us.net>
Wed, 23 Apr 2025 14:18:33 +0000 (07:18 -0700)
Make it optional for backwards compatibility.

Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
Link: https://lore.kernel.org/r/20250417180426.3872314-2-peter@korsgaard.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/tmp102.c

index 8af44a33055f3273736af4d4b20ed026e0d2388b..a02daa496c9c44cd83977902786dbc21c0fd0514 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/device.h>
 #include <linux/jiffies.h>
 #include <linux/regmap.h>
+#include <linux/regulator/consumer.h>
 #include <linux/of.h>
 
 #define        DRIVER_NAME "tmp102"
@@ -204,6 +205,10 @@ static int tmp102_probe(struct i2c_client *client)
                return -ENODEV;
        }
 
+       err = devm_regulator_get_enable_optional(dev, "vcc");
+       if (err < 0 && err != -ENODEV)
+               return dev_err_probe(dev, err, "Failed to enable regulator\n");
+
        tmp102 = devm_kzalloc(dev, sizeof(*tmp102), GFP_KERNEL);
        if (!tmp102)
                return -ENOMEM;