[PATCH v2 1/3] mtd: mtdoops: change printk() to counterpart pr_ functions

Miquel Raynal miquel.raynal at bootlin.com
Fri Oct 7 00:52:36 PDT 2022


Hi Joe, Ray,

joe at perches.com wrote on Fri, 07 Oct 2022 00:09:26 -0700:

> On Fri, 2022-10-07 at 06:50 +0000, Ray Zhang wrote:
> > To comply with latest kernel code requirement, change printk() to
> > counterpart pr_ functions in mtdoops driver:
> > - change printk(INFO) to pr_info()
> > - change printk(DEBUG) to pr_debug()  
> 
> There is a different behavior with printk(KERN_DEBUG to pr_debug(
> as pr_debug is a no-op unless dynamic debugging is enabled or
> DEBUG is defined.

I didn't know about this difference. I was expecting printk(KERN_DEBUG)
to behave the same as pr_debug/dev_dbg.

> And even with dynamic_debug, the output is default disabled unless
> DEBUG is defined.
> 
> As is, printk(KERN_DEBUG is emitted unless the console level is low.
> 
> > diff --git a/drivers/mtd/mtdoops.c b/drivers/mtd/mtdoops.c  
> []
> > @@ -120,8 +120,8 @@ static void mtdoops_inc_counter(struct mtdoops_context *cxt)
> >  		return;
> >  	}
> >  
> > -	printk(KERN_DEBUG "mtdoops: ready %d, %d (no erase)\n",
> > -	       cxt->nextpage, cxt->nextcount);
> > +	pr_debug("mtdoops: ready %d, %d (no erase)\n",
> > +		 cxt->nextpage, cxt->nextcount);

But honestly in this driver I feel fine changing the printk(KERN_DEBUG)
into pr_debug().

Ray, maybe you can adapt your commit log to mention the difference?

Thanks,
Miquèl



More information about the linux-mtd mailing list