From: Jenny TC <jenny.tc@intel.com>
To: Anton Vorontsov <anton.vorontsov@linaro.org>,
Anton Vorontsov <cbouatmailru@gmail.com>,
linux-kernel@vger.kernel.org
Cc: Pallala Ramakrishna <ramakrishna.pallala@intel.com>,
Chanwoo Choi <cw00.choi@samsung.com>,
myungjoo.ham@samsung.com, Jenny TC <jenny.tc@intel.com>
Subject: [PATCH 6/7] power_supply: enable charger framework callbacks
Date: Thu, 18 Oct 2012 22:14:05 +0530 [thread overview]
Message-ID: <1350578646-3315-7-git-send-email-jenny.tc@intel.com> (raw)
In-Reply-To: <1350578646-3315-1-git-send-email-jenny.tc@intel.com>
The charger framework needs to be notified on registering
a new charger, on power supply changed event or on a thermal
throttle request. This patch enables support for the same
Signed-off-by: Jenny TC <jenny.tc@intel.com>
---
drivers/power/power_supply.h | 20 ++++++++++++++++++++
drivers/power/power_supply_core.c | 12 ++++++++++++
2 files changed, 32 insertions(+)
diff --git a/drivers/power/power_supply.h b/drivers/power/power_supply.h
index cc439fd..ae2d66c 100644
--- a/drivers/power/power_supply.h
+++ b/drivers/power/power_supply.h
@@ -40,3 +40,23 @@ static inline int power_supply_create_triggers(struct power_supply *psy)
static inline void power_supply_remove_triggers(struct power_supply *psy) {}
#endif /* CONFIG_LEDS_TRIGGERS */
+#ifdef CONFIG_POWER_SUPPLY_CHARGER
+
+extern void power_supply_trigger_charging_handler(struct power_supply *psy);
+extern int power_supply_register_charger(struct power_supply *psy);
+extern int power_supply_unregister_charger(struct power_supply *psy);
+extern int psy_charger_throttle_charger(struct power_supply *psy,
+ unsigned long state);
+
+#else
+
+static inline void power_supply_trigger_charging_handler(struct power_supply *psy) { }
+static inline int power_supply_register_charger(struct power_supply *psy)
+{ return 0; }
+static inline int power_supply_unregister_charger(struct power_supply *psy)
+{ return 0; }
+static inline int psy_charger_throttle_charger(struct power_supply *psy,
+ unsigned long state)
+{ return 0; }
+
+#endif
diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
index 3338d49..73ac6e4 100644
--- a/drivers/power/power_supply_core.c
+++ b/drivers/power/power_supply_core.c
@@ -19,6 +19,7 @@
#include <linux/power_supply.h>
#include <linux/thermal.h>
#include "power_supply.h"
+#include "power_supply_charger.h"
/* exported for the APM Power driver, APM emulation */
struct class *power_supply_class;
@@ -49,6 +50,7 @@ static void power_supply_changed_work(struct work_struct *work)
class_for_each_device(power_supply_class, NULL, psy,
__power_supply_changed_work);
+ power_supply_trigger_charging_handler(psy);
power_supply_update_leds(psy);
@@ -265,6 +267,8 @@ static int ps_set_cur_charge_cntl_limit(struct thermal_cooling_device *tcd,
ret = psy->set_property(psy,
POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT, &val);
+ psy_charger_throttle_charger(psy,state);
+
return ret;
}
@@ -360,10 +364,16 @@ int power_supply_register(struct device *parent, struct power_supply *psy)
if (rc)
goto create_triggers_failed;
+ if (IS_CHARGER(psy))
+ rc = power_supply_register_charger(psy);
+ if (rc)
+ goto charger_register_failed;
+
power_supply_changed(psy);
goto success;
+charger_register_failed:
create_triggers_failed:
psy_unregister_cooler(psy);
register_cooler_failed:
@@ -382,6 +392,8 @@ void power_supply_unregister(struct power_supply *psy)
{
cancel_work_sync(&psy->changed_work);
sysfs_remove_link(&psy->dev->kobj, "powers");
+ if (IS_CHARGER(psy))
+ power_supply_unregister_charger(psy);
power_supply_remove_triggers(psy);
psy_unregister_cooler(psy);
psy_unregister_thermal(psy);
--
1.7.9.5
next prev parent reply other threads:[~2012-10-18 11:12 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-18 16:43 [PATCH 0/7] power_supply: Introduce charging Framework Jenny TC
2012-10-18 16:44 ` [PATCH 1/7] power_supply : Introduce battery identification framework Jenny TC
2012-10-18 16:44 ` [PATCH 2/7] power_supply: Add charger control properties Jenny TC
2012-11-19 0:50 ` Anton Vorontsov
2012-10-18 16:44 ` [PATCH 3/7] power_supply : add supported charger cable feature Jenny TC
2012-11-19 0:52 ` Anton Vorontsov
2012-10-18 16:44 ` [PATCH 4/7] power_supply: add throttle state Jenny TC
2012-11-19 2:39 ` Anton Vorontsov
2012-10-18 16:44 ` [PATCH 5/7] power_supply: Introduce Power Supply charging framework Jenny TC
2012-11-19 2:39 ` Anton Vorontsov
2012-10-18 16:44 ` Jenny TC [this message]
2012-10-18 16:44 ` [PATCH 7/7] power_supply: Introduce PSE compliant algorithm Jenny TC
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1350578646-3315-7-git-send-email-jenny.tc@intel.com \
--to=jenny.tc@intel.com \
--cc=anton.vorontsov@linaro.org \
--cc=cbouatmailru@gmail.com \
--cc=cw00.choi@samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=myungjoo.ham@samsung.com \
--cc=ramakrishna.pallala@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®