iwlegacy: 3945: fix hw passive scan on radar channels
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / include / linux / jump_label.h
blob388b0d425b507add656cca2aa7b48a346bf159ec
1 #ifndef _LINUX_JUMP_LABEL_H
2 #define _LINUX_JUMP_LABEL_H
4 #include <linux/types.h>
5 #include <linux/compiler.h>
7 #if defined(CC_HAVE_ASM_GOTO) && defined(CONFIG_JUMP_LABEL)
9 struct jump_label_key {
10 atomic_t enabled;
11 struct jump_entry *entries;
12 #ifdef CONFIG_MODULES
13 struct jump_label_mod *next;
14 #endif
17 # include <asm/jump_label.h>
18 # define HAVE_JUMP_LABEL
19 #endif /* CC_HAVE_ASM_GOTO && CONFIG_JUMP_LABEL */
21 enum jump_label_type {
22 JUMP_LABEL_DISABLE = 0,
23 JUMP_LABEL_ENABLE,
26 struct module;
28 #ifdef HAVE_JUMP_LABEL
30 #ifdef CONFIG_MODULES
31 #define JUMP_LABEL_INIT {ATOMIC_INIT(0), NULL, NULL}
32 #else
33 #define JUMP_LABEL_INIT {ATOMIC_INIT(0), NULL}
34 #endif
36 static __always_inline bool static_branch(struct jump_label_key *key)
38 return arch_static_branch(key);
41 extern struct jump_entry __start___jump_table[];
42 extern struct jump_entry __stop___jump_table[];
44 extern void jump_label_init(void);
45 extern void jump_label_lock(void);
46 extern void jump_label_unlock(void);
47 extern void arch_jump_label_transform(struct jump_entry *entry,
48 enum jump_label_type type);
49 extern void arch_jump_label_transform_static(struct jump_entry *entry,
50 enum jump_label_type type);
51 extern int jump_label_text_reserved(void *start, void *end);
52 extern void jump_label_inc(struct jump_label_key *key);
53 extern void jump_label_dec(struct jump_label_key *key);
54 extern bool jump_label_enabled(struct jump_label_key *key);
55 extern void jump_label_apply_nops(struct module *mod);
57 #else /* !HAVE_JUMP_LABEL */
59 #include <linux/atomic.h>
61 #define JUMP_LABEL_INIT {ATOMIC_INIT(0)}
63 struct jump_label_key {
64 atomic_t enabled;
67 static __always_inline void jump_label_init(void)
71 static __always_inline bool static_branch(struct jump_label_key *key)
73 if (unlikely(atomic_read(&key->enabled)))
74 return true;
75 return false;
78 static inline void jump_label_inc(struct jump_label_key *key)
80 atomic_inc(&key->enabled);
83 static inline void jump_label_dec(struct jump_label_key *key)
85 atomic_dec(&key->enabled);
88 static inline int jump_label_text_reserved(void *start, void *end)
90 return 0;
93 static inline void jump_label_lock(void) {}
94 static inline void jump_label_unlock(void) {}
96 static inline bool jump_label_enabled(struct jump_label_key *key)
98 return !!atomic_read(&key->enabled);
101 static inline int jump_label_apply_nops(struct module *mod)
103 return 0;
105 #endif /* HAVE_JUMP_LABEL */
107 #endif /* _LINUX_JUMP_LABEL_H */