Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef _LINUX_SUSPEND_H
0003 #define _LINUX_SUSPEND_H
0004 
0005 #include <linux/swap.h>
0006 #include <linux/notifier.h>
0007 #include <linux/init.h>
0008 #include <linux/pm.h>
0009 #include <linux/mm.h>
0010 #include <linux/freezer.h>
0011 #include <asm/errno.h>
0012 
0013 #ifdef CONFIG_VT
0014 extern void pm_set_vt_switch(int);
0015 #else
0016 static inline void pm_set_vt_switch(int do_switch)
0017 {
0018 }
0019 #endif
0020 
0021 #ifdef CONFIG_VT_CONSOLE_SLEEP
0022 extern void pm_prepare_console(void);
0023 extern void pm_restore_console(void);
0024 #else
0025 static inline void pm_prepare_console(void)
0026 {
0027 }
0028 
0029 static inline void pm_restore_console(void)
0030 {
0031 }
0032 #endif
0033 
0034 typedef int __bitwise suspend_state_t;
0035 
0036 #define PM_SUSPEND_ON       ((__force suspend_state_t) 0)
0037 #define PM_SUSPEND_TO_IDLE  ((__force suspend_state_t) 1)
0038 #define PM_SUSPEND_STANDBY  ((__force suspend_state_t) 2)
0039 #define PM_SUSPEND_MEM      ((__force suspend_state_t) 3)
0040 #define PM_SUSPEND_MIN      PM_SUSPEND_TO_IDLE
0041 #define PM_SUSPEND_MAX      ((__force suspend_state_t) 4)
0042 
0043 enum suspend_stat_step {
0044     SUSPEND_FREEZE = 1,
0045     SUSPEND_PREPARE,
0046     SUSPEND_SUSPEND,
0047     SUSPEND_SUSPEND_LATE,
0048     SUSPEND_SUSPEND_NOIRQ,
0049     SUSPEND_RESUME_NOIRQ,
0050     SUSPEND_RESUME_EARLY,
0051     SUSPEND_RESUME
0052 };
0053 
0054 struct suspend_stats {
0055     int success;
0056     int fail;
0057     int failed_freeze;
0058     int failed_prepare;
0059     int failed_suspend;
0060     int failed_suspend_late;
0061     int failed_suspend_noirq;
0062     int failed_resume;
0063     int failed_resume_early;
0064     int failed_resume_noirq;
0065 #define REC_FAILED_NUM  2
0066     int last_failed_dev;
0067     char    failed_devs[REC_FAILED_NUM][40];
0068     int last_failed_errno;
0069     int errno[REC_FAILED_NUM];
0070     int last_failed_step;
0071     enum suspend_stat_step  failed_steps[REC_FAILED_NUM];
0072 };
0073 
0074 extern struct suspend_stats suspend_stats;
0075 
0076 static inline void dpm_save_failed_dev(const char *name)
0077 {
0078     strlcpy(suspend_stats.failed_devs[suspend_stats.last_failed_dev],
0079         name,
0080         sizeof(suspend_stats.failed_devs[0]));
0081     suspend_stats.last_failed_dev++;
0082     suspend_stats.last_failed_dev %= REC_FAILED_NUM;
0083 }
0084 
0085 static inline void dpm_save_failed_errno(int err)
0086 {
0087     suspend_stats.errno[suspend_stats.last_failed_errno] = err;
0088     suspend_stats.last_failed_errno++;
0089     suspend_stats.last_failed_errno %= REC_FAILED_NUM;
0090 }
0091 
0092 static inline void dpm_save_failed_step(enum suspend_stat_step step)
0093 {
0094     suspend_stats.failed_steps[suspend_stats.last_failed_step] = step;
0095     suspend_stats.last_failed_step++;
0096     suspend_stats.last_failed_step %= REC_FAILED_NUM;
0097 }
0098 
0099 /**
0100  * struct platform_suspend_ops - Callbacks for managing platform dependent
0101  *  system sleep states.
0102  *
0103  * @valid: Callback to determine if given system sleep state is supported by
0104  *  the platform.
0105  *  Valid (ie. supported) states are advertised in /sys/power/state.  Note
0106  *  that it still may be impossible to enter given system sleep state if the
0107  *  conditions aren't right.
0108  *  There is the %suspend_valid_only_mem function available that can be
0109  *  assigned to this if the platform only supports mem sleep.
0110  *
0111  * @begin: Initialise a transition to given system sleep state.
0112  *  @begin() is executed right prior to suspending devices.  The information
0113  *  conveyed to the platform code by @begin() should be disregarded by it as
0114  *  soon as @end() is executed.  If @begin() fails (ie. returns nonzero),
0115  *  @prepare(), @enter() and @finish() will not be called by the PM core.
0116  *  This callback is optional.  However, if it is implemented, the argument
0117  *  passed to @enter() is redundant and should be ignored.
0118  *
0119  * @prepare: Prepare the platform for entering the system sleep state indicated
0120  *  by @begin().
0121  *  @prepare() is called right after devices have been suspended (ie. the
0122  *  appropriate .suspend() method has been executed for each device) and
0123  *  before device drivers' late suspend callbacks are executed.  It returns
0124  *  0 on success or a negative error code otherwise, in which case the
0125  *  system cannot enter the desired sleep state (@prepare_late(), @enter(),
0126  *  and @wake() will not be called in that case).
0127  *
0128  * @prepare_late: Finish preparing the platform for entering the system sleep
0129  *  state indicated by @begin().
0130  *  @prepare_late is called before disabling nonboot CPUs and after
0131  *  device drivers' late suspend callbacks have been executed.  It returns
0132  *  0 on success or a negative error code otherwise, in which case the
0133  *  system cannot enter the desired sleep state (@enter() will not be
0134  *  executed).
0135  *
0136  * @enter: Enter the system sleep state indicated by @begin() or represented by
0137  *  the argument if @begin() is not implemented.
0138  *  This callback is mandatory.  It returns 0 on success or a negative
0139  *  error code otherwise, in which case the system cannot enter the desired
0140  *  sleep state.
0141  *
0142  * @wake: Called when the system has just left a sleep state, right after
0143  *  the nonboot CPUs have been enabled and before device drivers' early
0144  *  resume callbacks are executed.
0145  *  This callback is optional, but should be implemented by the platforms
0146  *  that implement @prepare_late().  If implemented, it is always called
0147  *  after @prepare_late and @enter(), even if one of them fails.
0148  *
0149  * @finish: Finish wake-up of the platform.
0150  *  @finish is called right prior to calling device drivers' regular suspend
0151  *  callbacks.
0152  *  This callback is optional, but should be implemented by the platforms
0153  *  that implement @prepare().  If implemented, it is always called after
0154  *  @enter() and @wake(), even if any of them fails.  It is executed after
0155  *  a failing @prepare.
0156  *
0157  * @suspend_again: Returns whether the system should suspend again (true) or
0158  *  not (false). If the platform wants to poll sensors or execute some
0159  *  code during suspended without invoking userspace and most of devices,
0160  *  suspend_again callback is the place assuming that periodic-wakeup or
0161  *  alarm-wakeup is already setup. This allows to execute some codes while
0162  *  being kept suspended in the view of userland and devices.
0163  *
0164  * @end: Called by the PM core right after resuming devices, to indicate to
0165  *  the platform that the system has returned to the working state or
0166  *  the transition to the sleep state has been aborted.
0167  *  This callback is optional, but should be implemented by the platforms
0168  *  that implement @begin().  Accordingly, platforms implementing @begin()
0169  *  should also provide a @end() which cleans up transitions aborted before
0170  *  @enter().
0171  *
0172  * @recover: Recover the platform from a suspend failure.
0173  *  Called by the PM core if the suspending of devices fails.
0174  *  This callback is optional and should only be implemented by platforms
0175  *  which require special recovery actions in that situation.
0176  */
0177 struct platform_suspend_ops {
0178     int (*valid)(suspend_state_t state);
0179     int (*begin)(suspend_state_t state);
0180     int (*prepare)(void);
0181     int (*prepare_late)(void);
0182     int (*enter)(suspend_state_t state);
0183     void (*wake)(void);
0184     void (*finish)(void);
0185     bool (*suspend_again)(void);
0186     void (*end)(void);
0187     void (*recover)(void);
0188 };
0189 
0190 struct platform_s2idle_ops {
0191     int (*begin)(void);
0192     int (*prepare)(void);
0193     int (*prepare_late)(void);
0194     bool (*wake)(void);
0195     void (*restore_early)(void);
0196     void (*restore)(void);
0197     void (*end)(void);
0198 };
0199 
0200 #ifdef CONFIG_SUSPEND
0201 extern suspend_state_t mem_sleep_current;
0202 extern suspend_state_t mem_sleep_default;
0203 
0204 /**
0205  * suspend_set_ops - set platform dependent suspend operations
0206  * @ops: The new suspend operations to set.
0207  */
0208 extern void suspend_set_ops(const struct platform_suspend_ops *ops);
0209 extern int suspend_valid_only_mem(suspend_state_t state);
0210 
0211 extern unsigned int pm_suspend_global_flags;
0212 
0213 #define PM_SUSPEND_FLAG_FW_SUSPEND  BIT(0)
0214 #define PM_SUSPEND_FLAG_FW_RESUME   BIT(1)
0215 #define PM_SUSPEND_FLAG_NO_PLATFORM BIT(2)
0216 
0217 static inline void pm_suspend_clear_flags(void)
0218 {
0219     pm_suspend_global_flags = 0;
0220 }
0221 
0222 static inline void pm_set_suspend_via_firmware(void)
0223 {
0224     pm_suspend_global_flags |= PM_SUSPEND_FLAG_FW_SUSPEND;
0225 }
0226 
0227 static inline void pm_set_resume_via_firmware(void)
0228 {
0229     pm_suspend_global_flags |= PM_SUSPEND_FLAG_FW_RESUME;
0230 }
0231 
0232 static inline void pm_set_suspend_no_platform(void)
0233 {
0234     pm_suspend_global_flags |= PM_SUSPEND_FLAG_NO_PLATFORM;
0235 }
0236 
0237 /**
0238  * pm_suspend_via_firmware - Check if platform firmware will suspend the system.
0239  *
0240  * To be called during system-wide power management transitions to sleep states
0241  * or during the subsequent system-wide transitions back to the working state.
0242  *
0243  * Return 'true' if the platform firmware is going to be invoked at the end of
0244  * the system-wide power management transition (to a sleep state) in progress in
0245  * order to complete it, or if the platform firmware has been invoked in order
0246  * to complete the last (or preceding) transition of the system to a sleep
0247  * state.
0248  *
0249  * This matters if the caller needs or wants to carry out some special actions
0250  * depending on whether or not control will be passed to the platform firmware
0251  * subsequently (for example, the device may need to be reset before letting the
0252  * platform firmware manipulate it, which is not necessary when the platform
0253  * firmware is not going to be invoked) or when such special actions may have
0254  * been carried out during the preceding transition of the system to a sleep
0255  * state (as they may need to be taken into account).
0256  */
0257 static inline bool pm_suspend_via_firmware(void)
0258 {
0259     return !!(pm_suspend_global_flags & PM_SUSPEND_FLAG_FW_SUSPEND);
0260 }
0261 
0262 /**
0263  * pm_resume_via_firmware - Check if platform firmware has woken up the system.
0264  *
0265  * To be called during system-wide power management transitions from sleep
0266  * states.
0267  *
0268  * Return 'true' if the platform firmware has passed control to the kernel at
0269  * the beginning of the system-wide power management transition in progress, so
0270  * the event that woke up the system from sleep has been handled by the platform
0271  * firmware.
0272  */
0273 static inline bool pm_resume_via_firmware(void)
0274 {
0275     return !!(pm_suspend_global_flags & PM_SUSPEND_FLAG_FW_RESUME);
0276 }
0277 
0278 /**
0279  * pm_suspend_no_platform - Check if platform may change device power states.
0280  *
0281  * To be called during system-wide power management transitions to sleep states
0282  * or during the subsequent system-wide transitions back to the working state.
0283  *
0284  * Return 'true' if the power states of devices remain under full control of the
0285  * kernel throughout the system-wide suspend and resume cycle in progress (that
0286  * is, if a device is put into a certain power state during suspend, it can be
0287  * expected to remain in that state during resume).
0288  */
0289 static inline bool pm_suspend_no_platform(void)
0290 {
0291     return !!(pm_suspend_global_flags & PM_SUSPEND_FLAG_NO_PLATFORM);
0292 }
0293 
0294 /* Suspend-to-idle state machnine. */
0295 enum s2idle_states {
0296     S2IDLE_STATE_NONE,      /* Not suspended/suspending. */
0297     S2IDLE_STATE_ENTER,     /* Enter suspend-to-idle. */
0298     S2IDLE_STATE_WAKE,      /* Wake up from suspend-to-idle. */
0299 };
0300 
0301 extern enum s2idle_states __read_mostly s2idle_state;
0302 
0303 static inline bool idle_should_enter_s2idle(void)
0304 {
0305     return unlikely(s2idle_state == S2IDLE_STATE_ENTER);
0306 }
0307 
0308 extern bool pm_suspend_default_s2idle(void);
0309 extern void __init pm_states_init(void);
0310 extern void s2idle_set_ops(const struct platform_s2idle_ops *ops);
0311 extern void s2idle_wake(void);
0312 
0313 /**
0314  * arch_suspend_disable_irqs - disable IRQs for suspend
0315  *
0316  * Disables IRQs (in the default case). This is a weak symbol in the common
0317  * code and thus allows architectures to override it if more needs to be
0318  * done. Not called for suspend to disk.
0319  */
0320 extern void arch_suspend_disable_irqs(void);
0321 
0322 /**
0323  * arch_suspend_enable_irqs - enable IRQs after suspend
0324  *
0325  * Enables IRQs (in the default case). This is a weak symbol in the common
0326  * code and thus allows architectures to override it if more needs to be
0327  * done. Not called for suspend to disk.
0328  */
0329 extern void arch_suspend_enable_irqs(void);
0330 
0331 extern int pm_suspend(suspend_state_t state);
0332 extern bool sync_on_suspend_enabled;
0333 #else /* !CONFIG_SUSPEND */
0334 #define suspend_valid_only_mem  NULL
0335 
0336 static inline void pm_suspend_clear_flags(void) {}
0337 static inline void pm_set_suspend_via_firmware(void) {}
0338 static inline void pm_set_resume_via_firmware(void) {}
0339 static inline bool pm_suspend_via_firmware(void) { return false; }
0340 static inline bool pm_resume_via_firmware(void) { return false; }
0341 static inline bool pm_suspend_no_platform(void) { return false; }
0342 static inline bool pm_suspend_default_s2idle(void) { return false; }
0343 
0344 static inline void suspend_set_ops(const struct platform_suspend_ops *ops) {}
0345 static inline int pm_suspend(suspend_state_t state) { return -ENOSYS; }
0346 static inline bool sync_on_suspend_enabled(void) { return true; }
0347 static inline bool idle_should_enter_s2idle(void) { return false; }
0348 static inline void __init pm_states_init(void) {}
0349 static inline void s2idle_set_ops(const struct platform_s2idle_ops *ops) {}
0350 static inline void s2idle_wake(void) {}
0351 #endif /* !CONFIG_SUSPEND */
0352 
0353 /* struct pbe is used for creating lists of pages that should be restored
0354  * atomically during the resume from disk, because the page frames they have
0355  * occupied before the suspend are in use.
0356  */
0357 struct pbe {
0358     void *address;      /* address of the copy */
0359     void *orig_address; /* original address of a page */
0360     struct pbe *next;
0361 };
0362 
0363 /* mm/page_alloc.c */
0364 extern void mark_free_pages(struct zone *zone);
0365 
0366 /**
0367  * struct platform_hibernation_ops - hibernation platform support
0368  *
0369  * The methods in this structure allow a platform to carry out special
0370  * operations required by it during a hibernation transition.
0371  *
0372  * All the methods below, except for @recover(), must be implemented.
0373  *
0374  * @begin: Tell the platform driver that we're starting hibernation.
0375  *  Called right after shrinking memory and before freezing devices.
0376  *
0377  * @end: Called by the PM core right after resuming devices, to indicate to
0378  *  the platform that the system has returned to the working state.
0379  *
0380  * @pre_snapshot: Prepare the platform for creating the hibernation image.
0381  *  Called right after devices have been frozen and before the nonboot
0382  *  CPUs are disabled (runs with IRQs on).
0383  *
0384  * @finish: Restore the previous state of the platform after the hibernation
0385  *  image has been created *or* put the platform into the normal operation
0386  *  mode after the hibernation (the same method is executed in both cases).
0387  *  Called right after the nonboot CPUs have been enabled and before
0388  *  thawing devices (runs with IRQs on).
0389  *
0390  * @prepare: Prepare the platform for entering the low power state.
0391  *  Called right after the hibernation image has been saved and before
0392  *  devices are prepared for entering the low power state.
0393  *
0394  * @enter: Put the system into the low power state after the hibernation image
0395  *  has been saved to disk.
0396  *  Called after the nonboot CPUs have been disabled and all of the low
0397  *  level devices have been shut down (runs with IRQs off).
0398  *
0399  * @leave: Perform the first stage of the cleanup after the system sleep state
0400  *  indicated by @set_target() has been left.
0401  *  Called right after the control has been passed from the boot kernel to
0402  *  the image kernel, before the nonboot CPUs are enabled and before devices
0403  *  are resumed.  Executed with interrupts disabled.
0404  *
0405  * @pre_restore: Prepare system for the restoration from a hibernation image.
0406  *  Called right after devices have been frozen and before the nonboot
0407  *  CPUs are disabled (runs with IRQs on).
0408  *
0409  * @restore_cleanup: Clean up after a failing image restoration.
0410  *  Called right after the nonboot CPUs have been enabled and before
0411  *  thawing devices (runs with IRQs on).
0412  *
0413  * @recover: Recover the platform from a failure to suspend devices.
0414  *  Called by the PM core if the suspending of devices during hibernation
0415  *  fails.  This callback is optional and should only be implemented by
0416  *  platforms which require special recovery actions in that situation.
0417  */
0418 struct platform_hibernation_ops {
0419     int (*begin)(pm_message_t stage);
0420     void (*end)(void);
0421     int (*pre_snapshot)(void);
0422     void (*finish)(void);
0423     int (*prepare)(void);
0424     int (*enter)(void);
0425     void (*leave)(void);
0426     int (*pre_restore)(void);
0427     void (*restore_cleanup)(void);
0428     void (*recover)(void);
0429 };
0430 
0431 #ifdef CONFIG_HIBERNATION
0432 /* kernel/power/snapshot.c */
0433 extern void register_nosave_region(unsigned long b, unsigned long e);
0434 extern int swsusp_page_is_forbidden(struct page *);
0435 extern void swsusp_set_page_free(struct page *);
0436 extern void swsusp_unset_page_free(struct page *);
0437 extern unsigned long get_safe_page(gfp_t gfp_mask);
0438 extern asmlinkage int swsusp_arch_suspend(void);
0439 extern asmlinkage int swsusp_arch_resume(void);
0440 
0441 extern u32 swsusp_hardware_signature;
0442 extern void hibernation_set_ops(const struct platform_hibernation_ops *ops);
0443 extern int hibernate(void);
0444 extern bool system_entering_hibernation(void);
0445 extern bool hibernation_available(void);
0446 asmlinkage int swsusp_save(void);
0447 extern struct pbe *restore_pblist;
0448 int pfn_is_nosave(unsigned long pfn);
0449 
0450 int hibernate_quiet_exec(int (*func)(void *data), void *data);
0451 #else /* CONFIG_HIBERNATION */
0452 static inline void register_nosave_region(unsigned long b, unsigned long e) {}
0453 static inline int swsusp_page_is_forbidden(struct page *p) { return 0; }
0454 static inline void swsusp_set_page_free(struct page *p) {}
0455 static inline void swsusp_unset_page_free(struct page *p) {}
0456 
0457 static inline void hibernation_set_ops(const struct platform_hibernation_ops *ops) {}
0458 static inline int hibernate(void) { return -ENOSYS; }
0459 static inline bool system_entering_hibernation(void) { return false; }
0460 static inline bool hibernation_available(void) { return false; }
0461 
0462 static inline int hibernate_quiet_exec(int (*func)(void *data), void *data) {
0463     return -ENOTSUPP;
0464 }
0465 #endif /* CONFIG_HIBERNATION */
0466 
0467 #ifdef CONFIG_HIBERNATION_SNAPSHOT_DEV
0468 int is_hibernate_resume_dev(dev_t dev);
0469 #else
0470 static inline int is_hibernate_resume_dev(dev_t dev) { return 0; }
0471 #endif
0472 
0473 /* Hibernation and suspend events */
0474 #define PM_HIBERNATION_PREPARE  0x0001 /* Going to hibernate */
0475 #define PM_POST_HIBERNATION 0x0002 /* Hibernation finished */
0476 #define PM_SUSPEND_PREPARE  0x0003 /* Going to suspend the system */
0477 #define PM_POST_SUSPEND     0x0004 /* Suspend finished */
0478 #define PM_RESTORE_PREPARE  0x0005 /* Going to restore a saved image */
0479 #define PM_POST_RESTORE     0x0006 /* Restore failed */
0480 
0481 extern struct mutex system_transition_mutex;
0482 
0483 #ifdef CONFIG_PM_SLEEP
0484 void save_processor_state(void);
0485 void restore_processor_state(void);
0486 
0487 /* kernel/power/main.c */
0488 extern int register_pm_notifier(struct notifier_block *nb);
0489 extern int unregister_pm_notifier(struct notifier_block *nb);
0490 extern void ksys_sync_helper(void);
0491 
0492 #define pm_notifier(fn, pri) {              \
0493     static struct notifier_block fn##_nb =          \
0494         { .notifier_call = fn, .priority = pri };   \
0495     register_pm_notifier(&fn##_nb);         \
0496 }
0497 
0498 /* drivers/base/power/wakeup.c */
0499 extern bool events_check_enabled;
0500 extern suspend_state_t pm_suspend_target_state;
0501 
0502 extern bool pm_wakeup_pending(void);
0503 extern void pm_system_wakeup(void);
0504 extern void pm_system_cancel_wakeup(void);
0505 extern void pm_wakeup_clear(unsigned int irq_number);
0506 extern void pm_system_irq_wakeup(unsigned int irq_number);
0507 extern unsigned int pm_wakeup_irq(void);
0508 extern bool pm_get_wakeup_count(unsigned int *count, bool block);
0509 extern bool pm_save_wakeup_count(unsigned int count);
0510 extern void pm_wakep_autosleep_enabled(bool set);
0511 extern void pm_print_active_wakeup_sources(void);
0512 
0513 extern void lock_system_sleep(void);
0514 extern void unlock_system_sleep(void);
0515 
0516 #else /* !CONFIG_PM_SLEEP */
0517 
0518 static inline int register_pm_notifier(struct notifier_block *nb)
0519 {
0520     return 0;
0521 }
0522 
0523 static inline int unregister_pm_notifier(struct notifier_block *nb)
0524 {
0525     return 0;
0526 }
0527 
0528 static inline void ksys_sync_helper(void) {}
0529 
0530 #define pm_notifier(fn, pri)    do { (void)(fn); } while (0)
0531 
0532 static inline bool pm_wakeup_pending(void) { return false; }
0533 static inline void pm_system_wakeup(void) {}
0534 static inline void pm_wakeup_clear(bool reset) {}
0535 static inline void pm_system_irq_wakeup(unsigned int irq_number) {}
0536 
0537 static inline void lock_system_sleep(void) {}
0538 static inline void unlock_system_sleep(void) {}
0539 
0540 #endif /* !CONFIG_PM_SLEEP */
0541 
0542 #ifdef CONFIG_PM_SLEEP_DEBUG
0543 extern bool pm_print_times_enabled;
0544 extern bool pm_debug_messages_on;
0545 static inline int pm_dyn_debug_messages_on(void)
0546 {
0547 #ifdef CONFIG_DYNAMIC_DEBUG
0548     return 1;
0549 #else
0550     return 0;
0551 #endif
0552 }
0553 #ifndef pr_fmt
0554 #define pr_fmt(fmt) "PM: " fmt
0555 #endif
0556 #define __pm_pr_dbg(fmt, ...)                   \
0557     do {                            \
0558         if (pm_debug_messages_on)           \
0559             printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__);  \
0560         else if (pm_dyn_debug_messages_on())        \
0561             pr_debug(fmt, ##__VA_ARGS__);   \
0562     } while (0)
0563 #define __pm_deferred_pr_dbg(fmt, ...)              \
0564     do {                            \
0565         if (pm_debug_messages_on)           \
0566             printk_deferred(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); \
0567     } while (0)
0568 #else
0569 #define pm_print_times_enabled  (false)
0570 #define pm_debug_messages_on    (false)
0571 
0572 #include <linux/printk.h>
0573 
0574 #define __pm_pr_dbg(fmt, ...) \
0575     no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
0576 #define __pm_deferred_pr_dbg(fmt, ...) \
0577     no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
0578 #endif
0579 
0580 /**
0581  * pm_pr_dbg - print pm sleep debug messages
0582  *
0583  * If pm_debug_messages_on is enabled, print message.
0584  * If pm_debug_messages_on is disabled and CONFIG_DYNAMIC_DEBUG is enabled,
0585  *  print message only from instances explicitly enabled on dynamic debug's
0586  *  control.
0587  * If pm_debug_messages_on is disabled and CONFIG_DYNAMIC_DEBUG is disabled,
0588  *  don't print message.
0589  */
0590 #define pm_pr_dbg(fmt, ...) \
0591     __pm_pr_dbg(fmt, ##__VA_ARGS__)
0592 
0593 #define pm_deferred_pr_dbg(fmt, ...) \
0594     __pm_deferred_pr_dbg(fmt, ##__VA_ARGS__)
0595 
0596 #ifdef CONFIG_PM_AUTOSLEEP
0597 
0598 /* kernel/power/autosleep.c */
0599 void queue_up_suspend_work(void);
0600 
0601 #else /* !CONFIG_PM_AUTOSLEEP */
0602 
0603 static inline void queue_up_suspend_work(void) {}
0604 
0605 #endif /* !CONFIG_PM_AUTOSLEEP */
0606 
0607 #endif /* _LINUX_SUSPEND_H */