linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] regulator: pm8008: fix probe failure due to negative voltage selector
@ 2025-08-22 20:26 Kamal Wadhwa
  2025-08-25 20:21 ` Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Kamal Wadhwa @ 2025-08-22 20:26 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown
  Cc: linux-arm-msm, linux-kernel, johan+linaro, quic_skakitap,
	Kamal Wadhwa

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>
---
 drivers/regulator/qcom-pm8008-regulator.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/regulator/qcom-pm8008-regulator.c b/drivers/regulator/qcom-pm8008-regulator.c
index da017c1969d0cc2c6347b68c37518ea8a7ab44a3..90c78ee1c37bf9bf69f43e0bb7798fed94590e95 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 = {

---
base-commit: b9ddaa95fd283bce7041550ddbbe7e764c477110
change-id: 20250823-pm8008-negitive-selector-71646975befe

Best regards,
-- 
Kamal Wadhwa <quic_kamalw@quicinc.com>


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] regulator: pm8008: fix probe failure due to negative voltage selector
  2025-08-22 20:26 [PATCH] regulator: pm8008: fix probe failure due to negative voltage selector Kamal Wadhwa
@ 2025-08-25 20:21 ` Mark Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2025-08-25 20:21 UTC (permalink / raw)
  To: Liam Girdwood, Kamal Wadhwa
  Cc: linux-arm-msm, linux-kernel, johan+linaro, quic_skakitap

On Sat, 23 Aug 2025 01:56:39 +0530, Kamal Wadhwa wrote:
> 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.
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-next

Thanks!

[1/1] regulator: pm8008: fix probe failure due to negative voltage selector
      commit: ef3e9c91ed87f13dba877a20569f4a0accf0612c

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-08-25 20:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-22 20:26 [PATCH] regulator: pm8008: fix probe failure due to negative voltage selector Kamal Wadhwa
2025-08-25 20:21 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).