[PATCH 3/5] power: supply: qcom_smbx: fix float voltage selector

From: Robin Snyders via B4 Relay

Date: Tue Aug 11 2026 - 19:30:56 EST


From: Robin Snyders <robin@xxxxxxxxxxx>

FLOAT_VOLTAGE_CFG encodes 3,487,500 uV as selector zero and advances in
7,500 uV steps. The current calculation adds one to that selector, so it
programs the requested float voltage one step too high.

Remove the extra offset and name the hardware encoding constants.

Fixes: 8648aeb5d7b7 ("power: supply: add Qualcomm PMI8998 SMB2 Charger driver")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Robin Snyders <robin@xxxxxxxxxxx>
---
drivers/power/supply/qcom_smbx.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/power/supply/qcom_smbx.c b/drivers/power/supply/qcom_smbx.c
index 0e50d81aefc2a..e236b95c0ebf3 100644
--- a/drivers/power/supply/qcom_smbx.c
+++ b/drivers/power/supply/qcom_smbx.c
@@ -352,6 +352,8 @@

/* pmi8998 registers represent current in increments of 1/40th of an amp */
#define CURRENT_SCALE_FACTOR 25000
+#define SMB2_FLOAT_VOLTAGE_MIN_UV 3487500
+#define SMB2_FLOAT_VOLTAGE_STEP_UV 7500
/* clang-format on */

enum charger_status {
@@ -993,7 +995,8 @@ static int smb_probe(struct platform_device *pdev)
return dev_err_probe(chip->dev, rc,
"Failed to init status change work\n");

- rc = (chip->batt_info->voltage_max_design_uv - 3487500) / 7500 + 1;
+ rc = (chip->batt_info->voltage_max_design_uv -
+ SMB2_FLOAT_VOLTAGE_MIN_UV) / SMB2_FLOAT_VOLTAGE_STEP_UV;
rc = regmap_update_bits(chip->regmap, chip->base + FLOAT_VOLTAGE_CFG,
FLOAT_VOLTAGE_SETTING_MASK, rc);
if (rc < 0)

--
2.54.0