lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [day] [month] [year] [list]
Date:	Thu, 12 Jul 2012 15:03:29 +0900
From:	Chanwoo Choi <cw00.choi@...sung.com>
To:	anton.vorontsov@...aro.org
Cc:	cbouatmailru@...il.com, jenny.tc@...el.com,
	ramakrishna.pallala@...el.com, myungjoo.ham@...sung.com,
	kyungmin.park@...sung.com, linux-kernel@...r.kernel.org,
	Chanwoo Choi <cw00.choi@...sung.com>
Subject: [PATCH 2/2] charger-manager: Set current limit of regulator for over
 current protection

This patch support the protection of host device from over current.
The Charger-manager set proper current limit of charger(regulator) for
charging according to type of charger cable when external connector
is attached.

Signed-off-by: Chanwoo Choi <cw00.choi@...sung.com>
Signed-off-by: Myungjoo Ham <myungjoo.ham@...sung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@...sung.com>
---
 drivers/power/charger-manager.c       |   15 +++++++++++++++
 include/linux/power/charger-manager.h |    8 ++++++++
 2 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/drivers/power/charger-manager.c b/drivers/power/charger-manager.c
index af03f23..4f1de56 100644
--- a/drivers/power/charger-manager.c
+++ b/drivers/power/charger-manager.c
@@ -1001,6 +1001,21 @@ static void charger_extcon_work(struct work_struct *work)
 {
 	struct charger_cable *cable =
 			container_of(work, struct charger_cable, wq);
+	int ret;
+
+	if (cable->attached && cable->min_uA != 0 && cable->max_uA != 0) {
+		ret = regulator_set_current_limit(cable->charger->consumer,
+					cable->min_uA, cable->max_uA);
+		if (ret < 0) {
+			pr_err("Cannot set current limit of %s (%s)\n",
+				cable->charger->regulator_name, cable->name);
+			return;
+		}
+
+		pr_info("Set current limit of %s : %duA ~ %duA\n",
+					cable->charger->regulator_name,
+					cable->min_uA, cable->max_uA);
+	}
 
 	try_charger_enable(cable->cm, cable->attached);
 }
diff --git a/include/linux/power/charger-manager.h b/include/linux/power/charger-manager.h
index 6cb9fbc..cd22029 100644
--- a/include/linux/power/charger-manager.h
+++ b/include/linux/power/charger-manager.h
@@ -94,6 +94,14 @@ struct charger_cable {
 	bool attached;
 
 	struct charger_regulator *charger;
+
+	/*
+	 * Set min/max current of regulator to protect over-current issue
+	 * according to a kind of charger cable when cable is attached.
+	 */
+	int min_uA;
+	int max_uA;
+
 	struct charger_manager *cm;
 };
 
-- 
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ