cw2217b: Unify the polarity of the current reported

When the current is negative, it is in the charging state,
and when the current is positive, it is in the discharging state.

Change-Id: Idddf799e947c4094de08c6c641f0125ec6fe6a5e
Reviewed-on: https://gerrit.mot.com/2707665
SME-Granted: SME Approvals Granted
SLTApproved: Slta Waiver
Tested-by: Jira Key
Reviewed-by: Alison Venancio <alisonv@motorola.com>
Reviewed-by: Yonghua Yan <yanyh2@motorola.com>
Reviewed-by: Guobin Zhang <zhanggb@motorola.com>
Submit-Approved: Jira Key
This commit is contained in:
litong20 authored and litong committed 2023-08-14 02:10:11 -05:00
1 parent 0ece0109ba
commit bd94d0fb7f
1 file changed
+5 -4
@@ -424,7 +424,7 @@ static void cw_get_batt_status(struct cw_battery *cw_bat)
cw_bat->batt_status = POWER_SUPPLY_STATUS_FULL;
} else if (abs(batt_curr) < CW_CUR_ACCURACY) {
cw_bat->batt_status = POWER_SUPPLY_STATUS_NOT_CHARGING;
} else if (batt_curr > 0) {
} else if (batt_curr < 0) {
cw_bat->batt_status = POWER_SUPPLY_STATUS_CHARGING;
} else {
cw_bat->batt_status = POWER_SUPPLY_STATUS_DISCHARGING;
@@ -1072,10 +1072,11 @@ static int cw_parse_dts(struct cw_battery *cw_bat)
}
if (of_property_read_bool(np, "ibat-invert-polority"))
cw_bat->ibat_polority = -1;
else
cw_bat->ibat_polority = 1;
else
cw_bat->ibat_polority = -1;
cw_info("ibat_polority=%d \n", cw_bat->ibat_polority);
return rc;
}
@@ -1164,7 +1165,7 @@ static int cw_battery_get_property(struct power_supply *psy,
break;
case POWER_SUPPLY_PROP_CURRENT_NOW:
cw_get_current(cw_bat);
val->intval = cw_bat->cw_current * CW_CUR_UNIT * (-1);
val->intval = cw_bat->cw_current * CW_CUR_UNIT;
val->intval *= cw_bat->ibat_polority;
break;
case POWER_SUPPLY_PROP_TECHNOLOGY: