Commit 890ee02ac12c02c4712b6d7dd062ff4d6d37691c
1 parent
c0a20263db
Exists in
master
and in
4 other branches
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>
Showing 1 changed file with 17 additions and 23 deletions Side-by-side Diff
sound/core/misc.c
... | ... | @@ -58,26 +58,6 @@ |
58 | 58 | else |
59 | 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 | 61 | #endif |
82 | 62 | |
83 | 63 | #if defined(CONFIG_SND_DEBUG) || defined(CONFIG_SND_VERBOSE_PRINTK) |
84 | 64 | |
85 | 65 | |
86 | 66 | |
... | ... | @@ -85,15 +65,29 @@ |
85 | 65 | const char *format, ...) |
86 | 66 | { |
87 | 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 | 73 | #ifdef CONFIG_SND_DEBUG |
90 | 74 | if (debug < level) |
91 | 75 | return; |
92 | 76 | #endif |
77 | + | |
93 | 78 | va_start(args, format); |
94 | - if (print_snd_pfx(level, path, line, format)) | |
95 | - format += 3; /* skip the printk level-prefix */ | |
79 | +#ifdef CONFIG_SND_VERBOSE_PRINTK | |
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 | 89 | vprintk(format, args); |
90 | +#endif | |
97 | 91 | va_end(args); |
98 | 92 | } |
99 | 93 | EXPORT_SYMBOL_GPL(__snd_printk); |