diff options
author | Steven Rostedt <srostedt@redhat.com> | 2011-03-17 15:21:06 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2011-03-25 06:32:09 -0400 |
commit | 2092e6be82ec71ecbf5a8ceeef004bbcbdb78812 (patch) | |
tree | 19dec00f7d1b6e93d9116ec38edba0342b99d689 /include/asm-generic | |
parent | 71f9e59800e5ad4e6b683348424c9fe54306cd43 (diff) |
WARN_ON_SMP(): Allow use in if() statements on UP
Both WARN_ON() and WARN_ON_SMP() should be able to be used in
an if statement.
if (WARN_ON_SMP(foo)) { ... }
Because WARN_ON_SMP() is defined as a do { } while (0) on UP,
it can not be used this way.
Convert it to the same form that WARN_ON() is, even when
CONFIG_SMP is off.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Peter Zijlstra <peterz@infradead.org>
Acked-by: Darren Hart <dvhart@linux.intel.com>
Cc: Lai Jiangshan <laijs@cn.fujitsu.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
LKML-Reference: <20110317192208.444147791@goodmis.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'include/asm-generic')
-rw-r--r-- | include/asm-generic/bug.h | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h index c2c9ba032d46..f2d2faf4d9ae 100644 --- a/include/asm-generic/bug.h +++ b/include/asm-generic/bug.h | |||
@@ -165,10 +165,36 @@ extern void warn_slowpath_null(const char *file, const int line); | |||
165 | #define WARN_ON_RATELIMIT(condition, state) \ | 165 | #define WARN_ON_RATELIMIT(condition, state) \ |
166 | WARN_ON((condition) && __ratelimit(state)) | 166 | WARN_ON((condition) && __ratelimit(state)) |
167 | 167 | ||
168 | /* | ||
169 | * WARN_ON_SMP() is for cases that the warning is either | ||
170 | * meaningless for !SMP or may even cause failures. | ||
171 | * This is usually used for cases that we have | ||
172 | * WARN_ON(!spin_is_locked(&lock)) checks, as spin_is_locked() | ||
173 | * returns 0 for uniprocessor settings. | ||
174 | * It can also be used with values that are only defined | ||
175 | * on SMP: | ||
176 | * | ||
177 | * struct foo { | ||
178 | * [...] | ||
179 | * #ifdef CONFIG_SMP | ||
180 | * int bar; | ||
181 | * #endif | ||
182 | * }; | ||
183 | * | ||
184 | * void func(struct foo *zoot) | ||
185 | * { | ||
186 | * WARN_ON_SMP(!zoot->bar); | ||
187 | * | ||
188 | * For CONFIG_SMP, WARN_ON_SMP() should act the same as WARN_ON(), | ||
189 | * and should be a nop and return false for uniprocessor. | ||
190 | * | ||
191 | * if (WARN_ON_SMP(x)) returns true only when CONFIG_SMP is set | ||
192 | * and x is true. | ||
193 | */ | ||
168 | #ifdef CONFIG_SMP | 194 | #ifdef CONFIG_SMP |
169 | # define WARN_ON_SMP(x) WARN_ON(x) | 195 | # define WARN_ON_SMP(x) WARN_ON(x) |
170 | #else | 196 | #else |
171 | # define WARN_ON_SMP(x) do { } while (0) | 197 | # define WARN_ON_SMP(x) ({0;}) |
172 | #endif | 198 | #endif |
173 | 199 | ||
174 | #endif | 200 | #endif |