]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
Input: drv260x - fix unbalanced regulator_disable() call
authorYauhen Kharuzhy <jekhor@gmail.com>
Tue, 17 Feb 2026 18:12:27 +0000 (10:12 -0800)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Wed, 18 Feb 2026 07:05:17 +0000 (23:05 -0800)
The driver acquires the 'vbat' regulator during probing but never enables
it. Consequently, in the suspend method, the driver disables the regulator
without enabling it first, causing an 'Unbalanced regulator_disable()'
error.

Enable the regulator in the probe() method and add the remove() method with
regulator disabling to fix this.

Signed-off-by: Yauhen Kharuzhy <jekhor@gmail.com>
Link: https://patch.msgid.link/20260215141435.727872-5-jekhor@gmail.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
drivers/input/misc/drv260x.c

index b3076aa682c4db636b4eab14b67ba9b5a2bb7848..e2089d6ac8500419e33c80458466ba23d99808d7 100644 (file)
@@ -9,6 +9,7 @@
 
 #include <linux/acpi.h>
 #include <linux/delay.h>
+#include <linux/device/devres.h>
 #include <linux/gpio/consumer.h>
 #include <linux/i2c.h>
 #include <linux/input.h>
@@ -433,6 +434,13 @@ static const struct regmap_config drv260x_regmap_config = {
        .cache_type = REGCACHE_NONE,
 };
 
+static void drv260x_power_off(void *data)
+{
+       struct drv260x_data *haptics = data;
+
+       regulator_disable(haptics->regulator);
+}
+
 static int drv260x_probe(struct i2c_client *client)
 {
        struct device *dev = &client->dev;
@@ -498,6 +506,16 @@ static int drv260x_probe(struct i2c_client *client)
                return error;
        }
 
+       error = regulator_enable(haptics->regulator);
+       if (error) {
+               dev_err(dev, "Failed to enable regulator: %d\n", error);
+               return error;
+       }
+
+       error = devm_add_action_or_reset(dev, drv260x_power_off, haptics);
+       if (error)
+               return error;
+
        haptics->enable_gpio = devm_gpiod_get_optional(dev, "enable",
                                                       GPIOD_OUT_HIGH);
        if (IS_ERR(haptics->enable_gpio))