diff options
-rw-r--r-- | Documentation/DocBook/writing-an-alsa-driver.tmpl | 12 | ||||
-rw-r--r-- | include/sound/core.h | 24 |
2 files changed, 13 insertions, 23 deletions
diff --git a/Documentation/DocBook/writing-an-alsa-driver.tmpl b/Documentation/DocBook/writing-an-alsa-driver.tmpl index bd6fee22c4dd..06741e925985 100644 --- a/Documentation/DocBook/writing-an-alsa-driver.tmpl +++ b/Documentation/DocBook/writing-an-alsa-driver.tmpl | |||
@@ -6164,14 +6164,12 @@ struct _snd_pcm_runtime { | |||
6164 | 6164 | ||
6165 | <para> | 6165 | <para> |
6166 | The macro takes an conditional expression to evaluate. | 6166 | The macro takes an conditional expression to evaluate. |
6167 | When <constant>CONFIG_SND_DEBUG</constant>, is set, the | 6167 | When <constant>CONFIG_SND_DEBUG</constant>, is set, if the |
6168 | expression is actually evaluated. If it's non-zero, it shows | 6168 | expression is non-zero, it shows the warning message such as |
6169 | the warning message such as | ||
6170 | <computeroutput>BUG? (xxx)</computeroutput> | 6169 | <computeroutput>BUG? (xxx)</computeroutput> |
6171 | normally followed by stack trace. It returns the evaluated | 6170 | normally followed by stack trace. |
6172 | value. | 6171 | |
6173 | When no <constant>CONFIG_SND_DEBUG</constant> is set, this | 6172 | In both cases it returns the evaluated value. |
6174 | macro always returns zero. | ||
6175 | </para> | 6173 | </para> |
6176 | 6174 | ||
6177 | </section> | 6175 | </section> |
diff --git a/include/sound/core.h b/include/sound/core.h index 7cede2d6aa86..a63680b9819d 100644 --- a/include/sound/core.h +++ b/include/sound/core.h | |||
@@ -379,18 +379,10 @@ void __snd_printk(unsigned int level, const char *file, int line, | |||
379 | * snd_BUG_ON - debugging check macro | 379 | * snd_BUG_ON - debugging check macro |
380 | * @cond: condition to evaluate | 380 | * @cond: condition to evaluate |
381 | * | 381 | * |
382 | * When CONFIG_SND_DEBUG is set, this macro evaluates the given condition, | 382 | * Has the same behavior as WARN_ON when CONFIG_SND_DEBUG is set, |
383 | * and call WARN() and returns the value if it's non-zero. | 383 | * otherwise just evaluates the conditional and returns the value. |
384 | * | ||
385 | * When CONFIG_SND_DEBUG is not set, this just returns zero, and the given | ||
386 | * condition is ignored. | ||
387 | * | ||
388 | * NOTE: the argument won't be evaluated at all when CONFIG_SND_DEBUG=n. | ||
389 | * Thus, don't put any statement that influences on the code behavior, | ||
390 | * such as pre/post increment, to the argument of this macro. | ||
391 | * If you want to evaluate and give a warning, use standard WARN_ON(). | ||
392 | */ | 384 | */ |
393 | #define snd_BUG_ON(cond) WARN((cond), "BUG? (%s)\n", __stringify(cond)) | 385 | #define snd_BUG_ON(cond) WARN_ON((cond)) |
394 | 386 | ||
395 | #else /* !CONFIG_SND_DEBUG */ | 387 | #else /* !CONFIG_SND_DEBUG */ |
396 | 388 | ||
@@ -400,11 +392,11 @@ __printf(2, 3) | |||
400 | static inline void _snd_printd(int level, const char *format, ...) {} | 392 | static inline void _snd_printd(int level, const char *format, ...) {} |
401 | 393 | ||
402 | #define snd_BUG() do { } while (0) | 394 | #define snd_BUG() do { } while (0) |
403 | static inline int __snd_bug_on(int cond) | 395 | |
404 | { | 396 | #define snd_BUG_ON(condition) ({ \ |
405 | return 0; | 397 | int __ret_warn_on = !!(condition); \ |
406 | } | 398 | unlikely(__ret_warn_on); \ |
407 | #define snd_BUG_ON(cond) __snd_bug_on(0 && (cond)) /* always false */ | 399 | }) |
408 | 400 | ||
409 | #endif /* CONFIG_SND_DEBUG */ | 401 | #endif /* CONFIG_SND_DEBUG */ |
410 | 402 | ||