提交 ba4c6e55 编写于 作者: H Hongbo Yao 提交者: Yang Yingliang

PM / hibernate: introduce system_in_hibernation

hulk inclusion
category: bugfix
bugzilla: 26326
CVE: NA

-------------------------------------------------
Introduce boolean function system_in_hibernation() returning
'true' when the system carrying out hibernation.

Some device drivers or syscore need such a function to check
if it is in the phase of hibernation.
Signed-off-by: NHongbo Yao <yaohongbo@huawei.com>
Reviewed-by: NHanjun Guo <guohanjun@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 53091c2b
...@@ -414,6 +414,7 @@ extern asmlinkage int swsusp_arch_resume(void); ...@@ -414,6 +414,7 @@ extern asmlinkage int swsusp_arch_resume(void);
extern void hibernation_set_ops(const struct platform_hibernation_ops *ops); extern void hibernation_set_ops(const struct platform_hibernation_ops *ops);
extern int hibernate(void); extern int hibernate(void);
extern bool system_entering_hibernation(void); extern bool system_entering_hibernation(void);
extern bool system_in_hibernation(void);
extern bool hibernation_available(void); extern bool hibernation_available(void);
asmlinkage int swsusp_save(void); asmlinkage int swsusp_save(void);
extern struct pbe *restore_pblist; extern struct pbe *restore_pblist;
...@@ -427,6 +428,7 @@ static inline void swsusp_unset_page_free(struct page *p) {} ...@@ -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 void hibernation_set_ops(const struct platform_hibernation_ops *ops) {}
static inline int hibernate(void) { return -ENOSYS; } static inline int hibernate(void) { return -ENOSYS; }
static inline bool system_entering_hibernation(void) { return false; } 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; } static inline bool hibernation_available(void) { return false; }
#endif /* CONFIG_HIBERNATION */ #endif /* CONFIG_HIBERNATION */
......
...@@ -104,6 +104,15 @@ bool system_entering_hibernation(void) ...@@ -104,6 +104,15 @@ bool system_entering_hibernation(void)
} }
EXPORT_SYMBOL(system_entering_hibernation); 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 #ifdef CONFIG_PM_DEBUG
static void hibernation_debug_sleep(void) static void hibernation_debug_sleep(void)
{ {
...@@ -711,6 +720,7 @@ int hibernate(void) ...@@ -711,6 +720,7 @@ int hibernate(void)
} }
pr_info("hibernation entry\n"); pr_info("hibernation entry\n");
carry_out_hibernation = true;
pm_prepare_console(); pm_prepare_console();
error = __pm_notifier_call_chain(PM_HIBERNATION_PREPARE, -1, &nr_calls); error = __pm_notifier_call_chain(PM_HIBERNATION_PREPARE, -1, &nr_calls);
if (error) { if (error) {
...@@ -781,6 +791,7 @@ int hibernate(void) ...@@ -781,6 +791,7 @@ int hibernate(void)
atomic_inc(&snapshot_device_available); atomic_inc(&snapshot_device_available);
Unlock: Unlock:
unlock_system_sleep(); unlock_system_sleep();
carry_out_hibernation = false;
pr_info("hibernation exit\n"); pr_info("hibernation exit\n");
return error; return error;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册