Skip to content

Commit f5c0ecf

Browse files
committed
PM: sleep: Introduce pm_sleep_transition_in_progress()
The "suspend in progress" check in device_wakeup_enable() does not cover hibernation, but arguably it should do that, so introduce pm_sleep_transition_in_progress() covering transitions during both system suspend and hibernation to use in there and use it also in pm_debug_messages_should_print(). Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Reviewed-by: Mario Limonciello <mario.limonciello@amd.com> Link: https://patch.msgid.link/7820474.EvYhyI6sBW@rjwysocki.net [ rjw: Move the new function definition under CONFIG_PM_SLEEP ] Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 34a364f commit f5c0ecf

3 files changed

Lines changed: 10 additions & 3 deletions

File tree

drivers/base/power/wakeup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ int device_wakeup_enable(struct device *dev)
337337
if (!dev || !dev->power.can_wakeup)
338338
return -EINVAL;
339339

340-
if (pm_suspend_in_progress())
340+
if (pm_sleep_transition_in_progress())
341341
dev_dbg(dev, "Suspicious %s() during system transition!\n", __func__);
342342

343343
ws = wakeup_source_register(dev, dev_name(dev));

include/linux/suspend.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,8 @@ extern void pm_print_active_wakeup_sources(void);
475475
extern unsigned int lock_system_sleep(void);
476476
extern void unlock_system_sleep(unsigned int);
477477

478+
extern bool pm_sleep_transition_in_progress(void);
479+
478480
#else /* !CONFIG_PM_SLEEP */
479481

480482
static inline int register_pm_notifier(struct notifier_block *nb)
@@ -503,6 +505,8 @@ static inline void pm_system_irq_wakeup(unsigned int irq_number) {}
503505
static inline unsigned int lock_system_sleep(void) { return 0; }
504506
static inline void unlock_system_sleep(unsigned int flags) {}
505507

508+
static inline bool pm_sleep_transition_in_progress(void) { return false; }
509+
506510
#endif /* !CONFIG_PM_SLEEP */
507511

508512
#ifdef CONFIG_PM_SLEEP_DEBUG

kernel/power/main.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,10 @@ static int __init pm_debugfs_init(void)
557557
late_initcall(pm_debugfs_init);
558558
#endif /* CONFIG_DEBUG_FS */
559559

560+
bool pm_sleep_transition_in_progress(void)
561+
{
562+
return pm_suspend_in_progress() || hibernation_in_progress();
563+
}
560564
#endif /* CONFIG_PM_SLEEP */
561565

562566
#ifdef CONFIG_PM_SLEEP_DEBUG
@@ -613,8 +617,7 @@ bool pm_debug_messages_on __read_mostly;
613617

614618
bool pm_debug_messages_should_print(void)
615619
{
616-
return pm_debug_messages_on && (pm_suspend_in_progress() ||
617-
hibernation_in_progress());
620+
return pm_debug_messages_on && pm_sleep_transition_in_progress();
618621
}
619622
EXPORT_SYMBOL_GPL(pm_debug_messages_should_print);
620623

0 commit comments

Comments
 (0)