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
This commit is contained in:
FlowerSea0208 2023-06-10 12:13:37 +08:00 committed by Giovanni Ricca
parent b12e06a7da
commit 4ac66c04c2
No known key found for this signature in database

View File

@ -1124,6 +1124,12 @@ static int battery_psy_get_prop(struct power_supply *psy,
case POWER_SUPPLY_PROP_CHARGE_COUNTER: case POWER_SUPPLY_PROP_CHARGE_COUNTER:
pval->intval = DIV_ROUND_CLOSEST(pst->prop[prop_id], 100); pval->intval = DIV_ROUND_CLOSEST(pst->prop[prop_id], 100);
break; 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 #endif
default: default:
pval->intval = pst->prop[prop_id]; pval->intval = pst->prop[prop_id];