diff options
| author | Bart Van Assche <bart.vanassche@wdc.com> | 2018-01-05 12:19:08 -0500 |
|---|---|---|
| committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2018-01-09 19:07:46 -0500 |
| commit | 4bf236a3330e97d275e5848420f7e31948fef07a (patch) | |
| tree | 0be93c72c34a05451c4fd8bdb9c57d84dd06720a /include/linux/suspend.h | |
| parent | bdbc98abb3aa323f6323b11db39c740e6f8fc5b1 (diff) | |
PM / sleep: Make lock/unlock_system_sleep() available to kernel modules
Since pm_mutex is not exported using lock/unlock_system_sleep() from
inside a kernel module causes a "pm_mutex undefined" linker error.
Hence move lock/unlock_system_sleep() into kernel/power/main.c and
export these.
Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'include/linux/suspend.h')
| -rw-r--r-- | include/linux/suspend.h | 28 |
1 files changed, 2 insertions, 26 deletions
diff --git a/include/linux/suspend.h b/include/linux/suspend.h index d60b0f5c38d5..cc22a24516d6 100644 --- a/include/linux/suspend.h +++ b/include/linux/suspend.h | |||
| @@ -443,32 +443,8 @@ extern bool pm_save_wakeup_count(unsigned int count); | |||
| 443 | extern void pm_wakep_autosleep_enabled(bool set); | 443 | extern void pm_wakep_autosleep_enabled(bool set); |
| 444 | extern void pm_print_active_wakeup_sources(void); | 444 | extern void pm_print_active_wakeup_sources(void); |
| 445 | 445 | ||
| 446 | static inline void lock_system_sleep(void) | 446 | extern void lock_system_sleep(void); |
| 447 | { | 447 | extern void unlock_system_sleep(void); |
| 448 | current->flags |= PF_FREEZER_SKIP; | ||
| 449 | mutex_lock(&pm_mutex); | ||
| 450 | } | ||
| 451 | |||
| 452 | static inline void unlock_system_sleep(void) | ||
| 453 | { | ||
| 454 | /* | ||
| 455 | * Don't use freezer_count() because we don't want the call to | ||
| 456 | * try_to_freeze() here. | ||
| 457 | * | ||
| 458 | * Reason: | ||
| 459 | * Fundamentally, we just don't need it, because freezing condition | ||
| 460 | * doesn't come into effect until we release the pm_mutex lock, | ||
| 461 | * since the freezer always works with pm_mutex held. | ||
| 462 | * | ||
| 463 | * More importantly, in the case of hibernation, | ||
| 464 | * unlock_system_sleep() gets called in snapshot_read() and | ||
| 465 | * snapshot_write() when the freezing condition is still in effect. | ||
| 466 | * Which means, if we use try_to_freeze() here, it would make them | ||
| 467 | * enter the refrigerator, thus causing hibernation to lockup. | ||
| 468 | */ | ||
| 469 | current->flags &= ~PF_FREEZER_SKIP; | ||
| 470 | mutex_unlock(&pm_mutex); | ||
| 471 | } | ||
| 472 | 448 | ||
| 473 | #else /* !CONFIG_PM_SLEEP */ | 449 | #else /* !CONFIG_PM_SLEEP */ |
| 474 | 450 | ||
