aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKamal Wadhwa <[email protected]>2025-08-22 20:26:39 +0000
committerMark Brown <[email protected]>2025-08-24 21:41:04 +0000
commitef3e9c91ed87f13dba877a20569f4a0accf0612c (patch)
treefaa181785e586c023a1ab4f00f7d9262628747fa
parentLinux 6.17-rc3 (diff)
downloadkernel-ef3e9c91ed87f13dba877a20569f4a0accf0612c.tar.gz
kernel-ef3e9c91ed87f13dba877a20569f4a0accf0612c.zip
regulator: pm8008: fix probe failure due to negative voltage selector
In the current design, the `pm8008_regulator_get_voltage_sel()` callback can return a negative value if the raw voltage value is read as 0 uV from the PMIC HW register. This can cause the probe to fail when the `machine_constraints_voltage()` check is called during the regulator registration flow. Fix this by using the helper `regulator_map_voltage_linear_range()` to convert the raw value to a voltage selector inside the mentioned get voltage selector function. This ensures that the value returned is always within the defined range. Signed-off-by: Kamal Wadhwa <[email protected]> Message-ID: <[email protected]> Signed-off-by: Mark Brown <[email protected]>
-rw-r--r--drivers/regulator/qcom-pm8008-regulator.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/regulator/qcom-pm8008-regulator.c b/drivers/regulator/qcom-pm8008-regulator.c
index da017c1969d0..90c78ee1c37b 100644
--- a/drivers/regulator/qcom-pm8008-regulator.c
+++ b/drivers/regulator/qcom-pm8008-regulator.c
@@ -96,7 +96,7 @@ static int pm8008_regulator_get_voltage_sel(struct regulator_dev *rdev)
uV = le16_to_cpu(val) * 1000;
- return (uV - preg->desc.min_uV) / preg->desc.uV_step;
+ return regulator_map_voltage_linear_range(rdev, uV, INT_MAX);
}
static const struct regulator_ops pm8008_regulator_ops = {