Message ID | 1384856285-19593-2-git-send-email-pali.rohar@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Tue 2013-11-19 11:18:03, Pali Rohár 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> > Signed-off-by: Pali Rohár <pali.rohar@gmail.com> Reviewed-by: Pavel Machek <pavel@ucw.cz> > +extern struct atomic_notifier_head power_supply_notifier; You may want to delete some spaces here. Thanks, Pavel
On Tuesday 19 November 2013 14:10:06 Pavel Machek wrote: > On Tue 2013-11-19 11:18:03, Pali Rohár 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> > > Signed-off-by: Pali Rohár <pali.rohar@gmail.com> > > Reviewed-by: Pavel Machek <pavel@ucw.cz> > > > +extern struct atomic_notifier_head > > power_supply_notifier; > > You may want to delete some spaces here. > > Thanks, > Pavel Ok, note that this patch I copied from: https://lkml.org/lkml/2013/9/23/181
Hi, On Tue, Nov 19, 2013 at 11:18:03AM +0100, Pali Rohár 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 > > [...] Tested-By: Sebastian Reichel <sre@debian.org> -- Sebastian
> Subject: [PATCH v2 1/3] power_supply: Add power_supply notifier > > 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> > Signed-off-by: Pali Rohár <pali.rohar@gmail.com> > --- Acked-by: Jenny TC <jenny.tc@intel.com>
On Wed, Nov 27, 2013 at 05:23:34PM +0000, Tc, Jenny wrote: > > > Subject: [PATCH v2 1/3] power_supply: Add power_supply notifier > > > > 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> > > Signed-off-by: Pali Rohár <pali.rohar@gmail.com> > > --- > > Acked-by: Jenny TC <jenny.tc@intel.com> Applied, thanks a lot! Anton -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c index 00e6672..08bce22 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_GPL(power_supply_notifier); + static struct device_type power_supply_dev_type; static bool __power_supply_is_supplied_by(struct power_supply *supplier, @@ -80,6 +83,8 @@ 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_update_leds(psy); + atomic_notifier_call_chain(&power_supply_notifier, + PSY_EVENT_PROP_CHANGED, psy); kobject_uevent(&psy->dev->kobj, KOBJ_CHANGE); spin_lock_irqsave(&psy->changed_lock, flags); } @@ -347,6 +352,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 5c26006..c6f52c0 100644 --- a/include/linux/power_supply.h +++ b/include/linux/power_supply.h @@ -158,6 +158,13 @@ enum power_supply_type { POWER_SUPPLY_TYPE_USB_ACA, /* Accessory Charger Adapters */ }; +enum power_supply_notifier_events { + PSY_EVENT_NONE, + PSY_EVENT_PROP_CHANGED, + PSY_EVENT_BATTERY, + PSY_EVENT_CABLE, +}; + union power_supply_propval { int intval; const char *strval; @@ -235,6 +242,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);