Skip to content

Commit 495c8d3

Browse files
superm1rafaeljw
authored andcommitted
PM: hibernate: Add pm_hibernation_mode_is_suspend()
Some drivers have different flows for hibernation and suspend. If the driver opportunistically will skip thaw() then it needs a hint to know what is happening after the hibernate. Introduce a new symbol pm_hibernation_mode_is_suspend() that drivers can call to determine if suspending the system for this purpose. Tested-by: Ionut Nechita <ionut_n2001@yahoo.com> Tested-by: Kenneth Crudup <kenny@panix.com> Acked-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Mario Limonciello (AMD) <superm1@kernel.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 469d80a commit 495c8d3

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

include/linux/suspend.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ extern void arch_suspend_enable_irqs(void);
276276

277277
extern int pm_suspend(suspend_state_t state);
278278
extern bool sync_on_suspend_enabled;
279+
bool pm_hibernation_mode_is_suspend(void);
279280
#else /* !CONFIG_SUSPEND */
280281
#define suspend_valid_only_mem NULL
281282

@@ -288,6 +289,7 @@ static inline bool pm_suspend_via_firmware(void) { return false; }
288289
static inline bool pm_resume_via_firmware(void) { return false; }
289290
static inline bool pm_suspend_no_platform(void) { return false; }
290291
static inline bool pm_suspend_default_s2idle(void) { return false; }
292+
static inline bool pm_hibernation_mode_is_suspend(void) { return false; }
291293

292294
static inline void suspend_set_ops(const struct platform_suspend_ops *ops) {}
293295
static inline int pm_suspend(suspend_state_t state) { return -ENOSYS; }

kernel/power/hibernate.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,17 @@ static const struct platform_hibernation_ops *hibernation_ops;
8080

8181
static atomic_t hibernate_atomic = ATOMIC_INIT(1);
8282

83+
#ifdef CONFIG_SUSPEND
84+
/**
85+
* pm_hibernation_mode_is_suspend - Check if hibernation has been set to suspend
86+
*/
87+
bool pm_hibernation_mode_is_suspend(void)
88+
{
89+
return hibernation_mode == HIBERNATION_SUSPEND;
90+
}
91+
EXPORT_SYMBOL_GPL(pm_hibernation_mode_is_suspend);
92+
#endif
93+
8394
bool hibernate_acquire(void)
8495
{
8596
return atomic_add_unless(&hibernate_atomic, -1, 0);

0 commit comments

Comments
 (0)