diff options
-rw-r--r-- | Documentation/sound/alsa/ALSA-Configuration.txt | 6 | ||||
-rw-r--r-- | include/sound/core.h | 38 | ||||
-rw-r--r-- | sound/core/misc.c | 67 |
3 files changed, 59 insertions, 52 deletions
diff --git a/Documentation/sound/alsa/ALSA-Configuration.txt b/Documentation/sound/alsa/ALSA-Configuration.txt index 4252697a95d6..8e5b3488b370 100644 --- a/Documentation/sound/alsa/ALSA-Configuration.txt +++ b/Documentation/sound/alsa/ALSA-Configuration.txt | |||
@@ -60,6 +60,12 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. | |||
60 | slots - Reserve the slot index for the given driver. | 60 | slots - Reserve the slot index for the given driver. |
61 | This option takes multiple strings. | 61 | This option takes multiple strings. |
62 | See "Module Autoloading Support" section for details. | 62 | See "Module Autoloading Support" section for details. |
63 | debug - Specifies the debug message level | ||
64 | (0 = disable debug prints, 1 = normal debug messages, | ||
65 | 2 = verbose debug messages) | ||
66 | This option appears only when CONFIG_SND_DEBUG=y. | ||
67 | This option can be dynamically changed via sysfs | ||
68 | /sys/modules/snd/parameters/debug file. | ||
63 | 69 | ||
64 | Module snd-pcm-oss | 70 | Module snd-pcm-oss |
65 | ------------------ | 71 | ------------------ |
diff --git a/include/sound/core.h b/include/sound/core.h index 309cb9659a05..a89728db5584 100644 --- a/include/sound/core.h +++ b/include/sound/core.h | |||
@@ -340,18 +340,17 @@ unsigned int snd_dma_pointer(unsigned long dma, unsigned int size); | |||
340 | struct resource; | 340 | struct resource; |
341 | void release_and_free_resource(struct resource *res); | 341 | void release_and_free_resource(struct resource *res); |
342 | 342 | ||
343 | #ifdef CONFIG_SND_VERBOSE_PRINTK | ||
344 | void snd_verbose_printk(const char *file, int line, const char *format, ...) | ||
345 | __attribute__ ((format (printf, 3, 4))); | ||
346 | #endif | ||
347 | #if defined(CONFIG_SND_DEBUG) && defined(CONFIG_SND_VERBOSE_PRINTK) | ||
348 | void snd_verbose_printd(const char *file, int line, const char *format, ...) | ||
349 | __attribute__ ((format (printf, 3, 4))); | ||
350 | #endif | ||
351 | |||
352 | /* --- */ | 343 | /* --- */ |
353 | 344 | ||
354 | #ifdef CONFIG_SND_VERBOSE_PRINTK | 345 | #if defined(CONFIG_SND_DEBUG) || defined(CONFIG_SND_VERBOSE_PRINTK) |
346 | void __snd_printk(unsigned int level, const char *file, int line, | ||
347 | const char *format, ...) | ||
348 | __attribute__ ((format (printf, 4, 5))); | ||
349 | #else | ||
350 | #define __snd_printk(level, file, line, format, args...) \ | ||
351 | prinkt(format, ##args) | ||
352 | #endif | ||
353 | |||
355 | /** | 354 | /** |
356 | * snd_printk - printk wrapper | 355 | * snd_printk - printk wrapper |
357 | * @fmt: format string | 356 | * @fmt: format string |
@@ -360,15 +359,9 @@ void snd_verbose_printd(const char *file, int line, const char *format, ...) | |||
360 | * when configured with CONFIG_SND_VERBOSE_PRINTK. | 359 | * when configured with CONFIG_SND_VERBOSE_PRINTK. |
361 | */ | 360 | */ |
362 | #define snd_printk(fmt, args...) \ | 361 | #define snd_printk(fmt, args...) \ |
363 | snd_verbose_printk(__FILE__, __LINE__, fmt ,##args) | 362 | __snd_printk(0, __FILE__, __LINE__, fmt, ##args) |
364 | #else | ||
365 | #define snd_printk(fmt, args...) \ | ||
366 | printk(fmt ,##args) | ||
367 | #endif | ||
368 | 363 | ||
369 | #ifdef CONFIG_SND_DEBUG | 364 | #ifdef CONFIG_SND_DEBUG |
370 | |||
371 | #ifdef CONFIG_SND_VERBOSE_PRINTK | ||
372 | /** | 365 | /** |
373 | * snd_printd - debug printk | 366 | * snd_printd - debug printk |
374 | * @fmt: format string | 367 | * @fmt: format string |
@@ -377,11 +370,7 @@ void snd_verbose_printd(const char *file, int line, const char *format, ...) | |||
377 | * Ignored when CONFIG_SND_DEBUG is not set. | 370 | * Ignored when CONFIG_SND_DEBUG is not set. |
378 | */ | 371 | */ |
379 | #define snd_printd(fmt, args...) \ | 372 | #define snd_printd(fmt, args...) \ |
380 | snd_verbose_printd(__FILE__, __LINE__, fmt ,##args) | 373 | __snd_printk(1, __FILE__, __LINE__, fmt, ##args) |
381 | #else | ||
382 | #define snd_printd(fmt, args...) \ | ||
383 | printk(fmt ,##args) | ||
384 | #endif | ||
385 | 374 | ||
386 | /** | 375 | /** |
387 | * snd_BUG - give a BUG warning message and stack trace | 376 | * snd_BUG - give a BUG warning message and stack trace |
@@ -428,9 +417,10 @@ static inline int __snd_bug_on(int cond) | |||
428 | * Works like snd_printk() for debugging purposes. | 417 | * Works like snd_printk() for debugging purposes. |
429 | * Ignored when CONFIG_SND_DEBUG_VERBOSE is not set. | 418 | * Ignored when CONFIG_SND_DEBUG_VERBOSE is not set. |
430 | */ | 419 | */ |
431 | #define snd_printdd(format, args...) snd_printk(format, ##args) | 420 | #define snd_printdd(format, args...) \ |
421 | __snd_printk(2, __FILE__, __LINE__, format, ##args) | ||
432 | #else | 422 | #else |
433 | #define snd_printdd(format, args...) /* nothing */ | 423 | #define snd_printdd(format, args...) do { } while (0) |
434 | #endif | 424 | #endif |
435 | 425 | ||
436 | 426 | ||
diff --git a/sound/core/misc.c b/sound/core/misc.c index 1d29e678369e..23a032c6d487 100644 --- a/sound/core/misc.c +++ b/sound/core/misc.c | |||
@@ -24,6 +24,20 @@ | |||
24 | #include <linux/ioport.h> | 24 | #include <linux/ioport.h> |
25 | #include <sound/core.h> | 25 | #include <sound/core.h> |
26 | 26 | ||
27 | #ifdef CONFIG_SND_DEBUG | ||
28 | |||
29 | #ifdef CONFIG_SND_DEBUG_VERBOSE | ||
30 | #define DEFAULT_DEBUG_LEVEL 2 | ||
31 | #else | ||
32 | #define DEFAULT_DEBUG_LEVEL 1 | ||
33 | #endif | ||
34 | |||
35 | static int debug = DEFAULT_DEBUG_LEVEL; | ||
36 | module_param(debug, int, 0644); | ||
37 | MODULE_PARM_DESC(debug, "Debug level (0 = disable)"); | ||
38 | |||
39 | #endif /* CONFIG_SND_DEBUG */ | ||
40 | |||
27 | void release_and_free_resource(struct resource *res) | 41 | void release_and_free_resource(struct resource *res) |
28 | { | 42 | { |
29 | if (res) { | 43 | if (res) { |
@@ -35,6 +49,7 @@ void release_and_free_resource(struct resource *res) | |||
35 | EXPORT_SYMBOL(release_and_free_resource); | 49 | EXPORT_SYMBOL(release_and_free_resource); |
36 | 50 | ||
37 | #ifdef CONFIG_SND_VERBOSE_PRINTK | 51 | #ifdef CONFIG_SND_VERBOSE_PRINTK |
52 | /* strip the leading path if the given path is absolute */ | ||
38 | static const char *sanity_file_name(const char *path) | 53 | static const char *sanity_file_name(const char *path) |
39 | { | 54 | { |
40 | if (*path == '/') | 55 | if (*path == '/') |
@@ -43,48 +58,44 @@ static const char *sanity_file_name(const char *path) | |||
43 | return path; | 58 | return path; |
44 | } | 59 | } |
45 | 60 | ||
46 | void snd_verbose_printk(const char *path, int line, const char *format, ...) | 61 | /* print file and line with a certain printk prefix */ |
62 | static int print_snd_pfx(unsigned int level, const char *path, int line, | ||
63 | const char *format) | ||
47 | { | 64 | { |
48 | const char *file = sanity_file_name(path); | 65 | const char *file = sanity_file_name(path); |
49 | va_list args; | 66 | char tmp[] = "<0>"; |
50 | 67 | const char *pfx = level ? KERN_DEBUG : KERN_DEFAULT; | |
51 | if (format[0] == '<' && format[1] >= '0' && format[1] <= '7' && format[2] == '>') { | 68 | int ret = 0; |
52 | char tmp[] = "<0>"; | 69 | |
70 | if (format[0] == '<' && format[2] == '>') { | ||
53 | tmp[1] = format[1]; | 71 | tmp[1] = format[1]; |
54 | printk("%sALSA %s:%d: ", tmp, file, line); | 72 | pfx = tmp; |
55 | format += 3; | 73 | ret = 1; |
56 | } else { | ||
57 | printk("ALSA %s:%d: ", file, line); | ||
58 | } | 74 | } |
59 | va_start(args, format); | 75 | printk("%sALSA %s:%d: ", pfx, file, line); |
60 | vprintk(format, args); | 76 | return ret; |
61 | va_end(args); | ||
62 | } | 77 | } |
63 | 78 | #else | |
64 | EXPORT_SYMBOL(snd_verbose_printk); | 79 | #define print_snd_pfx(level, path, line, format) 0 |
65 | #endif | 80 | #endif |
66 | 81 | ||
67 | #if defined(CONFIG_SND_DEBUG) && defined(CONFIG_SND_VERBOSE_PRINTK) | 82 | #if defined(CONFIG_SND_DEBUG) || defined(CONFIG_SND_VERBOSE_PRINTK) |
68 | void snd_verbose_printd(const char *path, int line, const char *format, ...) | 83 | void __snd_printk(unsigned int level, const char *path, int line, |
84 | const char *format, ...) | ||
69 | { | 85 | { |
70 | const char *file = sanity_file_name(path); | ||
71 | va_list args; | 86 | va_list args; |
72 | 87 | ||
73 | if (format[0] == '<' && format[1] >= '0' && format[1] <= '7' && format[2] == '>') { | 88 | #ifdef CONFIG_SND_DEBUG |
74 | char tmp[] = "<0>"; | 89 | if (debug < level) |
75 | tmp[1] = format[1]; | 90 | return; |
76 | printk("%sALSA %s:%d: ", tmp, file, line); | 91 | #endif |
77 | format += 3; | ||
78 | } else { | ||
79 | printk(KERN_DEBUG "ALSA %s:%d: ", file, line); | ||
80 | } | ||
81 | va_start(args, format); | 92 | va_start(args, format); |
93 | if (print_snd_pfx(level, path, line, format)) | ||
94 | format += 3; /* skip the printk level-prefix */ | ||
82 | vprintk(format, args); | 95 | vprintk(format, args); |
83 | va_end(args); | 96 | va_end(args); |
84 | |||
85 | } | 97 | } |
86 | 98 | EXPORT_SYMBOL_GPL(__snd_printk); | |
87 | EXPORT_SYMBOL(snd_verbose_printd); | ||
88 | #endif | 99 | #endif |
89 | 100 | ||
90 | #ifdef CONFIG_PCI | 101 | #ifdef CONFIG_PCI |