aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/power/power_supply_core.c18
-rw-r--r--include/linux/power_supply.h8
2 files changed, 26 insertions, 0 deletions
diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
index 557af943b2f5..6aac23cc6566 100644
--- a/drivers/power/power_supply_core.c
+++ b/drivers/power/power_supply_core.c
@@ -15,6 +15,7 @@
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/slab.h> 16#include <linux/slab.h>
17#include <linux/device.h> 17#include <linux/device.h>
18#include <linux/notifier.h>
18#include <linux/err.h> 19#include <linux/err.h>
19#include <linux/power_supply.h> 20#include <linux/power_supply.h>
20#include <linux/thermal.h> 21#include <linux/thermal.h>
@@ -24,6 +25,9 @@
24struct class *power_supply_class; 25struct class *power_supply_class;
25EXPORT_SYMBOL_GPL(power_supply_class); 26EXPORT_SYMBOL_GPL(power_supply_class);
26 27
28ATOMIC_NOTIFIER_HEAD(power_supply_notifier);
29EXPORT_SYMBOL_GPL(power_supply_notifier);
30
27static struct device_type power_supply_dev_type; 31static struct device_type power_supply_dev_type;
28 32
29static bool __power_supply_is_supplied_by(struct power_supply *supplier, 33static bool __power_supply_is_supplied_by(struct power_supply *supplier,
@@ -80,6 +84,8 @@ static void power_supply_changed_work(struct work_struct *work)
80 class_for_each_device(power_supply_class, NULL, psy, 84 class_for_each_device(power_supply_class, NULL, psy,
81 __power_supply_changed_work); 85 __power_supply_changed_work);
82 power_supply_update_leds(psy); 86 power_supply_update_leds(psy);
87 atomic_notifier_call_chain(&power_supply_notifier,
88 PSY_EVENT_PROP_CHANGED, psy);
83 kobject_uevent(&psy->dev->kobj, KOBJ_CHANGE); 89 kobject_uevent(&psy->dev->kobj, KOBJ_CHANGE);
84 spin_lock_irqsave(&psy->changed_lock, flags); 90 spin_lock_irqsave(&psy->changed_lock, flags);
85 } 91 }
@@ -347,6 +353,18 @@ static void power_supply_dev_release(struct device *dev)
347 kfree(dev); 353 kfree(dev);
348} 354}
349 355
356int power_supply_reg_notifier(struct notifier_block *nb)
357{
358 return atomic_notifier_chain_register(&power_supply_notifier, nb);
359}
360EXPORT_SYMBOL_GPL(power_supply_reg_notifier);
361
362void power_supply_unreg_notifier(struct notifier_block *nb)
363{
364 atomic_notifier_chain_unregister(&power_supply_notifier, nb);
365}
366EXPORT_SYMBOL_GPL(power_supply_unreg_notifier);
367
350#ifdef CONFIG_THERMAL 368#ifdef CONFIG_THERMAL
351static int power_supply_read_temp(struct thermal_zone_device *tzd, 369static int power_supply_read_temp(struct thermal_zone_device *tzd,
352 unsigned long *temp) 370 unsigned long *temp)
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index 5c2600630dc9..3e28fe188d17 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -16,6 +16,7 @@
16#include <linux/workqueue.h> 16#include <linux/workqueue.h>
17#include <linux/leds.h> 17#include <linux/leds.h>
18#include <linux/spinlock.h> 18#include <linux/spinlock.h>
19#include <linux/notifier.h>
19 20
20struct device; 21struct device;
21 22
@@ -158,6 +159,10 @@ enum power_supply_type {
158 POWER_SUPPLY_TYPE_USB_ACA, /* Accessory Charger Adapters */ 159 POWER_SUPPLY_TYPE_USB_ACA, /* Accessory Charger Adapters */
159}; 160};
160 161
162enum power_supply_notifier_events {
163 PSY_EVENT_PROP_CHANGED,
164};
165
161union power_supply_propval { 166union power_supply_propval {
162 int intval; 167 int intval;
163 const char *strval; 168 const char *strval;
@@ -235,6 +240,9 @@ struct power_supply_info {
235 int use_for_apm; 240 int use_for_apm;
236}; 241};
237 242
243extern struct atomic_notifier_head power_supply_notifier;
244extern int power_supply_reg_notifier(struct notifier_block *nb);
245extern void power_supply_unreg_notifier(struct notifier_block *nb);
238extern struct power_supply *power_supply_get_by_name(const char *name); 246extern struct power_supply *power_supply_get_by_name(const char *name);
239extern void power_supply_changed(struct power_supply *psy); 247extern void power_supply_changed(struct power_supply *psy);
240extern int power_supply_am_i_supplied(struct power_supply *psy); 248extern int power_supply_am_i_supplied(struct power_supply *psy);