/* * drivers/base/power/main.c - Where the driver meets power management. * * Copyright (c) 2003 Patrick Mochel * Copyright (c) 2003 Open Source Development Lab * * This file is released under the GPLv2 * * * The driver model core calls device_pm_add() when a device is registered. * This will initialize the embedded device_pm_info object in the device * and add it to the list of power-controlled devices. sysfs entries for * controlling device power management will also be added. * * A separate list is used for keeping track of power info, because the power * domain dependencies may differ from the ancestral dependencies that the * subsystem list maintains. */#include<linux/device.h>#include<linux/kallsyms.h>#include<linux/export.h>#include<linux/mutex.h>#include<linux/pm.h>#include<linux/pm_runtime.h>#include<linux/resume-trace.h>#include<linux/interrupt.h>#include<linux/sched.h>#include<linux/async.h>#include<linux/suspend.h>#include<trace/events/power.h>#include<linux/cpuidle.h>#include"../base.h"#include"power.h"typedefint(*pm_callback_t)(structdevice*);/* * The entries in the dpm_list list are in a depth first order, simply * because children are guaranteed to be discovered after parents, and * are inserted at the back of the list on discovery. * * Since device_pm_add() may be called with a device lock held, * we must never try to acquire a device lock while holding * dpm_list_mutex. */LIST_HEAD(dpm_list);staticLIST_HEAD(dpm_prepared_list);staticLIST_HEAD(dpm_suspended_list);staticLIST_HEAD(dpm_late_early_list);staticLIST_HEAD(dpm_noirq_list);structsuspend_statssuspend_stats;staticDEFINE_MUTEX(dpm_list_mtx);staticpm_message_tpm_transition;staticintasync_error;staticchar*pm_verb(intevent){switch(event){casePM_EVENT_SUSPEND:return"suspend";casePM_EVENT_RESUME:return"resume";casePM_EVENT_FREEZE:return"freeze";casePM_EVENT_QUIESCE:return"quiesce";casePM_EVENT_HIBERNATE:return"hibernate";casePM_EVENT_THAW:return"thaw";casePM_EVENT_RESTORE:return"restore";casePM_EVENT_RECOVER:return"recover";default:return"(unknown PM event)";}}/** * device_pm_sleep_init - Initialize system suspend-related device fields. * @dev: Device object being initialized. */voiddevice_pm_sleep_init(structdevice*dev){dev->power.is_prepared=false;dev->power.is_suspended=false;init_completion(&dev-&