2007-07-29 14:27:18 -07:00
|
|
|
#ifdef CONFIG_PM_SLEEP
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* main.c
|
|
|
|
*/
|
|
|
|
|
2007-09-21 12:36:56 -07:00
|
|
|
extern struct list_head dpm_active; /* 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
|
|
|
}
|
|
|
|
|
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
|
|
|
extern int device_pm_add(struct device *);
|
2005-04-16 15:20:36 -07:00
|
|
|
extern void device_pm_remove(struct device *);
|
|
|
|
|
2007-11-21 15:55:18 -07:00
|
|
|
#else /* CONFIG_PM_SLEEP */
|
|
|
|
|
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 int device_pm_add(struct device *dev) { return 0; }
|
|
|
|
static inline void device_pm_remove(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
|