aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/base/power/generic_ops.c4
-rw-r--r--drivers/char/apm-emulation.c11
-rw-r--r--include/linux/pm.h21
-rw-r--r--include/linux/pm_runtime.h12
-rw-r--r--include/uapi/linux/apm_bios.h2
-rw-r--r--kernel/power/hibernate.c7
6 files changed, 46 insertions, 11 deletions
diff --git a/drivers/base/power/generic_ops.c b/drivers/base/power/generic_ops.c
index 5ee030a864f9..a2e55bfdf572 100644
--- a/drivers/base/power/generic_ops.c
+++ b/drivers/base/power/generic_ops.c
@@ -10,7 +10,7 @@
10#include <linux/pm_runtime.h> 10#include <linux/pm_runtime.h>
11#include <linux/export.h> 11#include <linux/export.h>
12 12
13#ifdef CONFIG_PM_RUNTIME 13#ifdef CONFIG_PM
14/** 14/**
15 * pm_generic_runtime_suspend - Generic runtime suspend callback for subsystems. 15 * pm_generic_runtime_suspend - Generic runtime suspend callback for subsystems.
16 * @dev: Device to suspend. 16 * @dev: Device to suspend.
@@ -48,7 +48,7 @@ int pm_generic_runtime_resume(struct device *dev)
48 return ret; 48 return ret;
49} 49}
50EXPORT_SYMBOL_GPL(pm_generic_runtime_resume); 50EXPORT_SYMBOL_GPL(pm_generic_runtime_resume);
51#endif /* CONFIG_PM_RUNTIME */ 51#endif /* CONFIG_PM */
52 52
53#ifdef CONFIG_PM_SLEEP 53#ifdef CONFIG_PM_SLEEP
54/** 54/**
diff --git a/drivers/char/apm-emulation.c b/drivers/char/apm-emulation.c
index 46118f845948..dd9dfa15e9d1 100644
--- a/drivers/char/apm-emulation.c
+++ b/drivers/char/apm-emulation.c
@@ -531,6 +531,7 @@ static int apm_suspend_notifier(struct notifier_block *nb,
531{ 531{
532 struct apm_user *as; 532 struct apm_user *as;
533 int err; 533 int err;
534 unsigned long apm_event;
534 535
535 /* short-cut emergency suspends */ 536 /* short-cut emergency suspends */
536 if (atomic_read(&userspace_notification_inhibit)) 537 if (atomic_read(&userspace_notification_inhibit))
@@ -538,6 +539,9 @@ static int apm_suspend_notifier(struct notifier_block *nb,
538 539
539 switch (event) { 540 switch (event) {
540 case PM_SUSPEND_PREPARE: 541 case PM_SUSPEND_PREPARE:
542 case PM_HIBERNATION_PREPARE:
543 apm_event = (event == PM_SUSPEND_PREPARE) ?
544 APM_USER_SUSPEND : APM_USER_HIBERNATION;
541 /* 545 /*
542 * Queue an event to all "writer" users that we want 546 * Queue an event to all "writer" users that we want
543 * to suspend and need their ack. 547 * to suspend and need their ack.
@@ -550,7 +554,7 @@ static int apm_suspend_notifier(struct notifier_block *nb,
550 as->writer && as->suser) { 554 as->writer && as->suser) {
551 as->suspend_state = SUSPEND_PENDING; 555 as->suspend_state = SUSPEND_PENDING;
552 atomic_inc(&suspend_acks_pending); 556 atomic_inc(&suspend_acks_pending);
553 queue_add_event(&as->queue, APM_USER_SUSPEND); 557 queue_add_event(&as->queue, apm_event);
554 } 558 }
555 } 559 }
556 560
@@ -601,11 +605,14 @@ static int apm_suspend_notifier(struct notifier_block *nb,
601 return notifier_from_errno(err); 605 return notifier_from_errno(err);
602 606
603 case PM_POST_SUSPEND: 607 case PM_POST_SUSPEND:
608 case PM_POST_HIBERNATION:
609 apm_event = (event == PM_POST_SUSPEND) ?
610 APM_NORMAL_RESUME : APM_HIBERNATION_RESUME;
604 /* 611 /*
605 * Anyone on the APM queues will think we're still suspended. 612 * Anyone on the APM queues will think we're still suspended.
606 * Send a message so everyone knows we're now awake again. 613 * Send a message so everyone knows we're now awake again.
607 */ 614 */
608 queue_event(APM_NORMAL_RESUME); 615 queue_event(apm_event);
609 616
610 /* 617 /*
611 * Finally, wake up anyone who is sleeping on the suspend. 618 * Finally, wake up anyone who is sleeping on the suspend.
diff --git a/include/linux/pm.h b/include/linux/pm.h
index a224c7f5c377..8c6583a53a06 100644
--- a/include/linux/pm.h
+++ b/include/linux/pm.h
@@ -311,6 +311,18 @@ struct dev_pm_ops {
311#define SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) 311#define SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn)
312#endif 312#endif
313 313
314#ifdef CONFIG_PM_SLEEP
315#define SET_LATE_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
316 .suspend_late = suspend_fn, \
317 .resume_early = resume_fn, \
318 .freeze_late = suspend_fn, \
319 .thaw_early = resume_fn, \
320 .poweroff_late = suspend_fn, \
321 .restore_early = resume_fn,
322#else
323#define SET_LATE_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn)
324#endif
325
314#ifdef CONFIG_PM_RUNTIME 326#ifdef CONFIG_PM_RUNTIME
315#define SET_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \ 327#define SET_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \
316 .runtime_suspend = suspend_fn, \ 328 .runtime_suspend = suspend_fn, \
@@ -320,6 +332,15 @@ struct dev_pm_ops {
320#define SET_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) 332#define SET_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn)
321#endif 333#endif
322 334
335#ifdef CONFIG_PM
336#define SET_PM_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \
337 .runtime_suspend = suspend_fn, \
338 .runtime_resume = resume_fn, \
339 .runtime_idle = idle_fn,
340#else
341#define SET_PM_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn)
342#endif
343
323/* 344/*
324 * Use this if you want to use the same suspend and resume callbacks for suspend 345 * Use this if you want to use the same suspend and resume callbacks for suspend
325 * to RAM and hibernation. 346 * to RAM and hibernation.
diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
index 6fa7cea25da9..16c9a62fa1c0 100644
--- a/include/linux/pm_runtime.h
+++ b/include/linux/pm_runtime.h
@@ -23,6 +23,14 @@
23 usage_count */ 23 usage_count */
24#define RPM_AUTO 0x08 /* Use autosuspend_delay */ 24#define RPM_AUTO 0x08 /* Use autosuspend_delay */
25 25
26#ifdef CONFIG_PM
27extern int pm_generic_runtime_suspend(struct device *dev);
28extern int pm_generic_runtime_resume(struct device *dev);
29#else
30static inline int pm_generic_runtime_suspend(struct device *dev) { return 0; }
31static inline int pm_generic_runtime_resume(struct device *dev) { return 0; }
32#endif
33
26#ifdef CONFIG_PM_RUNTIME 34#ifdef CONFIG_PM_RUNTIME
27 35
28extern struct workqueue_struct *pm_wq; 36extern struct workqueue_struct *pm_wq;
@@ -37,8 +45,6 @@ extern void pm_runtime_enable(struct device *dev);
37extern void __pm_runtime_disable(struct device *dev, bool check_resume); 45extern void __pm_runtime_disable(struct device *dev, bool check_resume);
38extern void pm_runtime_allow(struct device *dev); 46extern void pm_runtime_allow(struct device *dev);
39extern void pm_runtime_forbid(struct device *dev); 47extern void pm_runtime_forbid(struct device *dev);
40extern int pm_generic_runtime_suspend(struct device *dev);
41extern int pm_generic_runtime_resume(struct device *dev);
42extern void pm_runtime_no_callbacks(struct device *dev); 48extern void pm_runtime_no_callbacks(struct device *dev);
43extern void pm_runtime_irq_safe(struct device *dev); 49extern void pm_runtime_irq_safe(struct device *dev);
44extern void __pm_runtime_use_autosuspend(struct device *dev, bool use); 50extern void __pm_runtime_use_autosuspend(struct device *dev, bool use);
@@ -142,8 +148,6 @@ static inline bool pm_runtime_active(struct device *dev) { return true; }
142static inline bool pm_runtime_status_suspended(struct device *dev) { return false; } 148static inline bool pm_runtime_status_suspended(struct device *dev) { return false; }
143static inline bool pm_runtime_enabled(struct device *dev) { return false; } 149static inline bool pm_runtime_enabled(struct device *dev) { return false; }
144 150
145static inline int pm_generic_runtime_suspend(struct device *dev) { return 0; }
146static inline int pm_generic_runtime_resume(struct device *dev) { return 0; }
147static inline void pm_runtime_no_callbacks(struct device *dev) {} 151static inline void pm_runtime_no_callbacks(struct device *dev) {}
148static inline void pm_runtime_irq_safe(struct device *dev) {} 152static inline void pm_runtime_irq_safe(struct device *dev) {}
149 153
diff --git a/include/uapi/linux/apm_bios.h b/include/uapi/linux/apm_bios.h
index 724f409adae0..df79bca1b898 100644
--- a/include/uapi/linux/apm_bios.h
+++ b/include/uapi/linux/apm_bios.h
@@ -67,6 +67,8 @@ struct apm_bios_info {
67#define APM_USER_SUSPEND 0x000a 67#define APM_USER_SUSPEND 0x000a
68#define APM_STANDBY_RESUME 0x000b 68#define APM_STANDBY_RESUME 0x000b
69#define APM_CAPABILITY_CHANGE 0x000c 69#define APM_CAPABILITY_CHANGE 0x000c
70#define APM_USER_HIBERNATION 0x000d
71#define APM_HIBERNATION_RESUME 0x000e
70 72
71/* 73/*
72 * Error codes 74 * Error codes
diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
index 0121dab83f43..37170d4dd9a6 100644
--- a/kernel/power/hibernate.c
+++ b/kernel/power/hibernate.c
@@ -82,6 +82,7 @@ void hibernation_set_ops(const struct platform_hibernation_ops *ops)
82 82
83 unlock_system_sleep(); 83 unlock_system_sleep();
84} 84}
85EXPORT_SYMBOL_GPL(hibernation_set_ops);
85 86
86static bool entering_platform_hibernation; 87static bool entering_platform_hibernation;
87 88
@@ -293,10 +294,10 @@ static int create_image(int platform_mode)
293 error); 294 error);
294 /* Restore control flow magically appears here */ 295 /* Restore control flow magically appears here */
295 restore_processor_state(); 296 restore_processor_state();
296 if (!in_suspend) { 297 if (!in_suspend)
297 events_check_enabled = false; 298 events_check_enabled = false;
298 platform_leave(platform_mode); 299
299 } 300 platform_leave(platform_mode);
300 301
301 Power_up: 302 Power_up:
302 syscore_resume(); 303 syscore_resume();