Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <kamal.wadhwa@oss.qualcomm.com>
Message-ID: <20250823-pm8008-negitive-selector-v1-1-52b026a4b5e8@quicinc.com>
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Kamal Wadhwa and committed by
Mark Brown
ef3e9c91 1b237f19

+1 -1
+1 -1
drivers/regulator/qcom-pm8008-regulator.c
··· 96 96 97 97 uV = le16_to_cpu(val) * 1000; 98 98 99 - return (uV - preg->desc.min_uV) / preg->desc.uV_step; 99 + return regulator_map_voltage_linear_range(rdev, uV, INT_MAX); 100 100 } 101 101 102 102 static const struct regulator_ops pm8008_regulator_ops = {