linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/5] charger-manager: Disable battery charging when charger cable is detached
@ 2012-08-21  8:06 Chanwoo Choi
  0 siblings, 0 replies; only message in thread
From: Chanwoo Choi @ 2012-08-21  8:06 UTC (permalink / raw)
  To: anton.vorontsov
  Cc: cbouatmailru, jenny.tc, ramakrishna.pallala, myungjoo.ham,
	kyungmin.park, linux-kernel, Chanwoo Choi

This patch disable before stop chargint forcibly when charger cable
is detached and check return value of regulator_enable/disable() fucntion
to confirm correct opertion of enabling/disabling charger(regulator).

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>
---
 drivers/power/charger-manager.c |   21 +++++++++++++++++++--
 1 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/drivers/power/charger-manager.c b/drivers/power/charger-manager.c
index 526e5c9..f968301 100644
--- a/drivers/power/charger-manager.c
+++ b/drivers/power/charger-manager.c
@@ -271,9 +271,26 @@ 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
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2012-08-21  8:07 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-21  8:06 [PATCH 1/5] charger-manager: Disable battery charging when charger cable is detached Chanwoo Choi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).