diff options
-rw-r--r-- | drivers/power/power_supply_core.c | 18 | ||||
-rw-r--r-- | include/linux/power_supply.h | 8 |
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 @@ | |||
24 | struct class *power_supply_class; | 25 | struct class *power_supply_class; |
25 | EXPORT_SYMBOL_GPL(power_supply_class); | 26 | EXPORT_SYMBOL_GPL(power_supply_class); |
26 | 27 | ||
28 | ATOMIC_NOTIFIER_HEAD(power_supply_notifier); | ||
29 | EXPORT_SYMBOL_GPL(power_supply_notifier); | ||
30 | |||
27 | static struct device_type power_supply_dev_type; | 31 | static struct device_type power_supply_dev_type; |
28 | 32 | ||
29 | static bool __power_supply_is_supplied_by(struct power_supply *supplier, | 33 | static 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 | ||
356 | int power_supply_reg_notifier(struct notifier_block *nb) | ||
357 | { | ||
358 | return atomic_notifier_chain_register(&power_supply_notifier, nb); | ||
359 | } | ||
360 | EXPORT_SYMBOL_GPL(power_supply_reg_notifier); | ||
361 | |||
362 | void power_supply_unreg_notifier(struct notifier_block *nb) | ||
363 | { | ||
364 | atomic_notifier_chain_unregister(&power_supply_notifier, nb); | ||
365 | } | ||
366 | EXPORT_SYMBOL_GPL(power_supply_unreg_notifier); | ||
367 | |||
350 | #ifdef CONFIG_THERMAL | 368 | #ifdef CONFIG_THERMAL |
351 | static int power_supply_read_temp(struct thermal_zone_device *tzd, | 369 | static 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 | ||
20 | struct device; | 21 | struct 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 | ||
162 | enum power_supply_notifier_events { | ||
163 | PSY_EVENT_PROP_CHANGED, | ||
164 | }; | ||
165 | |||
161 | union power_supply_propval { | 166 | union 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 | ||
243 | extern struct atomic_notifier_head power_supply_notifier; | ||
244 | extern int power_supply_reg_notifier(struct notifier_block *nb); | ||
245 | extern void power_supply_unreg_notifier(struct notifier_block *nb); | ||
238 | extern struct power_supply *power_supply_get_by_name(const char *name); | 246 | extern struct power_supply *power_supply_get_by_name(const char *name); |
239 | extern void power_supply_changed(struct power_supply *psy); | 247 | extern void power_supply_changed(struct power_supply *psy); |
240 | extern int power_supply_am_i_supplied(struct power_supply *psy); | 248 | extern int power_supply_am_i_supplied(struct power_supply *psy); |