STRUCT PLATFORM_SUSPEND_OPS(9)
π NAME π
okay so welcome to the Kernel API Manual, section 9, page struct platform_suspend_ops(9) β bestie, this is literally the callback struct for managing platform-dependent system sleep states. the whole sleep-state situation is in here β¨
struct platform_suspend_ops β Callbacks for managing platform dependent system sleep states. π
π¦ SYNOPSIS π¦
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);
};
π Members π
okay so each one of these is a little callback bestie, and they all have a job. let's get into it π«Ά
validβ this one figures out if a given system sleep state is supported by the platform. valid (ie. supported) states are advertised in/sys/power/state. but lowkey note: it still may be impossible to enter a given system sleep state if the conditions aren't right π. also, there's thesuspend_valid_only_memfunction available that can be assigned to this if the platform only supports mem sleep.beginβ initialises a transition to the given system sleep state.beginis executed right prior to suspending devices. any information conveyed to the platform code bybeginshould be disregarded by it as soon asendis executed. ifbeginfails (ie. returns nonzero),prepare,enter, andfinishwill not be called by the PM core, periodt. this callback is optional. however, if it is implemented, the argument passed toenteris redundant and should be ignored. noted β¨prepareβ prepares the platform for entering the system sleep state indicated bybegin.prepareis called right after devices have been suspended (ie. the appropriate.suspendmethod has been executed for each device) and before device drivers' late suspend callbacks are executed. it returns0on success or a negative error code otherwise, in which case the system cannot enter the desired sleep state (prepare_late,enter, andwakewill not be called in that case). πprepare_lateβ finishes preparing the platform for entering the system sleep state indicated bybegin.prepare_lateis called before disabling nonboot CPUs and after device drivers' late suspend callbacks have been executed. it returns0on success or a negative error code otherwise, in which case the system cannot enter the desired sleep state andenterwill not be executed. no cap.enterβ enters the system sleep state indicated bybeginor represented by the argument ifbeginis not implemented. this callback is mandatory π. it returns0on success or a negative error code otherwise, in which case the system cannot enter the desired sleep state.wakeβ called when the system has just left a sleep state, right after the nonboot CPUs have been enabled and before device drivers' early resume callbacks are executed. this callback is optional, but should be implemented by the platforms that implementprepare_late. if implemented, it is always called afterprepare_lateandenter, even if one of them fails. the way that's so thorough β¨finishβ finishes wake-up of the platform.finishis called right prior to calling device drivers' regular suspend callbacks. this callback is optional, but should be implemented by the platforms that implementprepare. if implemented, it is always called afterenterandwake, even if any of them fails. it is executed after a failingprepare. okay werk πsuspend_againβ returns whether the system should suspend again (true) or not (false). if the platform wants to poll sensors or execute some code during suspended without invoking userspace and most of devices, thesuspend_againcallback is the place β assuming that periodic-wakeup or alarm-wakeup is already setup. this allows to execute some codes while being kept suspended in the view of userland and devices. iykyk π«Άendβ called by the PM core right after resuming devices, to indicate to the platform that the system has returned to the working state or the transition to the sleep state has been aborted. this callback is optional, but should be implemented by the platforms that implementbegin. accordingly, platforms implementingbeginshould also provide anendwhich cleans up transitions aborted beforeenter. don't skip this one bestie πrecoverβ recovers the platform from a suspend failure. called by the PM core if the suspending of devices fails. this callback is optional and should only be implemented by platforms which require special recovery actions in that situation. special circumstances only, fr fr.
π SEE ALSO π
Kernel file ./include/linux/suspend.h β then the whole squad: suspend_set_ops(9), pm_suspend_via_firmware(9), pm_resume_via_firmware(9), pm_suspend_no_platform(9), arch_suspend_disable_irqs(9), arch_suspend_enable_irqs(9), struct platform_hibernation_ops(9), pm_pr_dbg(9). go read those too, bestie π¦
this page comes from ./include/linux, dated October 2026, and it's all about struct platform_suspend_ops(9) β mwah π
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms