diff --git a/include/linux/suspend.h b/include/linux/suspend.h index 50e81bff37df53962f687b696debb914a10d9316..aff24892583d2e46b0b716e47f52071f71036050 100644 --- a/include/linux/suspend.h +++ b/include/linux/suspend.h @@ -414,6 +414,7 @@ extern asmlinkage int swsusp_arch_resume(void); extern void hibernation_set_ops(const struct platform_hibernation_ops *ops); extern int hibernate(void); extern bool system_entering_hibernation(void); +extern bool system_in_hibernation(void); extern bool hibernation_available(void); asmlinkage int swsusp_save(void); extern struct pbe *restore_pblist; @@ -427,6 +428,7 @@ static inline void swsusp_unset_page_free(struct page *p) {} static inline void hibernation_set_ops(const struct platform_hibernation_ops *ops) {} static inline int hibernate(void) { return -ENOSYS; } static inline bool system_entering_hibernation(void) { return false; } +static inline bool system_in_hibernation(void) { return false; } static inline bool hibernation_available(void) { return false; } #endif /* CONFIG_HIBERNATION */ diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c index f5ce9f7ec132d3aab21103ec60c9e74ccce60aff..72ef9df2a29cde448f4dba6e19f4443c9ac8c4f4 100644 --- a/kernel/power/hibernate.c +++ b/kernel/power/hibernate.c @@ -104,6 +104,15 @@ bool system_entering_hibernation(void) } EXPORT_SYMBOL(system_entering_hibernation); +/* To let some devices or syscore know if system carrying out hibernation*/ +static bool carry_out_hibernation; + +bool system_in_hibernation(void) +{ + return carry_out_hibernation; +} +EXPORT_SYMBOL(system_in_hibernation); + #ifdef CONFIG_PM_DEBUG static void hibernation_debug_sleep(void) { @@ -711,6 +720,7 @@ int hibernate(void) } pr_info("hibernation entry\n"); + carry_out_hibernation = true; pm_prepare_console(); error = __pm_notifier_call_chain(PM_HIBERNATION_PREPARE, -1, &nr_calls); if (error) { @@ -781,6 +791,7 @@ int hibernate(void) atomic_inc(&snapshot_device_available); Unlock: unlock_system_sleep(); + carry_out_hibernation = false; pr_info("hibernation exit\n"); return error;