power: supply: qti_battery_charger: Return time to full in seconds

* 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 Jens Reidel
parent 956e37ba3b
commit 05e7d49733
No known key found for this signature in database
GPG Key ID: 23C1E5F512C12303

View File

@ -1364,6 +1364,10 @@ static int battery_psy_get_prop(struct power_supply *psy,
case POWER_SUPPLY_PROP_CHARGE_COUNTER:
pval->intval = pst->prop[prop_id] * 1000;
break;
case POWER_SUPPLY_PROP_TIME_TO_FULL_AVG:
pval->intval = (pst->prop[prop_id] * 60) > 65535 ?
-1 : (pst->prop[prop_id] * 60);
break;
default:
pval->intval = pst->prop[prop_id];
break;