1010 * Copyright (C) 2011 Bart Van Assche. All Rights Reserved.
1111 */
1212
13+ #define pr_fmt (fmt ) KBUILD_MODNAME ":%s: " fmt, __func__
14+
1315#include <linux/kernel.h>
1416#include <linux/module.h>
1517#include <linux/moduleparam.h>
@@ -160,8 +162,7 @@ static void ddebug_change(const struct ddebug_query *query,
160162 else
161163 dp -> enabled = 0 ;
162164 if (verbose )
163- printk (KERN_INFO
164- "ddebug: changed %s:%d [%s]%s %s\n" ,
165+ pr_info ("changed %s:%d [%s]%s %s\n" ,
165166 dp -> filename , dp -> lineno ,
166167 dt -> mod_name , dp -> function ,
167168 ddebug_describe_flags (dp , flagbuf ,
@@ -171,7 +172,7 @@ static void ddebug_change(const struct ddebug_query *query,
171172 mutex_unlock (& ddebug_lock );
172173
173174 if (!nfound && verbose )
174- printk ( KERN_INFO "ddebug: no matches for query\n" );
175+ pr_info ( " no matches for query\n" );
175176}
176177
177178/*
@@ -216,10 +217,10 @@ static int ddebug_tokenize(char *buf, char *words[], int maxwords)
216217
217218 if (verbose ) {
218219 int i ;
219- printk ( KERN_INFO "%s: split into words:", __func__ );
220+ pr_info ( " split into words:" );
220221 for (i = 0 ; i < nwords ; i ++ )
221- printk (" \"%s\"" , words [i ]);
222- printk ("\n" );
222+ pr_cont (" \"%s\"" , words [i ]);
223+ pr_cont ("\n" );
223224 }
224225
225226 return nwords ;
@@ -331,16 +332,15 @@ static int ddebug_parse_query(char *words[], int nwords,
331332 }
332333 } else {
333334 if (verbose )
334- printk (KERN_ERR "%s: unknown keyword \"%s\"\n" ,
335- __func__ , words [i ]);
335+ pr_err ("unknown keyword \"%s\"\n" , words [i ]);
336336 return - EINVAL ;
337337 }
338338 }
339339
340340 if (verbose )
341- printk ( KERN_INFO "%s: q->function=\"%s\" q->filename=\"%s\" "
342- "q->module=\"%s\" q->format=\"%s\" q->lineno=%u-%u\n" ,
343- __func__ , query -> function , query -> filename ,
341+ pr_info ( " q->function=\"%s\" q->filename=\"%s\" "
342+ "q->module=\"%s\" q->format=\"%s\" q->lineno=%u-%u\n" ,
343+ query -> function , query -> filename ,
344344 query -> module , query -> format , query -> first_lineno ,
345345 query -> last_lineno );
346346
@@ -369,7 +369,7 @@ static int ddebug_parse_flags(const char *str, unsigned int *flagsp,
369369 return - EINVAL ;
370370 }
371371 if (verbose )
372- printk ( KERN_INFO "%s: op='%c'\n", __func__ , op );
372+ pr_info ( " op='%c'\n" , op );
373373
374374 for ( ; * str ; ++ str ) {
375375 for (i = ARRAY_SIZE (opt_array ) - 1 ; i >= 0 ; i -- ) {
@@ -384,7 +384,7 @@ static int ddebug_parse_flags(const char *str, unsigned int *flagsp,
384384 if (flags == 0 )
385385 return - EINVAL ;
386386 if (verbose )
387- printk ( KERN_INFO "%s: flags=0x%x\n", __func__ , flags );
387+ pr_info ( " flags=0x%x\n" , flags );
388388
389389 /* calculate final *flagsp, *maskp according to mask and op */
390390 switch (op ) {
@@ -402,8 +402,7 @@ static int ddebug_parse_flags(const char *str, unsigned int *flagsp,
402402 break ;
403403 }
404404 if (verbose )
405- printk (KERN_INFO "%s: *flagsp=0x%x *maskp=0x%x\n" ,
406- __func__ , * flagsp , * maskp );
405+ pr_info ("*flagsp=0x%x *maskp=0x%x\n" , * flagsp , * maskp );
407406 return 0 ;
408407}
409408
@@ -508,7 +507,7 @@ static __initdata char ddebug_setup_string[1024];
508507static __init int ddebug_setup_query (char * str )
509508{
510509 if (strlen (str ) >= 1024 ) {
511- pr_warning ("ddebug boot param string too large\n" );
510+ pr_warn ("ddebug boot param string too large\n" );
512511 return 0 ;
513512 }
514513 strcpy (ddebug_setup_string , str );
@@ -536,8 +535,7 @@ static ssize_t ddebug_proc_write(struct file *file, const char __user *ubuf,
536535 return - EFAULT ;
537536 tmpbuf [len ] = '\0' ;
538537 if (verbose )
539- printk (KERN_INFO "%s: read %d bytes from userspace\n" ,
540- __func__ , (int )len );
538+ pr_info ("read %d bytes from userspace\n" , (int )len );
541539
542540 ret = ddebug_exec_query (tmpbuf );
543541 if (ret )
@@ -600,8 +598,7 @@ static void *ddebug_proc_start(struct seq_file *m, loff_t *pos)
600598 int n = * pos ;
601599
602600 if (verbose )
603- printk (KERN_INFO "%s: called m=%p *pos=%lld\n" ,
604- __func__ , m , (unsigned long long )* pos );
601+ pr_info ("called m=%p *pos=%lld\n" , m , (unsigned long long )* pos );
605602
606603 mutex_lock (& ddebug_lock );
607604
@@ -626,8 +623,8 @@ static void *ddebug_proc_next(struct seq_file *m, void *p, loff_t *pos)
626623 struct _ddebug * dp ;
627624
628625 if (verbose )
629- printk ( KERN_INFO "%s: called m=%p p=%p *pos=%lld\n" ,
630- __func__ , m , p , (unsigned long long )* pos );
626+ pr_info ( " called m=%p p=%p *pos=%lld\n" ,
627+ m , p , (unsigned long long )* pos );
631628
632629 if (p == SEQ_START_TOKEN )
633630 dp = ddebug_iter_first (iter );
@@ -650,8 +647,7 @@ static int ddebug_proc_show(struct seq_file *m, void *p)
650647 char flagsbuf [8 ];
651648
652649 if (verbose )
653- printk (KERN_INFO "%s: called m=%p p=%p\n" ,
654- __func__ , m , p );
650+ pr_info ("called m=%p p=%p\n" , m , p );
655651
656652 if (p == SEQ_START_TOKEN ) {
657653 seq_puts (m ,
@@ -676,8 +672,7 @@ static int ddebug_proc_show(struct seq_file *m, void *p)
676672static void ddebug_proc_stop (struct seq_file * m , void * p )
677673{
678674 if (verbose )
679- printk (KERN_INFO "%s: called m=%p p=%p\n" ,
680- __func__ , m , p );
675+ pr_info ("called m=%p p=%p\n" , m , p );
681676 mutex_unlock (& ddebug_lock );
682677}
683678
@@ -700,7 +695,7 @@ static int ddebug_proc_open(struct inode *inode, struct file *file)
700695 int err ;
701696
702697 if (verbose )
703- printk ( KERN_INFO "%s: called\n", __func__ );
698+ pr_info ( " called\n" );
704699
705700 iter = kzalloc (sizeof (* iter ), GFP_KERNEL );
706701 if (iter == NULL )
@@ -752,8 +747,7 @@ int ddebug_add_module(struct _ddebug *tab, unsigned int n,
752747 mutex_unlock (& ddebug_lock );
753748
754749 if (verbose )
755- printk (KERN_INFO "%u debug prints in module %s\n" ,
756- n , dt -> mod_name );
750+ pr_info ("%u debug prints in module %s\n" , n , dt -> mod_name );
757751 return 0 ;
758752}
759753EXPORT_SYMBOL_GPL (ddebug_add_module );
@@ -775,8 +769,7 @@ int ddebug_remove_module(const char *mod_name)
775769 int ret = - ENOENT ;
776770
777771 if (verbose )
778- printk (KERN_INFO "%s: removing module \"%s\"\n" ,
779- __func__ , mod_name );
772+ pr_info ("removing module \"%s\"\n" , mod_name );
780773
781774 mutex_lock (& ddebug_lock );
782775 list_for_each_entry_safe (dt , nextdt , & ddebug_tables , link ) {
@@ -852,8 +845,8 @@ static int __init dynamic_debug_init(void)
852845 if (ddebug_setup_string [0 ] != '\0' ) {
853846 ret = ddebug_exec_query (ddebug_setup_string );
854847 if (ret )
855- pr_warning ("Invalid ddebug boot param %s" ,
856- ddebug_setup_string );
848+ pr_warn ("Invalid ddebug boot param %s" ,
849+ ddebug_setup_string );
857850 else
858851 pr_info ("ddebug initialized with string %s" ,
859852 ddebug_setup_string );
0 commit comments