[PATCH 5/8] regulator: core: remove dead code in regulator_resolve_supply()

André Draszik posted 8 patches 1 month, 1 week ago
There is a newer version of this series
[PATCH 5/8] regulator: core: remove dead code in regulator_resolve_supply()
Posted by André Draszik 1 month, 1 week ago
Since commit 98e48cd9283d ("regulator: core: resolve supply for
boot-on/always-on regulators") we require that a regulator's supply has
been resolved before enabling the regulator. Furthermore,
regulator_get() also fails if the supply hasn't been resolved yet
(preventing consumers from enabling a regulator without its supply
known). In combination this means that regulator_resolve_supply() now
always runs before the regulator has been enabled via
set_machine_constraints().

The code here was meant to run after enabling the regulator in case the
supply hadn't been resolved at that time and can therefore never
execute anymore since that commit.

Remove it.

No functional change intended.

Fixes: 98e48cd9283d ("regulator: core: resolve supply for boot-on/always-on regulators")
Signed-off-by: André Draszik <andre.draszik@linaro.org>
---
 drivers/regulator/core.c | 22 ----------------------
 1 file changed, 22 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 08bdb1e4175e6d47d154e7a2d859a9d39dcfd021..fd8da369c0529da12d6e80d90032e07bed414316 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -2282,28 +2282,6 @@ static int regulator_resolve_supply(struct regulator_dev *rdev)
 	/* rdev->supply was created in set_supply() */
 	link_and_create_debugfs(rdev->supply, r, &rdev->dev);
 
-	/*
-	 * In set_machine_constraints() we may have turned this regulator on
-	 * but we couldn't propagate to the supply if it hadn't been resolved
-	 * yet.  Do it now.
-	 */
-	if (rdev->use_count) {
-		ret = regulator_enable(rdev->supply);
-		if (ret < 0) {
-			struct regulator *supply;
-
-			regulator_lock_two(rdev, rdev->supply->rdev, &ww_ctx);
-
-			supply = rdev->supply;
-			rdev->supply = NULL;
-
-			regulator_unlock_two(rdev, supply->rdev, &ww_ctx);
-
-			regulator_put(supply);
-			goto out;
-		}
-	}
-
 out:
 	return ret;
 }

-- 
2.52.0.351.gbe84eed79e-goog

Re: [PATCH 5/8] regulator: core: remove dead code in regulator_resolve_supply()
Posted by Mark Brown 1 month, 1 week ago
On Sat, Dec 27, 2025 at 12:17:49PM +0000, André Draszik wrote:

> No functional change intended.

> Fixes: 98e48cd9283d ("regulator: core: resolve supply for boot-on/always-on regulators")

If this is just a cleanup then clearly it's not fixing a bug.  Please
don't throw Fixes tags on random commits that don't actually fix bugs,
it just makes noise for people who are looking for actual fixes.
Re: [PATCH 5/8] regulator: core: remove dead code in regulator_resolve_supply()
Posted by André Draszik 1 month, 1 week ago
Hi Mark,

On Sat, 2025-12-27 at 20:01 +0000, Mark Brown wrote:
> On Sat, Dec 27, 2025 at 12:17:49PM +0000, André Draszik wrote:
> 
> > No functional change intended.
> 
> > Fixes: 98e48cd9283d ("regulator: core: resolve supply for boot-on/always-on regulators")
> 
> If this is just a cleanup then clearly it's not fixing a bug.  Please
> don't throw Fixes tags on random commits that don't actually fix bugs,
> it just makes noise for people who are looking for actual fixes.

I added it to highlight that the dead code removal should have been
part of that commit, but left out CC:stable for the reason that this
commit is not strictly required. Especially the now incorrect comment
in the code was a bit confusing since that commit, and I wanted to make
it easier for future reader of that code, no matter which kernel version
somebody else might be looking at.

Anyway, will drop in next version.

Cheers,
Andre'