summaryrefslogtreecommitdiff
path: root/drivers/power
diff options
context:
space:
mode:
authorJonghwa Lee <jonghwa3.lee@samsung.com>2014-12-19 17:55:19 +0900
committerSeung-Woo Kim <sw0312.kim@samsung.com>2016-12-14 13:40:45 +0900
commit3975c8fdd84c17bdedf477ac65ace3e4980b7141 (patch)
treee9efece8ae424b1ccd279aa5bb999b67f82f1ce5 /drivers/power
parente4e37904b023b6fc9ca2621f6f3e4919b1130219 (diff)
power: charger-manager: Get external power souce information only from EXTCON.
When charger-manager checks whether external power source is available, it gets information from charger IC driver. However, it's not correct source, charger IC doesn't have responsibilty to give cable connection status. The charger-manager already gets cable information from EXTCON susbsystem, so it can re-use it. Signed-off-by: Jonghwa Lee <jonghwa3.lee@samsung.com> [k.kozlowski: rebased on 4.1] Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Diffstat (limited to 'drivers/power')
-rw-r--r--drivers/power/charger-manager.c36
1 files changed, 14 insertions, 22 deletions
diff --git a/drivers/power/charger-manager.c b/drivers/power/charger-manager.c
index 1d098abd503f..832fb413bcd0 100644
--- a/drivers/power/charger-manager.c
+++ b/drivers/power/charger-manager.c
@@ -116,36 +116,28 @@ static bool is_batt_present(struct charger_manager *cm)
* is_ext_pwr_online - See if an external power source is attached to charge
* @cm: the Charger Manager representing the battery.
*
- * Returns true if at least one of the chargers of the battery has an external
- * power source attached to charge the battery regardless of whether it is
- * actually charging or not.
+ * Returns true if there is external power source.
+ * Cable connection information is only obtained by EXTCON class notification.
*/
static bool is_ext_pwr_online(struct charger_manager *cm)
{
- union power_supply_propval val;
- struct power_supply *psy;
- bool online = false;
- int i, ret;
- /* If at least one of them has one, it's yes. */
- for (i = 0; cm->desc->psy_charger_stat[i]; i++) {
- psy = power_supply_get_by_name(cm->desc->psy_charger_stat[i]);
- if (!psy) {
- dev_err(cm->dev, "Cannot find power supply \"%s\"\n",
- cm->desc->psy_charger_stat[i]);
- continue;
- }
+ struct charger_desc *desc = cm->desc;
+ struct charger_regulator *regulators = desc->charger_regulators;
+ struct charger_cable *cables;
+ int i, j, num_cables;
- ret = power_supply_get_property(psy, POWER_SUPPLY_PROP_ONLINE,
- &val);
- power_supply_put(psy);
- if (ret == 0 && val.intval) {
- online = true;
- break;
+ /* If at least one of them has one, it's yes. */
+ for (i = 0; i < desc->num_charger_regulators; i++) {
+ cables = regulators[i].cables;
+ num_cables = regulators[i].num_cables;
+ for (j = 0; j < num_cables; j++) {
+ if (cables[j].attached)
+ return true;
}
}
- return online;
+ return false;
}
/**