Commit 2e711c04 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki

PM: Remove sysdev suspend, resume and shutdown operations

Since suspend, resume and shutdown operations in struct sysdev_class
and struct sysdev_driver are not used any more, remove them.  Also
drop sysdev_suspend(), sysdev_resume() and sysdev_shutdown() used
for executing those operations and modify all of their users
accordingly.  This reduces kernel code size quite a bit and reduces
its complexity.
Signed-off-by: default avatarRafael J. Wysocki <rjw@sisk.pl>
Acked-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent f5a592f7
......@@ -24,7 +24,6 @@ config SUPERH
select RTC_LIB
select GENERIC_ATOMIC64
select GENERIC_IRQ_SHOW
select ARCH_NO_SYSDEV_OPS
help
The SuperH is a RISC processor targeted for use in embedded systems
and consumer electronics; it was also used in the Sega Dreamcast
......
......@@ -71,7 +71,6 @@ config X86
select GENERIC_IRQ_SHOW
select IRQ_FORCED_THREADING
select USE_GENERIC_SMP_HELPERS if SMP
select ARCH_NO_SYSDEV_OPS
config INSTRUCTION_DECODER
def_bool (KPROBES || PERF_EVENTS)
......
......@@ -1238,7 +1238,6 @@ static int suspend(int vetoable)
dpm_suspend_noirq(PMSG_SUSPEND);
local_irq_disable();
sysdev_suspend(PMSG_SUSPEND);
syscore_suspend();
local_irq_enable();
......@@ -1258,7 +1257,6 @@ static int suspend(int vetoable)
err = (err == APM_SUCCESS) ? 0 : -EIO;
syscore_resume();
sysdev_resume();
local_irq_enable();
dpm_resume_noirq(PMSG_RESUME);
......@@ -1282,7 +1280,6 @@ static void standby(void)
dpm_suspend_noirq(PMSG_SUSPEND);
local_irq_disable();
sysdev_suspend(PMSG_SUSPEND);
syscore_suspend();
local_irq_enable();
......@@ -1292,7 +1289,6 @@ static void standby(void)
local_irq_disable();
syscore_resume();
sysdev_resume();
local_irq_enable();
dpm_resume_noirq(PMSG_RESUME);
......
......@@ -168,11 +168,4 @@ config SYS_HYPERVISOR
bool
default n
config ARCH_NO_SYSDEV_OPS
bool
---help---
To be selected by architectures that don't use sysdev class or
sysdev driver power management (suspend/resume) and shutdown
operations.
endmenu
......@@ -111,8 +111,6 @@ static inline int driver_match_device(struct device_driver *drv,
return drv->bus->match ? drv->bus->match(dev, drv) : 1;
}
extern void sysdev_shutdown(void);
extern char *make_class_name(const char *name, struct kobject *kobj);
extern int devres_release_all(struct device *dev);
......
......@@ -328,203 +328,8 @@ void sysdev_unregister(struct sys_device *sysdev)
kobject_put(&sysdev->kobj);
}
#ifndef CONFIG_ARCH_NO_SYSDEV_OPS
/**
* sysdev_shutdown - Shut down all system devices.
*
* Loop over each class of system devices, and the devices in each
* of those classes. For each device, we call the shutdown method for
* each driver registered for the device - the auxiliaries,
* and the class driver.
*
* Note: The list is iterated in reverse order, so that we shut down
* child devices before we shut down their parents. The list ordering
* is guaranteed by virtue of the fact that child devices are registered
* after their parents.
*/
void sysdev_shutdown(void)
{
struct sysdev_class *cls;
pr_debug("Shutting Down System Devices\n");
mutex_lock(&sysdev_drivers_lock);
list_for_each_entry_reverse(cls, &system_kset->list, kset.kobj.entry) {
struct sys_device *sysdev;
pr_debug("Shutting down type '%s':\n",
kobject_name(&cls->kset.kobj));
list_for_each_entry(sysdev, &cls->kset.list, kobj.entry) {
struct sysdev_driver *drv;
pr_debug(" %s\n", kobject_name(&sysdev->kobj));
/* Call auxiliary drivers first */
list_for_each_entry(drv, &cls->drivers, entry) {
if (drv->shutdown)
drv->shutdown(sysdev);
}
/* Now call the generic one */
if (cls->shutdown)
cls->shutdown(sysdev);
}
}
mutex_unlock(&sysdev_drivers_lock);
}
static void __sysdev_resume(struct sys_device *dev)
{
struct sysdev_class *cls = dev->cls;
struct sysdev_driver *drv;
/* First, call the class-specific one */
if (cls->resume)
cls->resume(dev);
WARN_ONCE(!irqs_disabled(),
"Interrupts enabled after %pF\n", cls->resume);
/* Call auxiliary drivers next. */
list_for_each_entry(drv, &cls->drivers, entry) {
if (drv->resume)
drv->resume(dev);
WARN_ONCE(!irqs_disabled(),
"Interrupts enabled after %pF\n", drv->resume);
}
}
/**
* sysdev_suspend - Suspend all system devices.
* @state: Power state to enter.
*
* We perform an almost identical operation as sysdev_shutdown()
* above, though calling ->suspend() instead. Interrupts are disabled
* when this called. Devices are responsible for both saving state and
* quiescing or powering down the device.
*
* This is only called by the device PM core, so we let them handle
* all synchronization.
*/
int sysdev_suspend(pm_message_t state)
{
struct sysdev_class *cls;
struct sys_device *sysdev, *err_dev;
struct sysdev_driver *drv, *err_drv;
int ret;
pr_debug("Checking wake-up interrupts\n");
/* Return error code if there are any wake-up interrupts pending */
ret = check_wakeup_irqs();
if (ret)
return ret;
WARN_ONCE(!irqs_disabled(),
"Interrupts enabled while suspending system devices\n");
pr_debug("Suspending System Devices\n");
list_for_each_entry_reverse(cls, &system_kset->list, kset.kobj.entry) {
pr_debug("Suspending type '%s':\n",
kobject_name(&cls->kset.kobj));
list_for_each_entry(sysdev, &cls->kset.list, kobj.entry) {
pr_debug(" %s\n", kobject_name(&sysdev->kobj));
/* Call auxiliary drivers first */
list_for_each_entry(drv, &cls->drivers, entry) {
if (drv->suspend) {
ret = drv->suspend(sysdev, state);
if (ret)
goto aux_driver;
}
WARN_ONCE(!irqs_disabled(),
"Interrupts enabled after %pF\n",
drv->suspend);
}
/* Now call the generic one */
if (cls->suspend) {
ret = cls->suspend(sysdev, state);
if (ret)
goto cls_driver;
WARN_ONCE(!irqs_disabled(),
"Interrupts enabled after %pF\n",
cls->suspend);
}
}
}
return 0;
/* resume current sysdev */
cls_driver:
drv = NULL;
printk(KERN_ERR "Class suspend failed for %s: %d\n",
kobject_name(&sysdev->kobj), ret);
aux_driver:
if (drv)
printk(KERN_ERR "Class driver suspend failed for %s: %d\n",
kobject_name(&sysdev->kobj), ret);
list_for_each_entry(err_drv, &cls->drivers, entry) {
if (err_drv == drv)
break;
if (err_drv->resume)
err_drv->resume(sysdev);
}
/* resume other sysdevs in current class */
list_for_each_entry(err_dev, &cls->kset.list, kobj.entry) {
if (err_dev == sysdev)
break;
pr_debug(" %s\n", kobject_name(&err_dev->kobj));
__sysdev_resume(err_dev);
}
/* resume other classes */
list_for_each_entry_continue(cls, &system_kset->list, kset.kobj.entry) {
list_for_each_entry(err_dev, &cls->kset.list, kobj.entry) {
pr_debug(" %s\n", kobject_name(&err_dev->kobj));
__sysdev_resume(err_dev);
}
}
return ret;
}
EXPORT_SYMBOL_GPL(sysdev_suspend);
/**
* sysdev_resume - Bring system devices back to life.
*
* Similar to sysdev_suspend(), but we iterate the list forwards
* to guarantee that parent devices are resumed before their children.
*
* Note: Interrupts are disabled when called.
*/
int sysdev_resume(void)
{
struct sysdev_class *cls;
WARN_ONCE(!irqs_disabled(),
"Interrupts enabled while resuming system devices\n");
pr_debug("Resuming System Devices\n");
list_for_each_entry(cls, &system_kset->list, kset.kobj.entry) {
struct sys_device *sysdev;
pr_debug("Resuming type '%s':\n",
kobject_name(&cls->kset.kobj));
list_for_each_entry(sysdev, &cls->kset.list, kobj.entry) {
pr_debug(" %s\n", kobject_name(&sysdev->kobj));
__sysdev_resume(sysdev);
}
}
return 0;
}
EXPORT_SYMBOL_GPL(sysdev_resume);
#endif /* CONFIG_ARCH_NO_SYSDEV_OPS */
EXPORT_SYMBOL_GPL(sysdev_register);
EXPORT_SYMBOL_GPL(sysdev_unregister);
int __init system_bus_init(void)
{
......@@ -534,9 +339,6 @@ int __init system_bus_init(void)
return 0;
}
EXPORT_SYMBOL_GPL(sysdev_register);
EXPORT_SYMBOL_GPL(sysdev_unregister);
#define to_ext_attr(x) container_of(x, struct sysdev_ext_attribute, attr)
ssize_t sysdev_store_ulong(struct sys_device *sysdev,
......
......@@ -70,12 +70,7 @@ static int xen_suspend(void *data)
BUG_ON(!irqs_disabled());
err = sysdev_suspend(PMSG_FREEZE);
if (!err) {
err = syscore_suspend();
if (err)
sysdev_resume();
}
if (err) {
printk(KERN_ERR "xen_suspend: system core suspend failed: %d\n",
err);
......@@ -102,7 +97,6 @@ static int xen_suspend(void *data)
}
syscore_resume();
sysdev_resume();
return 0;
}
......
......@@ -633,13 +633,6 @@ static inline int devtmpfs_mount(const char *mountpoint) { return 0; }
/* drivers/base/power/shutdown.c */
extern void device_shutdown(void);
#ifndef CONFIG_ARCH_NO_SYSDEV_OPS
/* drivers/base/sys.c */
extern void sysdev_shutdown(void);
#else
static inline void sysdev_shutdown(void) { }
#endif
/* debugging and troubleshooting/diagnostic helpers. */
extern const char *dev_driver_string(const struct device *dev);
......
......@@ -529,14 +529,6 @@ struct dev_power_domain {
*/
#ifdef CONFIG_PM_SLEEP
#ifndef CONFIG_ARCH_NO_SYSDEV_OPS
extern int sysdev_suspend(pm_message_t state);
extern int sysdev_resume(void);
#else
static inline int sysdev_suspend(pm_message_t state) { return 0; }
static inline int sysdev_resume(void) { return 0; }
#endif
extern void device_pm_lock(void);
extern void dpm_resume_noirq(pm_message_t state);
extern void dpm_resume_end(pm_message_t state);
......
......@@ -34,12 +34,6 @@ struct sysdev_class {
struct list_head drivers;
struct sysdev_class_attribute **attrs;
struct kset kset;
#ifndef CONFIG_ARCH_NO_SYSDEV_OPS
/* Default operations for these types of devices */
int (*shutdown)(struct sys_device *);
int (*suspend)(struct sys_device *, pm_message_t state);
int (*resume)(struct sys_device *);
#endif
};
struct sysdev_class_attribute {
......@@ -77,11 +71,6 @@ struct sysdev_driver {
struct list_head entry;
int (*add)(struct sys_device *);
int (*remove)(struct sys_device *);
#ifndef CONFIG_ARCH_NO_SYSDEV_OPS
int (*shutdown)(struct sys_device *);
int (*suspend)(struct sys_device *, pm_message_t state);
int (*resume)(struct sys_device *);
#endif
};
......
......@@ -1531,13 +1531,7 @@ int kernel_kexec(void)
if (error)
goto Enable_cpus;
local_irq_disable();
/* Suspend system devices */
error = sysdev_suspend(PMSG_FREEZE);
if (!error) {
error = syscore_suspend();
if (error)
sysdev_resume();
}
if (error)
goto Enable_irqs;
} else
......@@ -1553,7 +1547,6 @@ int kernel_kexec(void)
#ifdef CONFIG_KEXEC_JUMP
if (kexec_image->preserve_context) {
syscore_resume();
sysdev_resume();
Enable_irqs:
local_irq_enable();
Enable_cpus:
......
......@@ -272,12 +272,7 @@ static int create_image(int platform_mode)
local_irq_disable();
error = sysdev_suspend(PMSG_FREEZE);
if (!error) {
error = syscore_suspend();
if (error)
sysdev_resume();
}
if (error) {
printk(KERN_ERR "PM: Some system devices failed to power down, "
"aborting hibernation\n");
......@@ -302,7 +297,6 @@ static int create_image(int platform_mode)
Power_up:
syscore_resume();
sysdev_resume();
/* NOTE: dpm_resume_noirq() is just a resume() for devices
* that suspended with irqs off ... no overall powerup.
*/
......@@ -409,12 +403,7 @@ static int resume_target_kernel(bool platform_mode)
local_irq_disable();
error = sysdev_suspend(PMSG_QUIESCE);
if (!error) {
error = syscore_suspend();
if (error)
sysdev_resume();
}
if (error)
goto Enable_irqs;
......@@ -442,7 +431,6 @@ static int resume_target_kernel(bool platform_mode)
touch_softlockup_watchdog();
syscore_resume();
sysdev_resume();
Enable_irqs:
local_irq_enable();
......@@ -528,7 +516,6 @@ int hibernation_platform_enter(void)
goto Platform_finish;
local_irq_disable();
sysdev_suspend(PMSG_HIBERNATE);
syscore_suspend();
if (pm_wakeup_pending()) {
error = -EAGAIN;
......@@ -541,7 +528,6 @@ int hibernation_platform_enter(void)
Power_up:
syscore_resume();
sysdev_resume();
local_irq_enable();
enable_nonboot_cpus();
......
......@@ -163,19 +163,13 @@ static int suspend_enter(suspend_state_t state)
arch_suspend_disable_irqs();
BUG_ON(!irqs_disabled());
error = sysdev_suspend(PMSG_SUSPEND);
if (!error) {
error = syscore_suspend();
if (error)
sysdev_resume();
}
if (!error) {
if (!(suspend_test(TEST_CORE) || pm_wakeup_pending())) {
error = suspend_ops->enter(state);
events_check_enabled = false;
}
syscore_resume();
sysdev_resume();
}
arch_suspend_enable_irqs();
......
......@@ -315,7 +315,6 @@ void kernel_restart_prepare(char *cmd)
blocking_notifier_call_chain(&reboot_notifier_list, SYS_RESTART, cmd);
system_state = SYSTEM_RESTART;
device_shutdown();
sysdev_shutdown();
syscore_shutdown();
}
......@@ -354,7 +353,6 @@ static void kernel_shutdown_prepare(enum system_states state)
void kernel_halt(void)
{
kernel_shutdown_prepare(SYSTEM_HALT);
sysdev_shutdown();
syscore_shutdown();
printk(KERN_EMERG "System halted.\n");
kmsg_dump(KMSG_DUMP_HALT);
......@@ -374,7 +372,6 @@ void kernel_power_off(void)
if (pm_power_off_prepare)
pm_power_off_prepare();
disable_nonboot_cpus();
sysdev_shutdown();
syscore_shutdown();
printk(KERN_EMERG "Power down.\n");
kmsg_dump(KMSG_DUMP_POWEROFF);
......
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