w1: ds2482: Add regulator support
authorKryštof Černý <cleverline1mc@gmail.com>
Fri, 29 Nov 2024 13:25:55 +0000 (14:25 +0100)
committerKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Tue, 3 Dec 2024 14:53:29 +0000 (15:53 +0100)
Adds a support for attaching a supply regulator.

Signed-off-by: Kryštof Černý <cleverline1mc@gmail.com>
Link: https://lore.kernel.org/r/20241129-ds2482-add-reg-v6-3-bd95ad171e19@gmail.com
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
drivers/w1/masters/ds2482.c

index ea09d2ee21ccac27783a19547e988694ca171b91..f8095264d82f0e0135492ed65e71df74c71bcd65 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/slab.h>
 #include <linux/i2c.h>
 #include <linux/delay.h>
+#include <linux/regulator/consumer.h>
 
 #include <linux/w1.h>
 
@@ -445,6 +446,7 @@ static int ds2482_probe(struct i2c_client *client)
        int err = -ENODEV;
        int temp1;
        int idx;
+       int ret;
 
        if (!i2c_check_functionality(client->adapter,
                                     I2C_FUNC_SMBUS_WRITE_BYTE_DATA |
@@ -455,6 +457,10 @@ static int ds2482_probe(struct i2c_client *client)
        if (!data)
                return -ENOMEM;
 
+       ret = devm_regulator_get_enable(&client->dev, "vcc");
+       if (ret)
+               return dev_err_probe(&client->dev, ret, "Failed to enable regulator\n");
+
        data->client = client;
        i2c_set_clientdata(client, data);