[PATCH 07/18] regulator: devres: Disable exclusive regulator before releasing

Tommaso Merciai tommaso.merciai.xr at bp.renesas.com
Wed Oct 1 14:26:51 PDT 2025


Ensure that exclusive regulators are properly disabled when their reference
count drops to one before they are released. This prevents possible issues
where exclusive regulators may remain enabled unintentionally after being
put.

Signed-off-by: Tommaso Merciai <tommaso.merciai.xr at bp.renesas.com>
---
 drivers/regulator/devres.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/regulator/devres.c b/drivers/regulator/devres.c
index 2cf03042fddf..48da9823ce2f 100644
--- a/drivers/regulator/devres.c
+++ b/drivers/regulator/devres.c
@@ -16,7 +16,13 @@
 
 static void devm_regulator_release(struct device *dev, void *res)
 {
-	regulator_put(*(struct regulator **)res);
+	struct regulator *regulator = *(struct regulator **)res;
+	struct regulator_dev *rdev = regulator->rdev;
+
+	if (rdev->exclusive && regulator->enable_count == 1)
+		regulator_disable(regulator);
+
+	regulator_put(regulator);
 }
 
 static struct regulator *_devm_regulator_get(struct device *dev, const char *id,
-- 
2.43.0




More information about the linux-phy mailing list