Commit b70229bc authored by Krzysztof Kozlowski's avatar Krzysztof Kozlowski Committed by Sebastian Reichel

power_supply: charger-manager: Use power_supply_*() API for accessing function attrs

Replace direct calls to power supply function attributes with wrappers.
Wrappers provide safe access in case of unregistering the power
supply (e.g. by removing the driver). Replace:
 - get_property -> power_supply_get_property
Signed-off-by: default avatarKrzysztof Kozlowski <k.kozlowski@samsung.com>
Acked-by: default avatarJonghwa Lee <jonghwa3.lee@samsung.com>
Acked-by: default avatarPavel Machek <pavel@ucw.cz>
Reviewed-by: default avatarBartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Reviewed-by: default avatarSebastian Reichel <sre@kernel.org>
Signed-off-by: default avatarSebastian Reichel <sre@kernel.org>
parent d7bdffb9
...@@ -103,8 +103,8 @@ static bool is_batt_present(struct charger_manager *cm) ...@@ -103,8 +103,8 @@ static bool is_batt_present(struct charger_manager *cm)
if (!psy) if (!psy)
break; break;
ret = psy->get_property(psy, ret = power_supply_get_property(psy, POWER_SUPPLY_PROP_PRESENT,
POWER_SUPPLY_PROP_PRESENT, &val); &val);
if (ret == 0 && val.intval) if (ret == 0 && val.intval)
present = true; present = true;
break; break;
...@@ -118,8 +118,8 @@ static bool is_batt_present(struct charger_manager *cm) ...@@ -118,8 +118,8 @@ static bool is_batt_present(struct charger_manager *cm)
continue; continue;
} }
ret = psy->get_property(psy, POWER_SUPPLY_PROP_PRESENT, ret = power_supply_get_property(psy,
&val); POWER_SUPPLY_PROP_PRESENT, &val);
if (ret == 0 && val.intval) { if (ret == 0 && val.intval) {
present = true; present = true;
break; break;
...@@ -155,7 +155,8 @@ static bool is_ext_pwr_online(struct charger_manager *cm) ...@@ -155,7 +155,8 @@ static bool is_ext_pwr_online(struct charger_manager *cm)
continue; continue;
} }
ret = psy->get_property(psy, POWER_SUPPLY_PROP_ONLINE, &val); ret = power_supply_get_property(psy, POWER_SUPPLY_PROP_ONLINE,
&val);
if (ret == 0 && val.intval) { if (ret == 0 && val.intval) {
online = true; online = true;
break; break;
...@@ -183,7 +184,7 @@ static int get_batt_uV(struct charger_manager *cm, int *uV) ...@@ -183,7 +184,7 @@ static int get_batt_uV(struct charger_manager *cm, int *uV)
if (!fuel_gauge) if (!fuel_gauge)
return -ENODEV; return -ENODEV;
ret = fuel_gauge->get_property(fuel_gauge, ret = power_supply_get_property(fuel_gauge,
POWER_SUPPLY_PROP_VOLTAGE_NOW, &val); POWER_SUPPLY_PROP_VOLTAGE_NOW, &val);
if (ret) if (ret)
return ret; return ret;
...@@ -223,7 +224,8 @@ static bool is_charging(struct charger_manager *cm) ...@@ -223,7 +224,8 @@ static bool is_charging(struct charger_manager *cm)
} }
/* 2. The charger should be online (ext-power) */ /* 2. The charger should be online (ext-power) */
ret = psy->get_property(psy, POWER_SUPPLY_PROP_ONLINE, &val); ret = power_supply_get_property(psy, POWER_SUPPLY_PROP_ONLINE,
&val);
if (ret) { if (ret) {
dev_warn(cm->dev, "Cannot read ONLINE value from %s\n", dev_warn(cm->dev, "Cannot read ONLINE value from %s\n",
cm->desc->psy_charger_stat[i]); cm->desc->psy_charger_stat[i]);
...@@ -236,7 +238,8 @@ static bool is_charging(struct charger_manager *cm) ...@@ -236,7 +238,8 @@ static bool is_charging(struct charger_manager *cm)
* 3. The charger should not be FULL, DISCHARGING, * 3. The charger should not be FULL, DISCHARGING,
* or NOT_CHARGING. * or NOT_CHARGING.
*/ */
ret = psy->get_property(psy, POWER_SUPPLY_PROP_STATUS, &val); ret = power_supply_get_property(psy, POWER_SUPPLY_PROP_STATUS,
&val);
if (ret) { if (ret) {
dev_warn(cm->dev, "Cannot read STATUS value from %s\n", dev_warn(cm->dev, "Cannot read STATUS value from %s\n",
cm->desc->psy_charger_stat[i]); cm->desc->psy_charger_stat[i]);
...@@ -279,7 +282,7 @@ static bool is_full_charged(struct charger_manager *cm) ...@@ -279,7 +282,7 @@ static bool is_full_charged(struct charger_manager *cm)
val.intval = 0; val.intval = 0;
/* Not full if capacity of fuel gauge isn't full */ /* Not full if capacity of fuel gauge isn't full */
ret = fuel_gauge->get_property(fuel_gauge, ret = power_supply_get_property(fuel_gauge,
POWER_SUPPLY_PROP_CHARGE_FULL, &val); POWER_SUPPLY_PROP_CHARGE_FULL, &val);
if (!ret && val.intval > desc->fullbatt_full_capacity) if (!ret && val.intval > desc->fullbatt_full_capacity)
return true; return true;
...@@ -296,7 +299,7 @@ static bool is_full_charged(struct charger_manager *cm) ...@@ -296,7 +299,7 @@ static bool is_full_charged(struct charger_manager *cm)
if (desc->fullbatt_soc > 0) { if (desc->fullbatt_soc > 0) {
val.intval = 0; val.intval = 0;
ret = fuel_gauge->get_property(fuel_gauge, ret = power_supply_get_property(fuel_gauge,
POWER_SUPPLY_PROP_CAPACITY, &val); POWER_SUPPLY_PROP_CAPACITY, &val);
if (!ret && val.intval >= desc->fullbatt_soc) if (!ret && val.intval >= desc->fullbatt_soc)
return true; return true;
...@@ -580,7 +583,7 @@ static int cm_get_battery_temperature_by_psy(struct charger_manager *cm, ...@@ -580,7 +583,7 @@ static int cm_get_battery_temperature_by_psy(struct charger_manager *cm,
if (!fuel_gauge) if (!fuel_gauge)
return -ENODEV; return -ENODEV;
return fuel_gauge->get_property(fuel_gauge, return power_supply_get_property(fuel_gauge,
POWER_SUPPLY_PROP_TEMP, POWER_SUPPLY_PROP_TEMP,
(union power_supply_propval *)temp); (union power_supply_propval *)temp);
} }
...@@ -900,7 +903,7 @@ static int charger_get_property(struct power_supply *psy, ...@@ -900,7 +903,7 @@ static int charger_get_property(struct power_supply *psy,
ret = -ENODEV; ret = -ENODEV;
break; break;
} }
ret = fuel_gauge->get_property(fuel_gauge, ret = power_supply_get_property(fuel_gauge,
POWER_SUPPLY_PROP_CURRENT_NOW, val); POWER_SUPPLY_PROP_CURRENT_NOW, val);
break; break;
case POWER_SUPPLY_PROP_TEMP: case POWER_SUPPLY_PROP_TEMP:
...@@ -919,7 +922,7 @@ static int charger_get_property(struct power_supply *psy, ...@@ -919,7 +922,7 @@ static int charger_get_property(struct power_supply *psy,
break; break;
} }
ret = fuel_gauge->get_property(fuel_gauge, ret = power_supply_get_property(fuel_gauge,
POWER_SUPPLY_PROP_CAPACITY, val); POWER_SUPPLY_PROP_CAPACITY, val);
if (ret) if (ret)
break; break;
...@@ -975,7 +978,7 @@ static int charger_get_property(struct power_supply *psy, ...@@ -975,7 +978,7 @@ static int charger_get_property(struct power_supply *psy,
break; break;
} }
ret = fuel_gauge->get_property(fuel_gauge, ret = power_supply_get_property(fuel_gauge,
POWER_SUPPLY_PROP_CHARGE_NOW, POWER_SUPPLY_PROP_CHARGE_NOW,
val); val);
if (ret) { if (ret) {
...@@ -1424,7 +1427,7 @@ static int cm_init_thermal_data(struct charger_manager *cm, ...@@ -1424,7 +1427,7 @@ static int cm_init_thermal_data(struct charger_manager *cm,
int ret; int ret;
/* Verify whether fuel gauge provides battery temperature */ /* Verify whether fuel gauge provides battery temperature */
ret = fuel_gauge->get_property(fuel_gauge, ret = power_supply_get_property(fuel_gauge,
POWER_SUPPLY_PROP_TEMP, &val); POWER_SUPPLY_PROP_TEMP, &val);
if (!ret) { if (!ret) {
...@@ -1718,13 +1721,13 @@ static int charger_manager_probe(struct platform_device *pdev) ...@@ -1718,13 +1721,13 @@ static int charger_manager_probe(struct platform_device *pdev)
cm->charger_psy.num_properties = psy_default.num_properties; cm->charger_psy.num_properties = psy_default.num_properties;
/* Find which optional psy-properties are available */ /* Find which optional psy-properties are available */
if (!fuel_gauge->get_property(fuel_gauge, if (!power_supply_get_property(fuel_gauge,
POWER_SUPPLY_PROP_CHARGE_NOW, &val)) { POWER_SUPPLY_PROP_CHARGE_NOW, &val)) {
cm->charger_psy.properties[cm->charger_psy.num_properties] = cm->charger_psy.properties[cm->charger_psy.num_properties] =
POWER_SUPPLY_PROP_CHARGE_NOW; POWER_SUPPLY_PROP_CHARGE_NOW;
cm->charger_psy.num_properties++; cm->charger_psy.num_properties++;
} }
if (!fuel_gauge->get_property(fuel_gauge, if (!power_supply_get_property(fuel_gauge,
POWER_SUPPLY_PROP_CURRENT_NOW, POWER_SUPPLY_PROP_CURRENT_NOW,
&val)) { &val)) {
cm->charger_psy.properties[cm->charger_psy.num_properties] = cm->charger_psy.properties[cm->charger_psy.num_properties] =
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment