mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-28 03:40:04 +00:00
power: supply: charger-manager: Correct usage of CHARGE_NOW/FULL
The POWER_SUPPLY_CHARGE_NOW/FULL property reflects battery's charges in uAh unit, but charger-manager has been used it wrongly as a status field. Signed-off-by: Jonghwa Lee <jonghwa3.lee@samsung.com> Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> Signed-off-by: Jonathan Bakker <xc-racer2@live.ca> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
This commit is contained in:
parent
cdaeb15157
commit
0a9e0f94bf
1 changed files with 12 additions and 28 deletions
|
@ -846,35 +846,13 @@ static int charger_get_property(struct power_supply *psy,
|
||||||
val->intval = 0;
|
val->intval = 0;
|
||||||
break;
|
break;
|
||||||
case POWER_SUPPLY_PROP_CHARGE_FULL:
|
case POWER_SUPPLY_PROP_CHARGE_FULL:
|
||||||
if (is_full_charged(cm))
|
|
||||||
val->intval = 1;
|
|
||||||
else
|
|
||||||
val->intval = 0;
|
|
||||||
ret = 0;
|
|
||||||
break;
|
|
||||||
case POWER_SUPPLY_PROP_CHARGE_NOW:
|
case POWER_SUPPLY_PROP_CHARGE_NOW:
|
||||||
if (is_charging(cm)) {
|
fuel_gauge = power_supply_get_by_name(cm->desc->psy_fuel_gauge);
|
||||||
fuel_gauge = power_supply_get_by_name(
|
if (!fuel_gauge) {
|
||||||
cm->desc->psy_fuel_gauge);
|
ret = -ENODEV;
|
||||||
if (!fuel_gauge) {
|
break;
|
||||||
ret = -ENODEV;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = power_supply_get_property(fuel_gauge,
|
|
||||||
POWER_SUPPLY_PROP_CHARGE_NOW,
|
|
||||||
val);
|
|
||||||
if (ret) {
|
|
||||||
val->intval = 1;
|
|
||||||
ret = 0;
|
|
||||||
} else {
|
|
||||||
/* If CHARGE_NOW is supplied, use it */
|
|
||||||
val->intval = (val->intval > 0) ?
|
|
||||||
val->intval : 1;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
val->intval = 0;
|
|
||||||
}
|
}
|
||||||
|
ret = power_supply_get_property(fuel_gauge, psp, val);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
@ -893,9 +871,9 @@ static enum power_supply_property default_charger_props[] = {
|
||||||
POWER_SUPPLY_PROP_VOLTAGE_NOW,
|
POWER_SUPPLY_PROP_VOLTAGE_NOW,
|
||||||
POWER_SUPPLY_PROP_CAPACITY,
|
POWER_SUPPLY_PROP_CAPACITY,
|
||||||
POWER_SUPPLY_PROP_ONLINE,
|
POWER_SUPPLY_PROP_ONLINE,
|
||||||
POWER_SUPPLY_PROP_CHARGE_FULL,
|
|
||||||
/*
|
/*
|
||||||
* Optional properties are:
|
* Optional properties are:
|
||||||
|
* POWER_SUPPLY_PROP_CHARGE_FULL,
|
||||||
* POWER_SUPPLY_PROP_CHARGE_NOW,
|
* POWER_SUPPLY_PROP_CHARGE_NOW,
|
||||||
* POWER_SUPPLY_PROP_CURRENT_NOW,
|
* POWER_SUPPLY_PROP_CURRENT_NOW,
|
||||||
* POWER_SUPPLY_PROP_TEMP,
|
* POWER_SUPPLY_PROP_TEMP,
|
||||||
|
@ -1584,6 +1562,12 @@ static int charger_manager_probe(struct platform_device *pdev)
|
||||||
desc->psy_fuel_gauge);
|
desc->psy_fuel_gauge);
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
if (!power_supply_get_property(fuel_gauge,
|
||||||
|
POWER_SUPPLY_PROP_CHARGE_FULL, &val)) {
|
||||||
|
properties[num_properties] =
|
||||||
|
POWER_SUPPLY_PROP_CHARGE_FULL;
|
||||||
|
num_properties++;
|
||||||
|
}
|
||||||
if (!power_supply_get_property(fuel_gauge,
|
if (!power_supply_get_property(fuel_gauge,
|
||||||
POWER_SUPPLY_PROP_CHARGE_NOW, &val)) {
|
POWER_SUPPLY_PROP_CHARGE_NOW, &val)) {
|
||||||
properties[num_properties] =
|
properties[num_properties] =
|
||||||
|
|
Loading…
Reference in a new issue