@@ -468,6 +468,7 @@ extern void pm_wakep_autosleep_enabled(bool set);
extern void pm_print_active_wakeup_sources(void);
extern unsigned int lock_system_sleep(void);
+extern unsigned int trylock_system_sleep(void);
extern void unlock_system_sleep(unsigned int);
#else /* !CONFIG_PM_SLEEP */
@@ -496,6 +497,7 @@ static inline void pm_wakeup_clear(bool reset) {}
static inline void pm_system_irq_wakeup(unsigned int irq_number) {}
static inline unsigned int lock_system_sleep(void) { return 0; }
+static inline unsigned int trylock_system_sleep(void) { return 0; }
static inline void unlock_system_sleep(unsigned int flags) {}
#endif /* !CONFIG_PM_SLEEP */
@@ -1449,7 +1449,9 @@ static int hibernate_compressor_param_set(const char *compressor,
unsigned int sleep_flags;
int index, ret;
- sleep_flags = lock_system_sleep();
+ sleep_flags = trylock_system_sleep();
+ if (!sleep_flags)
+ return -EBUSY;
index = sysfs_match_string(comp_alg_enabled, compressor);
if (index >= 0) {
@@ -58,6 +58,18 @@ unsigned int lock_system_sleep(void)
}
EXPORT_SYMBOL_GPL(lock_system_sleep);
+unsigned int trylock_system_sleep(void)
+{
+ unsigned int flags = current->flags;
+ current->flags |= PF_NOFREEZE;
+ if (!mutex_trylock(&system_transition_mutex)) {
+ current->flags &= ~PF_NOFREEZE;
+ return 0;
+ }
+ return flags;
+}
+EXPORT_SYMBOL_GPL(trylock_system_sleep);
+
void unlock_system_sleep(unsigned int flags)
{
if (!(flags & PF_NOFREEZE))