Input: drv260x - fix unbalanced regulator_disable() call

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>
This commit is contained in:
Yauhen Kharuzhy
2026-02-17 10:12:27 -08:00
committed by Dmitry Torokhov
parent 710a1a8c59
commit e7b53288d9

View 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))