diff options
author | Takashi Iwai <tiwai@suse.de> | 2011-06-10 09:32:31 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2011-06-10 09:35:20 -0400 |
commit | 890ee02ac12c02c4712b6d7dd062ff4d6d37691c (patch) | |
tree | 7f3dce992c573590c0c0c1bb3013fef5acb25404 /sound | |
parent | c0a20263dbe1fc5f394913d71063c9cd8282c5db (diff) |
ALSA: Use %pV for snd_printk()
Clean up snd_printk() helper using the %pV prefix for recursive printks.
This also automagically fixes an Oops with RO/NX-enabled modules.
Tested-by: Maarten Lankhorst <m.b.lankhorst@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/core/misc.c | 40 |
1 files changed, 17 insertions, 23 deletions
diff --git a/sound/core/misc.c b/sound/core/misc.c index 2c41825c836e..eb9fe2e1d291 100644 --- a/sound/core/misc.c +++ b/sound/core/misc.c | |||
@@ -58,26 +58,6 @@ static const char *sanity_file_name(const char *path) | |||
58 | else | 58 | else |
59 | return path; | 59 | return path; |
60 | } | 60 | } |
61 | |||
62 | /* print file and line with a certain printk prefix */ | ||
63 | static int print_snd_pfx(unsigned int level, const char *path, int line, | ||
64 | const char *format) | ||
65 | { | ||
66 | const char *file = sanity_file_name(path); | ||
67 | char tmp[] = "<0>"; | ||
68 | const char *pfx = level ? KERN_DEBUG : KERN_DEFAULT; | ||
69 | int ret = 0; | ||
70 | |||
71 | if (format[0] == '<' && format[2] == '>') { | ||
72 | tmp[1] = format[1]; | ||
73 | pfx = tmp; | ||
74 | ret = 1; | ||
75 | } | ||
76 | printk("%sALSA %s:%d: ", pfx, file, line); | ||
77 | return ret; | ||
78 | } | ||
79 | #else | ||
80 | #define print_snd_pfx(level, path, line, format) 0 | ||
81 | #endif | 61 | #endif |
82 | 62 | ||
83 | #if defined(CONFIG_SND_DEBUG) || defined(CONFIG_SND_VERBOSE_PRINTK) | 63 | #if defined(CONFIG_SND_DEBUG) || defined(CONFIG_SND_VERBOSE_PRINTK) |
@@ -85,15 +65,29 @@ void __snd_printk(unsigned int level, const char *path, int line, | |||
85 | const char *format, ...) | 65 | const char *format, ...) |
86 | { | 66 | { |
87 | va_list args; | 67 | va_list args; |
88 | 68 | #ifdef CONFIG_SND_VERBOSE_PRINTK | |
69 | struct va_format vaf; | ||
70 | char verbose_fmt[] = KERN_DEFAULT "ALSA %s:%d %pV"; | ||
71 | #endif | ||
72 | |||
89 | #ifdef CONFIG_SND_DEBUG | 73 | #ifdef CONFIG_SND_DEBUG |
90 | if (debug < level) | 74 | if (debug < level) |
91 | return; | 75 | return; |
92 | #endif | 76 | #endif |
77 | |||
93 | va_start(args, format); | 78 | va_start(args, format); |
94 | if (print_snd_pfx(level, path, line, format)) | 79 | #ifdef CONFIG_SND_VERBOSE_PRINTK |
95 | format += 3; /* skip the printk level-prefix */ | 80 | vaf.fmt = format; |
81 | vaf.va = &args; | ||
82 | if (format[0] == '<' && format[2] == '>') { | ||
83 | memcpy(verbose_fmt, format, 3); | ||
84 | vaf.fmt = format + 3; | ||
85 | } else if (level) | ||
86 | memcpy(verbose_fmt, KERN_DEBUG, 3); | ||
87 | printk(verbose_fmt, sanity_file_name(path), line, &vaf); | ||
88 | #else | ||
96 | vprintk(format, args); | 89 | vprintk(format, args); |
90 | #endif | ||
97 | va_end(args); | 91 | va_end(args); |
98 | } | 92 | } |
99 | EXPORT_SYMBOL_GPL(__snd_printk); | 93 | EXPORT_SYMBOL_GPL(__snd_printk); |