Skip to content

Commit 8252575

Browse files
AlanSternlenb
authored andcommitted
PM: Convert PM notifiers to out-of-line code
This patch (as1008b) converts the PM notifier routines from inline calls to out-of-line code. It also prevents pm_chain_head from being created when CONFIG_PM_SLEEP isn't enabled, and EXPORTs the notifier registration and unregistration routines. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl> Signed-off-by: Len Brown <len.brown@intel.com>
1 parent 90dda1c commit 8252575

3 files changed

Lines changed: 32 additions & 21 deletions

File tree

‎include/linux/suspend.h‎

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -213,17 +213,8 @@ void save_processor_state(void);
213213
void restore_processor_state(void);
214214

215215
/* kernel/power/main.c */
216-
extern struct blocking_notifier_head pm_chain_head;
217-
218-
static inline int register_pm_notifier(struct notifier_block *nb)
219-
{
220-
return blocking_notifier_chain_register(&pm_chain_head, nb);
221-
}
222-
223-
static inline int unregister_pm_notifier(struct notifier_block *nb)
224-
{
225-
return blocking_notifier_chain_unregister(&pm_chain_head, nb);
226-
}
216+
extern int register_pm_notifier(struct notifier_block *nb);
217+
extern int unregister_pm_notifier(struct notifier_block *nb);
227218

228219
#define pm_notifier(fn, pri) { \
229220
static struct notifier_block fn##_nb = \

‎kernel/power/main.c‎

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,37 @@
2424

2525
#include "power.h"
2626

27-
BLOCKING_NOTIFIER_HEAD(pm_chain_head);
28-
2927
DEFINE_MUTEX(pm_mutex);
3028

3129
unsigned int pm_flags;
3230
EXPORT_SYMBOL(pm_flags);
3331

32+
#ifdef CONFIG_PM_SLEEP
33+
34+
/* Routines for PM-transition notifications */
35+
36+
static BLOCKING_NOTIFIER_HEAD(pm_chain_head);
37+
38+
int register_pm_notifier(struct notifier_block *nb)
39+
{
40+
return blocking_notifier_chain_register(&pm_chain_head, nb);
41+
}
42+
EXPORT_SYMBOL_GPL(register_pm_notifier);
43+
44+
int unregister_pm_notifier(struct notifier_block *nb)
45+
{
46+
return blocking_notifier_chain_unregister(&pm_chain_head, nb);
47+
}
48+
EXPORT_SYMBOL_GPL(unregister_pm_notifier);
49+
50+
int pm_notifier_call_chain(unsigned long val)
51+
{
52+
return (blocking_notifier_call_chain(&pm_chain_head, val, NULL)
53+
== NOTIFY_BAD) ? -EINVAL : 0;
54+
}
55+
56+
#endif /* CONFIG_PM_SLEEP */
57+
3458
#ifdef CONFIG_PM_DEBUG
3559
int pm_test_level = TEST_NONE;
3660

‎kernel/power/power.h‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -172,14 +172,10 @@ static inline int suspend_devices_and_enter(suspend_state_t state)
172172
}
173173
#endif /* !CONFIG_SUSPEND */
174174

175-
/* kernel/power/common.c */
176-
extern struct blocking_notifier_head pm_chain_head;
177-
178-
static inline int pm_notifier_call_chain(unsigned long val)
179-
{
180-
return (blocking_notifier_call_chain(&pm_chain_head, val, NULL)
181-
== NOTIFY_BAD) ? -EINVAL : 0;
182-
}
175+
#ifdef CONFIG_PM_SLEEP
176+
/* kernel/power/main.c */
177+
extern int pm_notifier_call_chain(unsigned long val);
178+
#endif
183179

184180
#ifdef CONFIG_HIGHMEM
185181
unsigned int count_highmem_pages(void);

0 commit comments

Comments
 (0)