Skip to content

Commit

Permalink
power_supply: charger-manager: Use power_supply_*() API for accessing…
Browse files Browse the repository at this point in the history
… 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: Krzysztof Kozlowski <[email protected]>
Acked-by: Jonghwa Lee <[email protected]>
Acked-by: Pavel Machek <[email protected]>
Reviewed-by: Bartlomiej Zolnierkiewicz <[email protected]>
Reviewed-by: Sebastian Reichel <[email protected]>
Signed-off-by: Sebastian Reichel <[email protected]>
  • Loading branch information
krzk authored and sre committed Mar 13, 2015
1 parent d7bdffb commit b70229b
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 additions & 17 deletions drivers/power/charger-manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ static bool is_batt_present(struct charger_manager *cm)
if (!psy)
break;

ret = psy->get_property(psy,
POWER_SUPPLY_PROP_PRESENT, &val);
ret = power_supply_get_property(psy, POWER_SUPPLY_PROP_PRESENT,
&val);
if (ret == 0 && val.intval)
present = true;
break;
Expand All @@ -118,8 +118,8 @@ static bool is_batt_present(struct charger_manager *cm)
continue;
}

ret = psy->get_property(psy, POWER_SUPPLY_PROP_PRESENT,
&val);
ret = power_supply_get_property(psy,
POWER_SUPPLY_PROP_PRESENT, &val);
if (ret == 0 && val.intval) {
present = true;
break;
Expand Down Expand Up @@ -155,7 +155,8 @@ static bool is_ext_pwr_online(struct charger_manager *cm)
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) {
online = true;
break;
Expand Down Expand Up @@ -183,7 +184,7 @@ static int get_batt_uV(struct charger_manager *cm, int *uV)
if (!fuel_gauge)
return -ENODEV;

ret = fuel_gauge->get_property(fuel_gauge,
ret = power_supply_get_property(fuel_gauge,
POWER_SUPPLY_PROP_VOLTAGE_NOW, &val);
if (ret)
return ret;
Expand Down Expand Up @@ -223,7 +224,8 @@ static bool is_charging(struct charger_manager *cm)
}

/* 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) {
dev_warn(cm->dev, "Cannot read ONLINE value from %s\n",
cm->desc->psy_charger_stat[i]);
Expand All @@ -236,7 +238,8 @@ static bool is_charging(struct charger_manager *cm)
* 3. The charger should not be FULL, DISCHARGING,
* 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) {
dev_warn(cm->dev, "Cannot read STATUS value from %s\n",
cm->desc->psy_charger_stat[i]);
Expand Down Expand Up @@ -279,7 +282,7 @@ static bool is_full_charged(struct charger_manager *cm)
val.intval = 0;

/* 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);
if (!ret && val.intval > desc->fullbatt_full_capacity)
return true;
Expand All @@ -296,7 +299,7 @@ static bool is_full_charged(struct charger_manager *cm)
if (desc->fullbatt_soc > 0) {
val.intval = 0;

ret = fuel_gauge->get_property(fuel_gauge,
ret = power_supply_get_property(fuel_gauge,
POWER_SUPPLY_PROP_CAPACITY, &val);
if (!ret && val.intval >= desc->fullbatt_soc)
return true;
Expand Down Expand Up @@ -580,7 +583,7 @@ static int cm_get_battery_temperature_by_psy(struct charger_manager *cm,
if (!fuel_gauge)
return -ENODEV;

return fuel_gauge->get_property(fuel_gauge,
return power_supply_get_property(fuel_gauge,
POWER_SUPPLY_PROP_TEMP,
(union power_supply_propval *)temp);
}
Expand Down Expand Up @@ -900,7 +903,7 @@ static int charger_get_property(struct power_supply *psy,
ret = -ENODEV;
break;
}
ret = fuel_gauge->get_property(fuel_gauge,
ret = power_supply_get_property(fuel_gauge,
POWER_SUPPLY_PROP_CURRENT_NOW, val);
break;
case POWER_SUPPLY_PROP_TEMP:
Expand All @@ -919,7 +922,7 @@ static int charger_get_property(struct power_supply *psy,
break;
}

ret = fuel_gauge->get_property(fuel_gauge,
ret = power_supply_get_property(fuel_gauge,
POWER_SUPPLY_PROP_CAPACITY, val);
if (ret)
break;
Expand Down Expand Up @@ -975,7 +978,7 @@ static int charger_get_property(struct power_supply *psy,
break;
}

ret = fuel_gauge->get_property(fuel_gauge,
ret = power_supply_get_property(fuel_gauge,
POWER_SUPPLY_PROP_CHARGE_NOW,
val);
if (ret) {
Expand Down Expand Up @@ -1424,7 +1427,7 @@ static int cm_init_thermal_data(struct charger_manager *cm,
int ret;

/* 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);

if (!ret) {
Expand Down Expand Up @@ -1718,13 +1721,13 @@ static int charger_manager_probe(struct platform_device *pdev)
cm->charger_psy.num_properties = psy_default.num_properties;

/* 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)) {
cm->charger_psy.properties[cm->charger_psy.num_properties] =
POWER_SUPPLY_PROP_CHARGE_NOW;
cm->charger_psy.num_properties++;
}
if (!fuel_gauge->get_property(fuel_gauge,
if (!power_supply_get_property(fuel_gauge,
POWER_SUPPLY_PROP_CURRENT_NOW,
&val)) {
cm->charger_psy.properties[cm->charger_psy.num_properties] =
Expand Down

0 comments on commit b70229b

Please sign in to comment.