include/linux/suspend.h

Source file repositories/reference/linux-study-clean/include/linux/suspend.h

File Facts

System
Linux kernel
Corpus path
include/linux/suspend.h
Extension
.h
Size
21820 bytes
Lines
608
Domain
Core OS
Bucket
Core Kernel Interface
Inferred role
Core OS: implementation source
Status
source implementation candidate

Why This File Exists

Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.

Dependency Surface

Detected Declarations

Annotated Snippet

struct platform_suspend_ops {
	int (*valid)(suspend_state_t state);
	int (*begin)(suspend_state_t state);
	int (*prepare)(void);
	int (*prepare_late)(void);
	int (*enter)(suspend_state_t state);
	void (*wake)(void);
	void (*finish)(void);
	bool (*suspend_again)(void);
	void (*end)(void);
	void (*recover)(void);
};

struct platform_s2idle_ops {
	int (*begin)(void);
	int (*prepare)(void);
	int (*prepare_late)(void);
	void (*check)(void);
	bool (*wake)(void);
	void (*restore_early)(void);
	void (*restore)(void);
	void (*end)(void);
};

#ifdef CONFIG_SUSPEND
extern suspend_state_t pm_suspend_target_state;
extern suspend_state_t mem_sleep_current;
extern suspend_state_t mem_sleep_default;

/**
 * suspend_set_ops - set platform dependent suspend operations
 * @ops: The new suspend operations to set.
 */
extern void suspend_set_ops(const struct platform_suspend_ops *ops);
extern int suspend_valid_only_mem(suspend_state_t state);

extern unsigned int pm_suspend_global_flags;

#define PM_SUSPEND_FLAG_FW_SUSPEND	BIT(0)
#define PM_SUSPEND_FLAG_FW_RESUME	BIT(1)
#define PM_SUSPEND_FLAG_NO_PLATFORM	BIT(2)

static inline void pm_suspend_clear_flags(void)
{
	pm_suspend_global_flags = 0;
}

static inline void pm_set_suspend_via_firmware(void)
{
	pm_suspend_global_flags |= PM_SUSPEND_FLAG_FW_SUSPEND;
}

static inline void pm_set_resume_via_firmware(void)
{
	pm_suspend_global_flags |= PM_SUSPEND_FLAG_FW_RESUME;
}

static inline void pm_set_suspend_no_platform(void)
{
	pm_suspend_global_flags |= PM_SUSPEND_FLAG_NO_PLATFORM;
}

/**
 * pm_suspend_via_firmware - Check if platform firmware will suspend the system.
 *
 * To be called during system-wide power management transitions to sleep states
 * or during the subsequent system-wide transitions back to the working state.
 *
 * Return 'true' if the platform firmware is going to be invoked at the end of
 * the system-wide power management transition (to a sleep state) in progress in
 * order to complete it, or if the platform firmware has been invoked in order
 * to complete the last (or preceding) transition of the system to a sleep
 * state.
 *
 * This matters if the caller needs or wants to carry out some special actions
 * depending on whether or not control will be passed to the platform firmware
 * subsequently (for example, the device may need to be reset before letting the
 * platform firmware manipulate it, which is not necessary when the platform
 * firmware is not going to be invoked) or when such special actions may have
 * been carried out during the preceding transition of the system to a sleep
 * state (as they may need to be taken into account).
 */
static inline bool pm_suspend_via_firmware(void)
{
	return !!(pm_suspend_global_flags & PM_SUSPEND_FLAG_FW_SUSPEND);
}

/**
 * pm_resume_via_firmware - Check if platform firmware has woken up the system.
 *

Annotation

Implementation Notes