ALSA: pcm: Add snd_printd_ratelimit()
authorTim Gardner <tim.gardner@canonical.com>
Fri, 16 Aug 2013 17:18:59 +0000 (11:18 -0600)
committerTakashi Iwai <tiwai@suse.de>
Mon, 19 Aug 2013 13:48:33 +0000 (15:48 +0200)
Direct calls to printk_limit() will emit log noise even when CONFIG_SND_DEBUG is not
defined. Add a wrapper macro around printk_limit() that is conditionally defined by
CONFIG_SND_DEBUG.

Cc: Jaroslav Kysela <perex@perex.cz>
Cc: Takashi Iwai <tiwai@suse.de>
Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Cc: Lars-Peter Clausen <lars@metafoo.de>
Cc: Yacine Belkadi <yacine.belkadi.1@gmail.com>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
include/sound/core.h

index c586617cfa0dffaa2cdce5e548f78fed28e1f63e..2a14f1f02d4f6766e236b288f6173ee7391e78a2 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/rwsem.h>               /* struct rw_semaphore */
 #include <linux/pm.h>                  /* pm_message_t */
 #include <linux/stringify.h>
+#include <linux/printk.h>
 
 /* number of supported soundcards */
 #ifdef CONFIG_SND_DYNAMIC_MINORS
@@ -375,6 +376,11 @@ void __snd_printk(unsigned int level, const char *file, int line,
  */
 #define snd_BUG()              WARN(1, "BUG?\n")
 
+/**
+ * Suppress high rates of output when CONFIG_SND_DEBUG is enabled.
+ */
+#define snd_printd_ratelimit() printk_ratelimit()
+
 /**
  * snd_BUG_ON - debugging check macro
  * @cond: condition to evaluate
@@ -398,6 +404,8 @@ static inline void _snd_printd(int level, const char *format, ...) {}
        unlikely(__ret_warn_on); \
 })
 
+static inline bool snd_printd_ratelimit(void) { return false; }
+
 #endif /* CONFIG_SND_DEBUG */
 
 #ifdef CONFIG_SND_DEBUG_VERBOSE