[lvc-project] [PATCH] regulator: palmas: Check return value of palmas_smps_write()

Aleksandrova Alyona aga at itb.spb.ru
Fri Jun 5 13:26:40 MSK 2026


palmas_set_mode_smps() updates the SMPS mode register when the rail is
enabled, but it ignores a possible error from palmas_smps_write().

Since enable_val is updated after the write, ignoring the error may leave
the cached enable value inconsistent with the hardware state.

Return the error if the register write fails to avoid reporting success
when the mode has not been updated.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: 51d3a0c999e1 ("regulator: palmas: preserve modes of rails during enable/disable")
Signed-off-by: Aleksandrova Alyona <aga ÎÁ itb.spb.ru>
---
 drivers/regulator/palmas-regulator.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/regulator/palmas-regulator.c b/drivers/regulator/palmas-regulator.c
index 337dd614695e..fa6dd240015e 100644
--- a/drivers/regulator/palmas-regulator.c
+++ b/drivers/regulator/palmas-regulator.c
@@ -469,8 +469,11 @@ static int palmas_set_mode_smps(struct regulator_dev *dev, unsigned int mode)
 	}
 
 	pmic->current_reg_mode[id] = reg & PALMAS_SMPS12_CTRL_MODE_ACTIVE_MASK;
-	if (rail_enable)
-		palmas_smps_write(pmic->palmas, rinfo->ctrl_addr, reg);
+	if (rail_enable) {
+		ret = palmas_smps_write(pmic->palmas, rinfo->ctrl_addr, reg);
+		if (ret)
+			return ret;
+	}
 
 	/* Switch the enable value to ensure this is used for enable */
 	pmic->desc[id].enable_val = pmic->current_reg_mode[id];
-- 
2.26.2




More information about the lvc-project mailing list