[PATCH RFC net-next v3 02/27] regulator: core: Ignore unset max_uA constraints in current limit check

From: Kory Maincent
Date: Thu Nov 21 2024 - 09:45:25 EST


From: Kory Maincent (Dent Project) <kory.maincent@xxxxxxxxxxx>

We should only consider max_uA constraints if they are explicitly defined.
In cases where it is not set, we should assume the regulator has no current
limit.

Signed-off-by: Kory Maincent <kory.maincent@xxxxxxxxxxx>
---

Change in v3:
- New patch
---
drivers/regulator/core.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 1179766811f5..2948a7eca734 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -497,7 +497,8 @@ static int regulator_check_current_limit(struct regulator_dev *rdev,
return -EPERM;
}

- if (*max_uA > rdev->constraints->max_uA)
+ if (*max_uA > rdev->constraints->max_uA &&
+ rdev->constraints->max_uA)
*max_uA = rdev->constraints->max_uA;
if (*min_uA < rdev->constraints->min_uA)
*min_uA = rdev->constraints->min_uA;

--
2.34.1