Skip to content

Commit 81af7f2

Browse files
jwrdegoedesre
authored andcommitted
power: supply: axp288_charger: Round constant_charge_voltage writes down
Round constant_charge_voltage writes down to the first supported lower value, rather then rounding them up to the first supported higher value. This fixes e.g. writing 4250000 resulting in a value of 4350000 which might be dangerous, instead writing 4250000 will now result in a safe 4200000 value. Fixes: 843735b ("power: axp288_charger: axp288 charger driver") Cc: stable@vger.kernel.org Signed-off-by: Hans de Goede <hdegoede@redhat.com> Link: https://lore.kernel.org/r/20240717200333.56669-2-hdegoede@redhat.com Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
1 parent b34ce4a commit 81af7f2

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

drivers/power/supply/axp288_charger.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -178,18 +178,18 @@ static inline int axp288_charger_set_cv(struct axp288_chrg_info *info, int cv)
178178
u8 reg_val;
179179
int ret;
180180

181-
if (cv <= CV_4100MV) {
182-
reg_val = CHRG_CCCV_CV_4100MV;
183-
cv = CV_4100MV;
184-
} else if (cv <= CV_4150MV) {
185-
reg_val = CHRG_CCCV_CV_4150MV;
186-
cv = CV_4150MV;
187-
} else if (cv <= CV_4200MV) {
181+
if (cv >= CV_4350MV) {
182+
reg_val = CHRG_CCCV_CV_4350MV;
183+
cv = CV_4350MV;
184+
} else if (cv >= CV_4200MV) {
188185
reg_val = CHRG_CCCV_CV_4200MV;
189186
cv = CV_4200MV;
187+
} else if (cv >= CV_4150MV) {
188+
reg_val = CHRG_CCCV_CV_4150MV;
189+
cv = CV_4150MV;
190190
} else {
191-
reg_val = CHRG_CCCV_CV_4350MV;
192-
cv = CV_4350MV;
191+
reg_val = CHRG_CCCV_CV_4100MV;
192+
cv = CV_4100MV;
193193
}
194194

195195
reg_val = reg_val << CHRG_CCCV_CV_BIT_POS;

0 commit comments

Comments
 (0)