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 | 75 |
3 files changed, 68 insertions, 51 deletions
diff --git a/Documentation/sound/alsa/ALSA-Configuration.txt b/Documentation/sound/alsa/ALSA-Configuration.txt index ad51c93d41e4..1c8eb4518ce0 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 f545efcf03f2..a61499c22b0b 100644 --- a/include/sound/core.h +++ b/include/sound/core.h | |||
| @@ -329,18 +329,17 @@ unsigned int snd_dma_pointer(unsigned long dma, unsigned int size); | |||
| 329 | struct resource; | 329 | struct resource; |
| 330 | void release_and_free_resource(struct resource *res); | 330 | void release_and_free_resource(struct resource *res); |
| 331 | 331 | ||
| 332 | #ifdef CONFIG_SND_VERBOSE_PRINTK | ||
| 333 | void snd_verbose_printk(const char *file, int line, const char *format, ...) | ||
| 334 | __attribute__ ((format (printf, 3, 4))); | ||
| 335 | #endif | ||
| 336 | #if defined(CONFIG_SND_DEBUG) && defined(CONFIG_SND_VERBOSE_PRINTK) | ||
| 337 | void snd_verbose_printd(const char *file, int line, const char *format, ...) | ||
| 338 | __attribute__ ((format (printf, 3, 4))); | ||
| 339 | #endif | ||
| 340 | |||
| 341 | /* --- */ | 332 | /* --- */ |
| 342 | 333 | ||
| 343 | #ifdef CONFIG_SND_VERBOSE_PRINTK | 334 | #if defined(CONFIG_SND_DEBUG) || defined(CONFIG_SND_VERBOSE_PRINTK) |
| 335 | void __snd_printk(unsigned int level, const char *file, int line, | ||
| 336 | const char *format, ...) | ||
| 337 | __attribute__ ((format (printf, 4, 5))); | ||
| 338 | #else | ||
| 339 | #define __snd_printk(level, file, line, format, args...) \ | ||
| 340 | printk(format, ##args) | ||
| 341 | #endif | ||
| 342 | |||
| 344 | /** | 343 | /** |
| 345 | * snd_printk - printk wrapper | 344 | * snd_printk - printk wrapper |
| 346 | * @fmt: format string | 345 | * @fmt: format string |
| @@ -349,15 +348,9 @@ void snd_verbose_printd(const char *file, int line, const char *format, ...) | |||
| 349 | * when configured with CONFIG_SND_VERBOSE_PRINTK. | 348 | * when configured with CONFIG_SND_VERBOSE_PRINTK. |
| 350 | */ | 349 | */ |
| 351 | #define snd_printk(fmt, args...) \ | 350 | #define snd_printk(fmt, args...) \ |
| 352 | snd_verbose_printk(__FILE__, __LINE__, fmt ,##args) | 351 | __snd_printk(0, __FILE__, __LINE__, fmt, ##args) |
| 353 | #else | ||
| 354 | #define snd_printk(fmt, args...) \ | ||
| 355 | printk(fmt ,##args) | ||
| 356 | #endif | ||
| 357 | 352 | ||
| 358 | #ifdef CONFIG_SND_DEBUG | 353 | #ifdef CONFIG_SND_DEBUG |
| 359 | |||
| 360 | #ifdef CONFIG_SND_VERBOSE_PRINTK | ||
| 361 | /** | 354 | /** |
| 362 | * snd_printd - debug printk | 355 | * snd_printd - debug printk |
| 363 | * @fmt: format string | 356 | * @fmt: format string |
| @@ -366,11 +359,7 @@ void snd_verbose_printd(const char *file, int line, const char *format, ...) | |||
| 366 | * Ignored when CONFIG_SND_DEBUG is not set. | 359 | * Ignored when CONFIG_SND_DEBUG is not set. |
| 367 | */ | 360 | */ |
| 368 | #define snd_printd(fmt, args...) \ | 361 | #define snd_printd(fmt, args...) \ |
| 369 | snd_verbose_printd(__FILE__, __LINE__, fmt ,##args) | 362 | __snd_printk(1, __FILE__, __LINE__, fmt, ##args) |
| 370 | #else | ||
| 371 | #define snd_printd(fmt, args...) \ | ||
| 372 | printk(fmt ,##args) | ||
| 373 | #endif | ||
| 374 | 363 | ||
| 375 | /** | 364 | /** |
| 376 | * snd_BUG - give a BUG warning message and stack trace | 365 | * snd_BUG - give a BUG warning message and stack trace |
| @@ -417,9 +406,10 @@ static inline int __snd_bug_on(int cond) | |||
| 417 | * Works like snd_printk() for debugging purposes. | 406 | * Works like snd_printk() for debugging purposes. |
| 418 | * Ignored when CONFIG_SND_DEBUG_VERBOSE is not set. | 407 | * Ignored when CONFIG_SND_DEBUG_VERBOSE is not set. |
| 419 | */ | 408 | */ |
| 420 | #define snd_printdd(format, args...) snd_printk(format, ##args) | 409 | #define snd_printdd(format, args...) \ |
| 410 | __snd_printk(2, __FILE__, __LINE__, format, ##args) | ||
| 421 | #else | 411 | #else |
| 422 | #define snd_printdd(format, args...) /* nothing */ | 412 | #define snd_printdd(format, args...) do { } while (0) |
| 423 | #endif | 413 | #endif |
| 424 | 414 | ||
| 425 | 415 | ||
diff --git a/sound/core/misc.c b/sound/core/misc.c index a9710e0c97af..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,46 +49,53 @@ 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 |
| 38 | void snd_verbose_printk(const char *file, int line, const char *format, ...) | 52 | /* strip the leading path if the given path is absolute */ |
| 53 | static const char *sanity_file_name(const char *path) | ||
| 39 | { | 54 | { |
| 40 | va_list args; | 55 | if (*path == '/') |
| 41 | 56 | return strrchr(path, '/') + 1; | |
| 42 | if (format[0] == '<' && format[1] >= '0' && format[1] <= '7' && format[2] == '>') { | 57 | else |
| 43 | char tmp[] = "<0>"; | 58 | return path; |
| 59 | } | ||
| 60 | |||
| 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) | ||
| 64 | { | ||
| 65 | const char *file = sanity_file_name(path); | ||
| 66 | char tmp[] = "<0>"; | ||
| 67 | const char *pfx = level ? KERN_DEBUG : KERN_DEFAULT; | ||
| 68 | int ret = 0; | ||
| 69 | |||
| 70 | if (format[0] == '<' && format[2] == '>') { | ||
| 44 | tmp[1] = format[1]; | 71 | tmp[1] = format[1]; |
| 45 | printk("%sALSA %s:%d: ", tmp, file, line); | 72 | pfx = tmp; |
| 46 | format += 3; | 73 | ret = 1; |
| 47 | } else { | ||
| 48 | printk("ALSA %s:%d: ", file, line); | ||
| 49 | } | 74 | } |
| 50 | va_start(args, format); | 75 | printk("%sALSA %s:%d: ", pfx, file, line); |
| 51 | vprintk(format, args); | 76 | return ret; |
| 52 | va_end(args); | ||
| 53 | } | 77 | } |
| 54 | 78 | #else | |
| 55 | EXPORT_SYMBOL(snd_verbose_printk); | 79 | #define print_snd_pfx(level, path, line, format) 0 |
| 56 | #endif | 80 | #endif |
| 57 | 81 | ||
| 58 | #if defined(CONFIG_SND_DEBUG) && defined(CONFIG_SND_VERBOSE_PRINTK) | 82 | #if defined(CONFIG_SND_DEBUG) || defined(CONFIG_SND_VERBOSE_PRINTK) |
| 59 | void snd_verbose_printd(const char *file, int line, const char *format, ...) | 83 | void __snd_printk(unsigned int level, const char *path, int line, |
| 84 | const char *format, ...) | ||
| 60 | { | 85 | { |
| 61 | va_list args; | 86 | va_list args; |
| 62 | 87 | ||
| 63 | if (format[0] == '<' && format[1] >= '0' && format[1] <= '7' && format[2] == '>') { | 88 | #ifdef CONFIG_SND_DEBUG |
| 64 | char tmp[] = "<0>"; | 89 | if (debug < level) |
| 65 | tmp[1] = format[1]; | 90 | return; |
| 66 | printk("%sALSA %s:%d: ", tmp, file, line); | 91 | #endif |
| 67 | format += 3; | ||
| 68 | } else { | ||
| 69 | printk(KERN_DEBUG "ALSA %s:%d: ", file, line); | ||
| 70 | } | ||
| 71 | 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 */ | ||
| 72 | vprintk(format, args); | 95 | vprintk(format, args); |
| 73 | va_end(args); | 96 | va_end(args); |
| 74 | |||
| 75 | } | 97 | } |
| 76 | 98 | EXPORT_SYMBOL_GPL(__snd_printk); | |
| 77 | EXPORT_SYMBOL(snd_verbose_printd); | ||
| 78 | #endif | 99 | #endif |
| 79 | 100 | ||
| 80 | #ifdef CONFIG_PCI | 101 | #ifdef CONFIG_PCI |
