Commit 2d7681a4 authored by Patrick Mochel's avatar Patrick Mochel

[power] Split device PM functions

- Create drivers/base/power/
- Move drivers/base/power.c there.
- Split into shutdown.c suspend.c and resume.c
parent f670dfba
# Makefile for the Linux device tree
obj-y := core.o sys.o interface.o power.o bus.o \
obj-y := core.o sys.o interface.o bus.o \
driver.o class.o platform.o \
cpu.o firmware.o init.o map.o
obj-y += power/
obj-$(CONFIG_FW_LOADER) += firmware_class.o
obj-$(CONFIG_NUMA) += node.o memblk.o
obj-y := shutdown.o
obj-$(CONFIG_PM) += suspend.o resume.o
/*
* resume.c - Functions for waking devices up.
*
* Copyright (c) 2003 Patrick Mochel
* Copyright (c) 2003 Open Source Development Labs
*
* This file is released under the GPLv2
*
*/
#include <linux/device.h>
#define to_dev(node) container_of(node,struct device,kobj.entry)
extern struct subsystem devices_subsys;
extern int sysdev_resume(void);
extern int sysdev_restore(void);
/**
* device_resume - resume all the devices in the system
* @level: stage of resume process we're at
*
* Similar to device_suspend above, though we want to do a breadth-first
* walk of the tree to make sure we wake up parents before children.
* So, we iterate over the list backward.
*/
void device_resume(u32 level)
{
struct device * dev;
switch (level) {
case RESUME_POWER_ON:
sysdev_resume();
break;
case RESUME_RESTORE_STATE:
sysdev_restore();
break;
default:
break;
}
down_write(&devices_subsys.rwsem);
list_for_each_entry(dev,&devices_subsys.kset.list,kobj.entry) {
if (dev->driver && dev->driver->resume) {
pr_debug("resuming device %s\n",dev->name);
dev->driver->resume(dev,level);
}
}
up_write(&devices_subsys.rwsem);
}
/*
* shutdown.c - power management functions for the device tree.
*
* Copyright (c) 2002-3 Patrick Mochel
* 2002-3 Open Source Development Lab
*
* This file is released under the GPLv2
*
*/
#undef DEBUG
#include <linux/device.h>
#include <asm/semaphore.h>
#define to_dev(node) container_of(node,struct device,kobj.entry)
extern struct subsystem devices_subsys;
/**
* We handle system devices differently - we suspend and shut them
* down first and resume them first. That way, we do anything stupid like
* shutting down the interrupt controller before any devices..
*
* Note that there are not different stages for power management calls -
* they only get one called once when interrupts are disabled.
*/
extern int sysdev_shutdown(void);
/**
* device_shutdown - call ->remove() on each device to shutdown.
*/
void device_shutdown(void)
{
struct device * dev;
down_write(&devices_subsys.rwsem);
list_for_each_entry_reverse(dev,&devices_subsys.kset.list,kobj.entry) {
pr_debug("shutting down %s: ",dev->name);
if (dev->driver && dev->driver->shutdown) {
pr_debug("Ok\n");
dev->driver->shutdown(dev);
} else
pr_debug("Ignored.\n");
}
up_write(&devices_subsys.rwsem);
sysdev_shutdown();
}
/*
* power.c - power management functions for the device tree.
*
* Copyright (c) 2002-3 Patrick Mochel
* 2002-3 Open Source Development Lab
*
* suspend.c - Functions for putting devices to sleep.
*
* Copyright (c) 2003 Patrick Mochel
* Copyright (c) 2003 Open Source Development Labs
*
* This file is released under the GPLv2
*
* Kai Germaschewski contributed to the list walking routines.
*
*/
#undef DEBUG
#include <linux/device.h>
#include <linux/module.h>
#include <asm/semaphore.h>
#include "base.h"
#define to_dev(node) container_of(node,struct device,kobj.entry)
extern struct subsystem devices_subsys;
/**
* We handle system devices differently - we suspend and shut them
* down first and resume them first. That way, we do anything stupid like
* shutting down the interrupt controller before any devices..
*
* Note that there are not different stages for power management calls -
* they only get one called once when interrupts are disabled.
*/
extern int sysdev_shutdown(void);
extern int sysdev_save(u32 state);
extern int sysdev_suspend(u32 state);
extern int sysdev_resume(void);
extern int sysdev_restore(void);
/**
* device_suspend - suspend/remove all devices on the device ree
......@@ -81,60 +62,3 @@ int device_suspend(u32 state, u32 level)
return error;
}
/**
* device_resume - resume all the devices in the system
* @level: stage of resume process we're at
*
* Similar to device_suspend above, though we want to do a breadth-first
* walk of the tree to make sure we wake up parents before children.
* So, we iterate over the list backward.
*/
void device_resume(u32 level)
{
struct device * dev;
switch (level) {
case RESUME_POWER_ON:
sysdev_resume();
break;
case RESUME_RESTORE_STATE:
sysdev_restore();
break;
default:
break;
}
down_write(&devices_subsys.rwsem);
list_for_each_entry(dev,&devices_subsys.kset.list,kobj.entry) {
if (dev->driver && dev->driver->resume) {
pr_debug("resuming device %s\n",dev->name);
dev->driver->resume(dev,level);
}
}
up_write(&devices_subsys.rwsem);
}
/**
* device_shutdown - call ->remove() on each device to shutdown.
*/
void device_shutdown(void)
{
struct device * dev;
down_write(&devices_subsys.rwsem);
list_for_each_entry_reverse(dev,&devices_subsys.kset.list,kobj.entry) {
pr_debug("shutting down %s: ",dev->name);
if (dev->driver && dev->driver->shutdown) {
pr_debug("Ok\n");
dev->driver->shutdown(dev);
} else
pr_debug("Ignored.\n");
}
up_write(&devices_subsys.rwsem);
sysdev_shutdown();
}
EXPORT_SYMBOL(device_suspend);
EXPORT_SYMBOL(device_resume);
EXPORT_SYMBOL(device_shutdown);
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