Commit 9113e260 authored by Zhang Rui's avatar Zhang Rui Committed by Rafael J. Wysocki

power_supply: allow power supply devices registered w/o wakeup source

Currently, all the power supply devices are registered with wakeup source,
this results in that every power_supply_changed() invocation brings
the system out of suspend-to-freeze state.

This is overkill as some device drivers, e.g. ACPI battery driver,
have the ability to check the device status and wake up the system
from sleeping only when necessary.

Thus introduce a new API which allows device to be registered
w/o wakeup source.
Signed-off-by: default avatarZhang Rui <rui.zhang@intel.com>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 1ac5aaa6
...@@ -537,7 +537,7 @@ static void psy_unregister_cooler(struct power_supply *psy) ...@@ -537,7 +537,7 @@ static void psy_unregister_cooler(struct power_supply *psy)
} }
#endif #endif
int power_supply_register(struct device *parent, struct power_supply *psy) int __power_supply_register(struct device *parent, struct power_supply *psy, bool ws)
{ {
struct device *dev; struct device *dev;
int rc; int rc;
...@@ -568,7 +568,7 @@ int power_supply_register(struct device *parent, struct power_supply *psy) ...@@ -568,7 +568,7 @@ int power_supply_register(struct device *parent, struct power_supply *psy)
} }
spin_lock_init(&psy->changed_lock); spin_lock_init(&psy->changed_lock);
rc = device_init_wakeup(dev, true); rc = device_init_wakeup(dev, ws);
if (rc) if (rc)
goto wakeup_init_failed; goto wakeup_init_failed;
...@@ -606,8 +606,19 @@ int power_supply_register(struct device *parent, struct power_supply *psy) ...@@ -606,8 +606,19 @@ int power_supply_register(struct device *parent, struct power_supply *psy)
success: success:
return rc; return rc;
} }
int power_supply_register(struct device *parent, struct power_supply *psy)
{
return __power_supply_register(parent, psy, true);
}
EXPORT_SYMBOL_GPL(power_supply_register); EXPORT_SYMBOL_GPL(power_supply_register);
int power_supply_register_no_ws(struct device *parent, struct power_supply *psy)
{
return __power_supply_register(parent, psy, false);
}
EXPORT_SYMBOL_GPL(power_supply_register_no_ws);
void power_supply_unregister(struct power_supply *psy) void power_supply_unregister(struct power_supply *psy)
{ {
cancel_work_sync(&psy->changed_work); cancel_work_sync(&psy->changed_work);
......
...@@ -264,6 +264,8 @@ static inline int power_supply_is_system_supplied(void) { return -ENOSYS; } ...@@ -264,6 +264,8 @@ static inline int power_supply_is_system_supplied(void) { return -ENOSYS; }
extern int power_supply_register(struct device *parent, extern int power_supply_register(struct device *parent,
struct power_supply *psy); struct power_supply *psy);
extern int power_supply_register_no_ws(struct device *parent,
struct power_supply *psy);
extern void power_supply_unregister(struct power_supply *psy); extern void power_supply_unregister(struct power_supply *psy);
extern int power_supply_powers(struct power_supply *psy, struct device *dev); extern int power_supply_powers(struct power_supply *psy, struct device *dev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment