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

Kory Maincent posted 27 patches 2 days, 14 hours ago
[PATCH RFC net-next v3 02/27] regulator: core: Ignore unset max_uA constraints in current limit check
Posted by Kory Maincent 2 days, 14 hours ago
From: Kory Maincent (Dent Project) <kory.maincent@bootlin.com>

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@bootlin.com>
---

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