[PATCH] driver model wakeup flags
This is a refresh of an earlier patch to add "wakeup" support to the PM core model. This provides per-device bus-neutral control of the use of wakeup events. * "struct device_pm_info" has two bits that are initialized as part of setting up the enclosing struct device: - "can_wakeup", reflecting hardware capabilities - "may_wakeup", the policy setting (when CONFIG_PM) * There's a writeable sysfs "wakeup" file, with one of two values: - "enabled", when the policy is to allow wakeup - "disabled", when the policy is not to allow it - "" if the device can't currently issue wakeups By default, wakeup is enabled on all devices that support it. If its driver doesn't support it ... treat it as a bug. :) Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
2a7ff1feda
commit
0ac85241eb
@@ -219,7 +219,9 @@ typedef struct pm_message {
|
||||
|
||||
struct dev_pm_info {
|
||||
pm_message_t power_state;
|
||||
unsigned can_wakeup:1;
|
||||
#ifdef CONFIG_PM
|
||||
unsigned should_wakeup:1;
|
||||
pm_message_t prev_state;
|
||||
void * saved_state;
|
||||
atomic_t pm_users;
|
||||
@@ -236,13 +238,35 @@ extern void device_resume(void);
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
extern int device_suspend(pm_message_t state);
|
||||
#else
|
||||
|
||||
#define device_set_wakeup_enable(dev,val) \
|
||||
((dev)->power.should_wakeup = !!(val))
|
||||
#define device_may_wakeup(dev) \
|
||||
(device_can_wakeup(dev) && (dev)->power.should_wakeup)
|
||||
|
||||
#else /* !CONFIG_PM */
|
||||
|
||||
static inline int device_suspend(pm_message_t state)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define device_set_wakeup_enable(dev,val) do{}while(0)
|
||||
#define device_may_wakeup(dev) (0)
|
||||
|
||||
#endif
|
||||
|
||||
/* changes to device_may_wakeup take effect on the next pm state change.
|
||||
* by default, devices should wakeup if they can.
|
||||
*/
|
||||
#define device_can_wakeup(dev) \
|
||||
((dev)->power.can_wakeup)
|
||||
#define device_init_wakeup(dev,val) \
|
||||
do { \
|
||||
device_can_wakeup(dev) = !!(val); \
|
||||
device_set_wakeup_enable(dev,val); \
|
||||
} while(0)
|
||||
|
||||
#endif /* __KERNEL__ */
|
||||
|
||||
#endif /* _LINUX_PM_H */
|
||||
|
Reference in New Issue
Block a user