All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] power_supply: Add power_supply notifier
@ 2013-07-25 19:21 Jenny TC
  2013-08-09 18:56 ` Anton Vorontsov
  0 siblings, 1 reply; 3+ messages in thread
From: Jenny TC @ 2013-07-25 19:21 UTC (permalink / raw)
  To: linux-kernel, Anton Vorontsov, Anton Vorontsov; +Cc: Jenny TC

This patch adds a notifier chain to the power_supply.
This notifier helps drivers in other subsystem to listen to
changes in power supply subsystem. This would help to take some
actions in those drivers on changing the power supply properties.
One such scenario is to increase/decrease system performance based
on the battery capacity/voltage. Another scenario is to adjust the
h/w peak current detection voltage/current thresholds based on battery
voltage/capacity. The notifier helps drivers to listen to changes
in power_suppy susbystem without polling the power_supply properties

Signed-off-by: Jenny TC <jenny.tc@intel.com>
---
 drivers/power/power_supply_core.c |   18 ++++++++++++++++++
 include/linux/power_supply.h      |    7 +++++++
 2 files changed, 25 insertions(+)

diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
index 3b2d5df..a5779b3 100644
--- a/drivers/power/power_supply_core.c
+++ b/drivers/power/power_supply_core.c
@@ -24,6 +24,9 @@
 struct class *power_supply_class;
 EXPORT_SYMBOL_GPL(power_supply_class);
 
+ATOMIC_NOTIFIER_HEAD(power_supply_notifier);
+EXPORT_SYMBOL(power_supply_notifier);
+
 static struct device_type power_supply_dev_type;
 
 static bool __power_supply_is_supplied_by(struct power_supply *supplier,
@@ -76,6 +79,9 @@ static void power_supply_changed_work(struct work_struct *work)
 			      __power_supply_changed_work);
 
 	power_supply_update_leds(psy);
+	
+	atomic_notifier_call_chain(&power_supply_notifier,
+				POWER_SUPPLY_PROP_CHANGED, psy);
 
 	kobject_uevent(&psy->dev->kobj, KOBJ_CHANGE);
 }
@@ -328,6 +334,18 @@ static void power_supply_dev_release(struct device *dev)
 	kfree(dev);
 }
 
+int power_supply_reg_notifier(struct notifier_block *nb)
+{
+	return atomic_notifier_chain_register(&power_supply_notifier, nb);
+}
+EXPORT_SYMBOL_GPL(power_supply_reg_notifier);
+
+void power_supply_unreg_notifier(struct notifier_block *nb)
+{
+	atomic_notifier_chain_unregister(&power_supply_notifier, nb);
+}
+EXPORT_SYMBOL_GPL(power_supply_unreg_notifier);
+
 #ifdef CONFIG_THERMAL
 static int power_supply_read_temp(struct thermal_zone_device *tzd,
 		unsigned long *temp)
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index 516e4c4..32fae9c 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -217,6 +217,10 @@ enum psy_throttle_action {
 	PSY_THROTTLE_INPUT_LIMIT,
 };
 
+enum power_supply_notifier_events {
+	POWER_SUPPLY_PROP_CHANGED,
+};
+
 struct psy_throttle_state {
 	enum psy_throttle_action throttle_action;
 	unsigned throttle_val;
@@ -293,6 +297,9 @@ struct power_supply_info {
 	int use_for_apm;
 };
 
+extern struct atomic_notifier_head    power_supply_notifier;
+extern int power_supply_reg_notifier(struct notifier_block *nb);
+extern void power_supply_unreg_notifier(struct notifier_block *nb);
 extern struct power_supply *power_supply_get_by_name(const char *name);
 extern void power_supply_changed(struct power_supply *psy);
 extern int power_supply_am_i_supplied(struct power_supply *psy);
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] power_supply: Add power_supply notifier
  2013-07-25 19:21 [PATCH] power_supply: Add power_supply notifier Jenny TC
@ 2013-08-09 18:56 ` Anton Vorontsov
  2013-09-23 11:00   ` Tc, Jenny
  0 siblings, 1 reply; 3+ messages in thread
From: Anton Vorontsov @ 2013-08-09 18:56 UTC (permalink / raw)
  To: Jenny TC; +Cc: linux-kernel

On Fri, Jul 26, 2013 at 12:51:09AM +0530, Jenny TC wrote:
> This patch adds a notifier chain to the power_supply.
> This notifier helps drivers in other subsystem to listen to
> changes in power supply subsystem. This would help to take some
> actions in those drivers on changing the power supply properties.
> One such scenario is to increase/decrease system performance based
> on the battery capacity/voltage. Another scenario is to adjust the
> h/w peak current detection voltage/current thresholds based on battery
> voltage/capacity. The notifier helps drivers to listen to changes
> in power_suppy susbystem without polling the power_supply properties
> 
> Signed-off-by: Jenny TC <jenny.tc@intel.com>
> ---

Hi Jenny,

Can you please submit users of this new API as well, so that we could see
the whole picture?

Thanks,

Anton

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH] power_supply: Add power_supply notifier
  2013-08-09 18:56 ` Anton Vorontsov
@ 2013-09-23 11:00   ` Tc, Jenny
  0 siblings, 0 replies; 3+ messages in thread
From: Tc, Jenny @ 2013-09-23 11:00 UTC (permalink / raw)
  To: Anton Vorontsov; +Cc: linux-kernel

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 1442 bytes --]

Anton,

I submitted 7 patches together which includes this patch also. Hope this would give more insight to the features.

-Jenny

> -----Original Message-----
> From: Anton Vorontsov [mailto:anton@scarybugs.org] On Behalf Of Anton Vorontsov
> Sent: Saturday, August 10, 2013 12:27 AM
> To: Tc, Jenny
> Cc: linux-kernel@vger.kernel.org
> Subject: Re: [PATCH] power_supply: Add power_supply notifier
> 
> On Fri, Jul 26, 2013 at 12:51:09AM +0530, Jenny TC wrote:
> > This patch adds a notifier chain to the power_supply.
> > This notifier helps drivers in other subsystem to listen to changes in
> > power supply subsystem. This would help to take some actions in those
> > drivers on changing the power supply properties.
> > One such scenario is to increase/decrease system performance based on
> > the battery capacity/voltage. Another scenario is to adjust the h/w
> > peak current detection voltage/current thresholds based on battery
> > voltage/capacity. The notifier helps drivers to listen to changes in
> > power_suppy susbystem without polling the power_supply properties
> >
> > Signed-off-by: Jenny TC <jenny.tc@intel.com>
> > ---
> 
> Hi Jenny,
> 
> Can you please submit users of this new API as well, so that we could see the whole
> picture?
> 
> Thanks,
> 
> Anton
ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-09-23 11:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-25 19:21 [PATCH] power_supply: Add power_supply notifier Jenny TC
2013-08-09 18:56 ` Anton Vorontsov
2013-09-23 11:00   ` Tc, Jenny

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.