Skip to content

Commit

Permalink
charger-manager: Disable regulator when charger cable is detached
Browse files Browse the repository at this point in the history
This patch disable regulator for charging when charger cable is detached
before stopping charging forcibly on abnormal battery state and check
return value of regulator_enable/disable() function to confirm correct
operation of enabling or disabling regulator for charging.

Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Myungjoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
  • Loading branch information
Chanwoo Choi authored and Anton Vorontsov committed Aug 23, 2012
1 parent c084e09 commit dbb61fc
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions drivers/power/charger-manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,24 @@ static int try_charger_enable(struct charger_manager *cm, bool enable)
if (enable) {
if (cm->emergency_stop)
return -EAGAIN;
for (i = 0 ; i < desc->num_charger_regulators ; i++)
regulator_enable(desc->charger_regulators[i].consumer);
for (i = 0 ; i < desc->num_charger_regulators ; i++) {
err = regulator_enable(desc->charger_regulators[i].consumer);
if (err < 0) {
dev_warn(cm->dev,
"Cannot enable %s regulator\n",
desc->charger_regulators[i].regulator_name);
}
}
} else {
for (i = 0 ; i < desc->num_charger_regulators ; i++) {
err = regulator_disable(desc->charger_regulators[i].consumer);
if (err < 0) {
dev_warn(cm->dev,
"Cannot disable %s regulator\n",
desc->charger_regulators[i].regulator_name);
}
}

/*
* Abnormal battery state - Stop charging forcibly,
* even if charger was enabled at the other places
Expand Down

0 comments on commit dbb61fc

Please sign in to comment.