Skip to content

Commit abfe2d7

Browse files
rjwysockiJeff Garzik
authored andcommitted
Hibernation: Introduce system_entering_hibernation
Introduce boolean function system_entering_hibernation() returning 'true' during the last phase of hibernation, in which devices are being put into low power states and the sleep state (for example, ACPI S4) is finally entered. Some device drivers need such a function to check if the system is in the final phase of hibernation. In particular, some SATA drivers are going to use it for blacklisting systems in which the disks should not be spun down during the last phase of hibernation (the BIOS will do that anyway). Signed-off-by: Rafael J. Wysocki <[email protected]> Signed-off-by: Jeff Garzik <[email protected]>
1 parent f3b8436 commit abfe2d7

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

include/linux/suspend.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ extern int hibernate_nvs_alloc(void);
237237
extern void hibernate_nvs_free(void);
238238
extern void hibernate_nvs_save(void);
239239
extern void hibernate_nvs_restore(void);
240+
extern bool system_entering_hibernation(void);
240241
#else /* CONFIG_HIBERNATION */
241242
static inline int swsusp_page_is_forbidden(struct page *p) { return 0; }
242243
static inline void swsusp_set_page_free(struct page *p) {}
@@ -252,6 +253,7 @@ static inline int hibernate_nvs_alloc(void) { return 0; }
252253
static inline void hibernate_nvs_free(void) {}
253254
static inline void hibernate_nvs_save(void) {}
254255
static inline void hibernate_nvs_restore(void) {}
256+
static inline bool system_entering_hibernation(void) { return false; }
255257
#endif /* CONFIG_HIBERNATION */
256258

257259
#ifdef CONFIG_PM_SLEEP

kernel/power/disk.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,14 @@ void hibernation_set_ops(struct platform_hibernation_ops *ops)
7171
mutex_unlock(&pm_mutex);
7272
}
7373

74+
static bool entering_platform_hibernation;
75+
76+
bool system_entering_hibernation(void)
77+
{
78+
return entering_platform_hibernation;
79+
}
80+
EXPORT_SYMBOL(system_entering_hibernation);
81+
7482
#ifdef CONFIG_PM_DEBUG
7583
static void hibernation_debug_sleep(void)
7684
{
@@ -411,6 +419,7 @@ int hibernation_platform_enter(void)
411419
if (error)
412420
goto Close;
413421

422+
entering_platform_hibernation = true;
414423
suspend_console();
415424
error = device_suspend(PMSG_HIBERNATE);
416425
if (error) {
@@ -445,6 +454,7 @@ int hibernation_platform_enter(void)
445454
Finish:
446455
hibernation_ops->finish();
447456
Resume_devices:
457+
entering_platform_hibernation = false;
448458
device_resume(PMSG_RESTORE);
449459
resume_console();
450460
Close:

0 commit comments

Comments
 (0)