spi-topcliff-pch: Fix issue for transmitting over 4KByte
[zen-stable.git] / include / linux / jump_label.h
blob5ce8b140428f90b4861d2d1ac100cf9d58dac198
1 #ifndef _LINUX_JUMP_LABEL_H
2 #define _LINUX_JUMP_LABEL_H
4 #include <linux/types.h>
5 #include <linux/compiler.h>
6 #include <linux/workqueue.h>
8 #if defined(CC_HAVE_ASM_GOTO) && defined(CONFIG_JUMP_LABEL)
10 struct jump_label_key {
11 atomic_t enabled;
12 struct jump_entry *entries;
13 #ifdef CONFIG_MODULES
14 struct jump_label_mod *next;
15 #endif
18 struct jump_label_key_deferred {
19 struct jump_label_key key;
20 unsigned long timeout;
21 struct delayed_work work;
24 # include <asm/jump_label.h>
25 # define HAVE_JUMP_LABEL
26 #endif /* CC_HAVE_ASM_GOTO && CONFIG_JUMP_LABEL */
28 enum jump_label_type {
29 JUMP_LABEL_DISABLE = 0,
30 JUMP_LABEL_ENABLE,
33 struct module;
35 #ifdef HAVE_JUMP_LABEL
37 #ifdef CONFIG_MODULES
38 #define JUMP_LABEL_INIT {ATOMIC_INIT(0), NULL, NULL}
39 #else
40 #define JUMP_LABEL_INIT {ATOMIC_INIT(0), NULL}
41 #endif
43 static __always_inline bool static_branch(struct jump_label_key *key)
45 return arch_static_branch(key);
48 extern struct jump_entry __start___jump_table[];
49 extern struct jump_entry __stop___jump_table[];
51 extern void jump_label_init(void);
52 extern void jump_label_lock(void);
53 extern void jump_label_unlock(void);
54 extern void arch_jump_label_transform(struct jump_entry *entry,
55 enum jump_label_type type);
56 extern void arch_jump_label_transform_static(struct jump_entry *entry,
57 enum jump_label_type type);
58 extern int jump_label_text_reserved(void *start, void *end);
59 extern void jump_label_inc(struct jump_label_key *key);
60 extern void jump_label_dec(struct jump_label_key *key);
61 extern void jump_label_dec_deferred(struct jump_label_key_deferred *key);
62 extern bool jump_label_enabled(struct jump_label_key *key);
63 extern void jump_label_apply_nops(struct module *mod);
64 extern void jump_label_rate_limit(struct jump_label_key_deferred *key,
65 unsigned long rl);
67 #else /* !HAVE_JUMP_LABEL */
69 #include <linux/atomic.h>
71 #define JUMP_LABEL_INIT {ATOMIC_INIT(0)}
73 struct jump_label_key {
74 atomic_t enabled;
77 static __always_inline void jump_label_init(void)
81 struct jump_label_key_deferred {
82 struct jump_label_key key;
85 static __always_inline bool static_branch(struct jump_label_key *key)
87 if (unlikely(atomic_read(&key->enabled)))
88 return true;
89 return false;
92 static inline void jump_label_inc(struct jump_label_key *key)
94 atomic_inc(&key->enabled);
97 static inline void jump_label_dec(struct jump_label_key *key)
99 atomic_dec(&key->enabled);
102 static inline void jump_label_dec_deferred(struct jump_label_key_deferred *key)
104 jump_label_dec(&key->key);
107 static inline int jump_label_text_reserved(void *start, void *end)
109 return 0;
112 static inline void jump_label_lock(void) {}
113 static inline void jump_label_unlock(void) {}
115 static inline bool jump_label_enabled(struct jump_label_key *key)
117 return !!atomic_read(&key->enabled);
120 static inline int jump_label_apply_nops(struct module *mod)
122 return 0;
125 static inline void jump_label_rate_limit(struct jump_label_key_deferred *key,
126 unsigned long rl)
129 #endif /* HAVE_JUMP_LABEL */
131 #define jump_label_key_enabled ((struct jump_label_key){ .enabled = ATOMIC_INIT(1), })
132 #define jump_label_key_disabled ((struct jump_label_key){ .enabled = ATOMIC_INIT(0), })
134 #endif /* _LINUX_JUMP_LABEL_H */