diff options
| author | David S. Miller <davem@davemloft.net> | 2009-09-11 23:35:13 -0400 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2009-09-11 23:35:13 -0400 |
| commit | cabc5c0f7fa1342049042d6e147db5a73773955b (patch) | |
| tree | 2be09ae1777d580c7dfe05d6d5b76e57281ec447 /sound/core/misc.c | |
| parent | b73d884756303316ead4cd7dad51236b2a515a1a (diff) | |
| parent | 86d710146fb9975f04c505ec78caa43d227c1018 (diff) | |
Merge branch 'master' of /home/davem/src/GIT/linux-2.6/
Conflicts:
arch/sparc/Kconfig
Diffstat (limited to 'sound/core/misc.c')
| -rw-r--r-- | sound/core/misc.c | 75 |
1 files changed, 48 insertions, 27 deletions
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 |
