Skip to content

Commit

Permalink
PM: Remove sysdev suspend, resume and shutdown operations
Browse files Browse the repository at this point in the history
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: Rafael J. Wysocki <rjw@sisk.pl>
Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
rjwysocki committed May 11, 2011
1 parent f5a592f commit 2e711c0
Show file tree
Hide file tree
Showing 14 changed files with 7 additions and 282 deletions.
1 change: 0 additions & 1 deletion arch/sh/Kconfig
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion arch/x86/Kconfig
Expand Up @@ -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)
Expand Down
4 changes: 0 additions & 4 deletions arch/x86/kernel/apm_32.c
Expand Up @@ -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();
Expand All @@ -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);
Expand All @@ -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();

Expand All @@ -1292,7 +1289,6 @@ static void standby(void)

local_irq_disable();
syscore_resume();
sysdev_resume();
local_irq_enable();

dpm_resume_noirq(PMSG_RESUME);
Expand Down
7 changes: 0 additions & 7 deletions drivers/base/Kconfig
Expand Up @@ -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
2 changes: 0 additions & 2 deletions drivers/base/base.h
Expand Up @@ -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);
Expand Down
202 changes: 2 additions & 200 deletions drivers/base/sys.c
Expand Up @@ -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)
{
Expand All @@ -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,
Expand Down
8 changes: 1 addition & 7 deletions drivers/xen/manage.c
Expand Up @@ -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();
}
err = syscore_suspend();
if (err) {
printk(KERN_ERR "xen_suspend: system core suspend failed: %d\n",
err);
Expand All @@ -102,7 +97,6 @@ static int xen_suspend(void *data)
}

syscore_resume();
sysdev_resume();

return 0;
}
Expand Down
7 changes: 0 additions & 7 deletions include/linux/device.h
Expand Up @@ -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);

Expand Down
8 changes: 0 additions & 8 deletions include/linux/pm.h
Expand Up @@ -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);
Expand Down
11 changes: 0 additions & 11 deletions include/linux/sysdev.h
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
};


Expand Down
9 changes: 1 addition & 8 deletions kernel/kexec.c
Expand Up @@ -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();
}
error = syscore_suspend();
if (error)
goto Enable_irqs;
} else
Expand All @@ -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:
Expand Down

0 comments on commit 2e711c0

Please sign in to comment.