Skip to content

Commit ef3e9c9

Browse files
QUIC-kamalwbroonie
authored andcommitted
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]>
1 parent 1b237f1 commit ef3e9c9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/regulator/qcom-pm8008-regulator.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ static int pm8008_regulator_get_voltage_sel(struct regulator_dev *rdev)
9696

9797
uV = le16_to_cpu(val) * 1000;
9898

99-
return (uV - preg->desc.min_uV) / preg->desc.uV_step;
99+
return regulator_map_voltage_linear_range(rdev, uV, INT_MAX);
100100
}
101101

102102
static const struct regulator_ops pm8008_regulator_ops = {

0 commit comments

Comments
 (0)