2008-08-07 10:06:12 -07:00
|
|
|
static inline void device_pm_init(struct device *dev)
|
|
|
|
{
|
|
|
|
dev->power.status = DPM_ON;
|
|
|
|
}
|
|
|
|
|
2007-07-29 14:27:18 -07:00
|
|
|
#ifdef CONFIG_PM_SLEEP
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* main.c
|
|
|
|
*/
|
|
|
|
|
Introduce new top level suspend and hibernation callbacks
Introduce 'struct pm_ops' and 'struct pm_ext_ops' ('ext' meaning
'extended') representing suspend and hibernation operations for bus
types, device classes, device types and device drivers.
Modify the PM core to use 'struct pm_ops' and 'struct pm_ext_ops'
objects, if defined, instead of the ->suspend(), ->resume(),
->suspend_late(), and ->resume_early() callbacks (the old callbacks
will be considered as legacy and gradually phased out).
The main purpose of doing this is to separate suspend (aka S2RAM and
standby) callbacks from hibernation callbacks in such a way that the
new callbacks won't take arguments and the semantics of each of them
will be clearly specified. This has been requested for multiple
times by many people, including Linus himself, and the reason is that
within the current scheme if ->resume() is called, for example, it's
difficult to say why it's been called (ie. is it a resume from RAM or
from hibernation or a suspend/hibernation failure etc.?).
The second purpose is to make the suspend/hibernation callbacks more
flexible so that device drivers can handle more than they can within
the current scheme. For example, some drivers may need to prevent
new children of the device from being registered before their
->suspend() callbacks are executed or they may want to carry out some
operations requiring the availability of some other devices, not
directly bound via the parent-child relationship, in order to prepare
for the execution of ->suspend(), etc.
Ultimately, we'd like to stop using the freezing of tasks for suspend
and therefore the drivers' suspend/hibernation code will have to take
care of the handling of the user space during suspend/hibernation.
That, in turn, would be difficult within the current scheme, without
the new ->prepare() and ->complete() callbacks.
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
2008-05-20 14:00:01 -07:00
|
|
|
extern struct list_head dpm_list; /* The active device list */
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2007-11-21 15:55:18 -07:00
|
|
|
static inline struct device *to_device(struct list_head *entry)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
2007-09-21 12:36:56 -07:00
|
|
|
return container_of(entry, struct device, power.entry);
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
2008-08-07 10:06:12 -07:00
|
|
|
extern void device_pm_add(struct device *);
|
2005-04-16 15:20:36 -07:00
|
|
|
extern void device_pm_remove(struct device *);
|
2009-03-04 04:44:00 -07:00
|
|
|
extern void device_pm_move_before(struct device *, struct device *);
|
|
|
|
extern void device_pm_move_after(struct device *, struct device *);
|
|
|
|
extern void device_pm_move_last(struct device *);
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2007-11-21 15:55:18 -07:00
|
|
|
#else /* CONFIG_PM_SLEEP */
|
|
|
|
|
2008-08-07 10:06:12 -07:00
|
|
|
static inline void device_pm_add(struct device *dev) {}
|
PM: Handle device registrations during suspend/resume
Modify the PM core to protect its data structures, specifically the
dpm_active list, from being corrupted if a child of the currently
suspending device is registered concurrently with its ->suspend()
callback. In that case, since the new device (the child) is added
to dpm_active after its parent, the PM core will attempt to
suspend it after the parent, which is wrong.
Introduce a new member of struct dev_pm_info, called 'sleeping',
and use it to check if the parent of the device being added to
dpm_active has been suspended, in which case the device registration
fails. Also, use 'sleeping' for checking if the ordering of devices
on dpm_active is correct.
Introduce variable 'all_sleeping' that will be set to 'true' once all
devices have been suspended and make new device registrations fail
until 'all_sleeping' is reset to 'false', in order to avoid having
unsuspended devices around while the system is going into a sleep state.
Remove pm_sleep_rwsem which is not necessary any more.
Special thanks to Alan Stern for discussions and suggestions that
lead to the creation of this patch.
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2008-03-11 16:57:22 -07:00
|
|
|
static inline void device_pm_remove(struct device *dev) {}
|
2009-03-04 04:44:00 -07:00
|
|
|
static inline void device_pm_move_before(struct device *deva,
|
|
|
|
struct device *devb) {}
|
|
|
|
static inline void device_pm_move_after(struct device *deva,
|
|
|
|
struct device *devb) {}
|
|
|
|
static inline void device_pm_move_last(struct device *dev) {}
|
2008-01-12 12:40:46 -07:00
|
|
|
|
2007-11-21 15:55:18 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_PM
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
/*
|
|
|
|
* sysfs.c
|
|
|
|
*/
|
|
|
|
|
|
|
|
extern int dpm_sysfs_add(struct device *);
|
|
|
|
extern void dpm_sysfs_remove(struct device *);
|
|
|
|
|
2007-11-21 15:55:18 -07:00
|
|
|
#else /* CONFIG_PM */
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2007-11-21 15:55:18 -07:00
|
|
|
static inline int dpm_sysfs_add(struct device *dev)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-11-21 15:55:18 -07:00
|
|
|
static inline void dpm_sysfs_remove(struct device *dev)
|
|
|
|
{
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|