From 4ac66c04c2d57f25a8157a321741e299fe2bc704 Mon Sep 17 00:00:00 2001 From: FlowerSea0208 Date: Sat, 10 Jun 2023 12:13:37 +0800 Subject: [PATCH] power: supply: qti_battery_charger: change the measuring unit of TIME_TO_FULL_AVG property * In Android 13, Xiaomi changed the measuring unit of this property in firmware to minutes instead of seconds, revert that behavior back by intercepting the property value and multiplying it by 60 before setting the node, as userspace expects the unit to be seconds. * Then make sure the final value doesn't exceed 65535. Change-Id: I9d8accbe48d743b8b071cba4253e017068b8e766 --- drivers/power/supply/qti_battery_charger.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/power/supply/qti_battery_charger.c b/drivers/power/supply/qti_battery_charger.c index 363ba95e310b..129bd624f2f1 100644 --- a/drivers/power/supply/qti_battery_charger.c +++ b/drivers/power/supply/qti_battery_charger.c @@ -1124,6 +1124,12 @@ static int battery_psy_get_prop(struct power_supply *psy, case POWER_SUPPLY_PROP_CHARGE_COUNTER: pval->intval = DIV_ROUND_CLOSEST(pst->prop[prop_id], 100); break; +#endif +#ifdef CONFIG_BQ_FUEL_GAUGE + case POWER_SUPPLY_PROP_TIME_TO_FULL_AVG: + pval->intval = (pst->prop[prop_id] * 60) >= 65535 ? + 65535 : (pst->prop[prop_id] * 60); + break; #endif default: pval->intval = pst->prop[prop_id];