PM: don't skip device PM init when CONFIG_PM_SLEEP isn't set and CONFIG_PM is set

This patch (as1124) fixes a couple of bugs in the PM core.  The new
dev->power.status field should be initialized regardless of whether
CONFIG_PM_SLEEP is enabled, and similarly dpm_sysfs_add() should be
called whenever CONFIG_PM is enabled.

The patch separates out the call to dpm_sysfs_add() from the call to
device_pm_add().  As a result device_pm_add() can no longer return an
error, so its return type is changed to void.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Tested-by: Romit Dasgupta <romit@ti.com>
Acked-by: Rafael J. Wysocki <rjw@sisk.pl>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
Alan Stern
2008-08-07 13:06:12 -04:00
committed by Greg Kroah-Hartman
parent 7c2250352e
commit 3b98aeaf3a
3 changed files with 16 additions and 15 deletions

View File

@ -67,10 +67,8 @@ void device_pm_unlock(void)
* device_pm_add - add a device to the list of active devices
* @dev: Device to be added to the list
*/
int device_pm_add(struct device *dev)
void device_pm_add(struct device *dev)
{
int error;
pr_debug("PM: Adding info for %s:%s\n",
dev->bus ? dev->bus->name : "No Bus",
kobject_name(&dev->kobj));
@ -89,13 +87,9 @@ int device_pm_add(struct device *dev)
*/
WARN_ON(true);
}
error = dpm_sysfs_add(dev);
if (!error) {
dev->power.status = DPM_ON;
list_add_tail(&dev->power.entry, &dpm_list);
}
list_add_tail(&dev->power.entry, &dpm_list);
mutex_unlock(&dpm_list_mtx);
return error;
}
/**
@ -110,7 +104,6 @@ void device_pm_remove(struct device *dev)
dev->bus ? dev->bus->name : "No Bus",
kobject_name(&dev->kobj));
mutex_lock(&dpm_list_mtx);
dpm_sysfs_remove(dev);
list_del_init(&dev->power.entry);
mutex_unlock(&dpm_list_mtx);
}

View File

@ -1,3 +1,8 @@
static inline void device_pm_init(struct device *dev)
{
dev->power.status = DPM_ON;
}
#ifdef CONFIG_PM_SLEEP
/*
@ -11,12 +16,12 @@ static inline struct device *to_device(struct list_head *entry)
return container_of(entry, struct device, power.entry);
}
extern int device_pm_add(struct device *);
extern void device_pm_add(struct device *);
extern void device_pm_remove(struct device *);
#else /* CONFIG_PM_SLEEP */
static inline int device_pm_add(struct device *dev) { return 0; }
static inline void device_pm_add(struct device *dev) {}
static inline void device_pm_remove(struct device *dev) {}
#endif