diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/asm-generic/bug.h | 40 | ||||
-rw-r--r-- | include/linux/ratelimit.h | 40 |
2 files changed, 40 insertions, 40 deletions
diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h index 91784841e407..dfb0ec666c94 100644 --- a/include/asm-generic/bug.h +++ b/include/asm-generic/bug.h | |||
@@ -162,46 +162,6 @@ extern void warn_slowpath_null(const char *file, const int line); | |||
162 | unlikely(__ret_warn_once); \ | 162 | unlikely(__ret_warn_once); \ |
163 | }) | 163 | }) |
164 | 164 | ||
165 | #ifdef CONFIG_PRINTK | ||
166 | |||
167 | #define WARN_ON_RATELIMIT(condition, state) \ | ||
168 | WARN_ON((condition) && __ratelimit(state)) | ||
169 | |||
170 | #define __WARN_RATELIMIT(condition, state, format...) \ | ||
171 | ({ \ | ||
172 | int rtn = 0; \ | ||
173 | if (unlikely(__ratelimit(state))) \ | ||
174 | rtn = WARN(condition, format); \ | ||
175 | rtn; \ | ||
176 | }) | ||
177 | |||
178 | #define WARN_RATELIMIT(condition, format...) \ | ||
179 | ({ \ | ||
180 | static DEFINE_RATELIMIT_STATE(_rs, \ | ||
181 | DEFAULT_RATELIMIT_INTERVAL, \ | ||
182 | DEFAULT_RATELIMIT_BURST); \ | ||
183 | __WARN_RATELIMIT(condition, &_rs, format); \ | ||
184 | }) | ||
185 | |||
186 | #else | ||
187 | |||
188 | #define WARN_ON_RATELIMIT(condition, state) \ | ||
189 | WARN_ON(condition) | ||
190 | |||
191 | #define __WARN_RATELIMIT(condition, state, format...) \ | ||
192 | ({ \ | ||
193 | int rtn = WARN(condition, format); \ | ||
194 | rtn; \ | ||
195 | }) | ||
196 | |||
197 | #define WARN_RATELIMIT(condition, format...) \ | ||
198 | ({ \ | ||
199 | int rtn = WARN(condition, format); \ | ||
200 | rtn; \ | ||
201 | }) | ||
202 | |||
203 | #endif | ||
204 | |||
205 | /* | 165 | /* |
206 | * WARN_ON_SMP() is for cases that the warning is either | 166 | * WARN_ON_SMP() is for cases that the warning is either |
207 | * meaningless for !SMP or may even cause failures. | 167 | * meaningless for !SMP or may even cause failures. |
diff --git a/include/linux/ratelimit.h b/include/linux/ratelimit.h index 03ff67b0cdf5..2f007157fab9 100644 --- a/include/linux/ratelimit.h +++ b/include/linux/ratelimit.h | |||
@@ -41,4 +41,44 @@ extern struct ratelimit_state printk_ratelimit_state; | |||
41 | extern int ___ratelimit(struct ratelimit_state *rs, const char *func); | 41 | extern int ___ratelimit(struct ratelimit_state *rs, const char *func); |
42 | #define __ratelimit(state) ___ratelimit(state, __func__) | 42 | #define __ratelimit(state) ___ratelimit(state, __func__) |
43 | 43 | ||
44 | #ifdef CONFIG_PRINTK | ||
45 | |||
46 | #define WARN_ON_RATELIMIT(condition, state) \ | ||
47 | WARN_ON((condition) && __ratelimit(state)) | ||
48 | |||
49 | #define __WARN_RATELIMIT(condition, state, format...) \ | ||
50 | ({ \ | ||
51 | int rtn = 0; \ | ||
52 | if (unlikely(__ratelimit(state))) \ | ||
53 | rtn = WARN(condition, format); \ | ||
54 | rtn; \ | ||
55 | }) | ||
56 | |||
57 | #define WARN_RATELIMIT(condition, format...) \ | ||
58 | ({ \ | ||
59 | static DEFINE_RATELIMIT_STATE(_rs, \ | ||
60 | DEFAULT_RATELIMIT_INTERVAL, \ | ||
61 | DEFAULT_RATELIMIT_BURST); \ | ||
62 | __WARN_RATELIMIT(condition, &_rs, format); \ | ||
63 | }) | ||
64 | |||
65 | #else | ||
66 | |||
67 | #define WARN_ON_RATELIMIT(condition, state) \ | ||
68 | WARN_ON(condition) | ||
69 | |||
70 | #define __WARN_RATELIMIT(condition, state, format...) \ | ||
71 | ({ \ | ||
72 | int rtn = WARN(condition, format); \ | ||
73 | rtn; \ | ||
74 | }) | ||
75 | |||
76 | #define WARN_RATELIMIT(condition, format...) \ | ||
77 | ({ \ | ||
78 | int rtn = WARN(condition, format); \ | ||
79 | rtn; \ | ||
80 | }) | ||
81 | |||
82 | #endif | ||
83 | |||
44 | #endif /* _LINUX_RATELIMIT_H */ | 84 | #endif /* _LINUX_RATELIMIT_H */ |