linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Shreeya Patel <shreeya.patel23498@gmail.com>
To: Boris Brezillon <boris.brezillon@bootlin.com>
Cc: boris.brezillon@free-electrons.com, richard@nod.at,
	dwmw2@infradead.org, computersforpeace@gmail.com,
	marek.vasut@gmail.com, cyrille.pitchen@wedev4u.fr,
	 maximlevitsky@gmail.com, linux-mtd@lists.infradead.org,
	 linux-kernel@vger.kernel.org, ezequiel@vanguardiasur.com.ar,
	 outreachy-kernel@googlegroups.com
Subject: [Outreachy kernel] Re: [PATCH NAND v2] mtd: nand: Replace printk() with appropriate pr_*macro()
Date: Tue, 20 Feb 2018 23:07:18 +0530	[thread overview]
Message-ID: <1519148238.14621.3.camel@gmail.com> (raw)
In-Reply-To: <20180220181647.6f2367b6@bbrezillon>

On Tue, 2018-02-20 at 18:16 +0100, Boris Brezillon wrote:
> On Tue, 20 Feb 2018 22:36:41 +0530
> Shreeya Patel <shreeya.patel23498@gmail.com> wrote:
> 
> > 
> > On Mon, 2018-02-19 at 15:51 +0100, Boris Brezillon wrote:
> > > 
> > > Hi Shreeya,
> > > 
> > > On Mon, 19 Feb 2018 18:43:45 +0530
> > > Shreeya Patel <shreeya.patel23498@gmail.com> wrote:
> > >   
> > > > 
> > > > 
> > > > The log levels embedded with the name are more concise than
> > > > printk.
> > > > Replace printks having a log level with the appropriate
> > > > pr_*macro.
> > > > 
> > > > Signed-off-by: Shreeya Patel <shreeya.patel23498@gmail.com>
> > > > ---
> > > > 
> > > > Changes in v2:
> > > >   -Merge previous patches of the patchset regarding replacement
> > > > of printk with pr_*macro, into single patch.
> > > > 
> > > > 
> > > >  drivers/mtd/nand/cs553x_nand.c   |  9 ++---
> > > >  drivers/mtd/nand/diskonchip.c    | 76 +++++++++++++++++++++---
> > > > ----
> > > > ------------
> > > >  drivers/mtd/nand/fsl_elbc_nand.c |  2 +-
> > > >  drivers/mtd/nand/fsl_ifc_nand.c  |  2 +-
> > > >  drivers/mtd/nand/mxc_nand.c      |  2 +-
> > > >  drivers/mtd/nand/nand_bch.c      | 12 +++----
> > > >  drivers/mtd/nand/nandsim.c       | 10 +++---
> > > >  drivers/mtd/nand/r852.c          |  2 +-
> > > >  drivers/mtd/nand/r852.h          |  6 ++--
> > > >  drivers/mtd/nand/sm_common.c     |  5 ++-
> > > >  10 files changed, 65 insertions(+), 61 deletions(-)
> > > >   
> > > [...]
> > >   
> > > > 
> > > > 
> > > >  
> > > > diff --git a/drivers/mtd/nand/diskonchip.c
> > > > b/drivers/mtd/nand/diskonchip.c
> > > > index c3aa53c..b97d88c 100644
> > > > --- a/drivers/mtd/nand/diskonchip.c
> > > > +++ b/drivers/mtd/nand/diskonchip.c  
> > > [...]
> > >   
> > > > 
> > > > 
> > > > @@ -438,7 +438,7 @@ static void __init
> > > > doc2000_count_chips(struct
> > > > mtd_info *mtd)
> > > >  			break;
> > > >  	}
> > > >  	doc->chips_per_floor = i;
> > > > -	printk(KERN_DEBUG "Detected %d chips per floor.\n",
> > > > i);
> > > > +	pr_info("Detected %d chips per floor.\n", i);  
> > > Should be pr_debug() here.
> > >   
> > > > 
> > > > 
> > > >  }
> > > >    
> > > [...]
> > >   
> > > > 
> > > > 
> > > > diff --git a/drivers/mtd/nand/nandsim.c
> > > > b/drivers/mtd/nand/nandsim.c
> > > > index 246b439..4e5f817 100644
> > > > --- a/drivers/mtd/nand/nandsim.c
> > > > +++ b/drivers/mtd/nand/nandsim.c
> > > > @@ -184,15 +184,15 @@ MODULE_PARM_DESC(bch,		 "En
> > > > able
> > > > BCH ecc and set how many bits should "
> > > >  
> > > >  /* Simulator's output macros (logging, debugging, warning,
> > > > error)
> > > > */
> > > >  #define NS_LOG(args...) \
> > > > -	do { if (log) printk(KERN_DEBUG NS_OUTPUT_PREFIX "
> > > > log: "
> > > > args); } while(0)
> > > > +	do { if (log) pr_debug(NS_OUTPUT_PREFIX " log: "
> > > > args); }
> > > > while(0)  
> > > You could define pr_fmt() to avoid passing NS_OUTPUT_PREFIX.
> > > Something
> > > like:
> > > 
> > > #define pr_fmt(fmt)	"[nandsim]" fmt
> > > 
> > > (remember to put this definition before include directives).
> > > 
> > > Then, all you have to do is
> > > 
> > > do { if (log) pr_debug(" log: " args); } while(0)
> > >   
> > > > 
> > > > 
> > > >  #define NS_DBG(args...) \
> > > > -	do { if (dbg) printk(KERN_DEBUG NS_OUTPUT_PREFIX "
> > > > debug:
> > > > " args); } while(0)
> > > > +	do { if (dbg) pr_debug(NS_OUTPUT_PREFIX " debug: "
> > > > args);
> > > > } while(0)
> > > >  #define NS_WARN(args...) \
> > > > -	do { printk(KERN_WARNING NS_OUTPUT_PREFIX " warning: "
> > > > args); } while(0)
> > > > +	do { pr_warn(NS_OUTPUT_PREFIX " warning: " args); }
> > > > while(0)
> > > >  #define NS_ERR(args...) \
> > > > -	do { printk(KERN_ERR NS_OUTPUT_PREFIX " error: "
> > > > args); }
> > > > while(0)
> > > > +	do { pr_err(NS_OUTPUT_PREFIX " error: " args); }
> > > > while(0)
> > > >  #define NS_INFO(args...) \
> > > > -	do { printk(KERN_INFO NS_OUTPUT_PREFIX " " args); }
> > > > while(0)
> > > > +	do { pr_info(NS_OUTPUT_PREFIX " " args); } while(0)
> > > >  
> > > >  /* Busy-wait delay macros (microseconds, milliseconds) */
> > > >  #define NS_UDELAY(us) \
> > > > diff --git a/drivers/mtd/nand/r852.c b/drivers/mtd/nand/r852.c
> > > > index fc9287a..3d54c6a 100644
> > > > --- a/drivers/mtd/nand/r852.c
> > > > +++ b/drivers/mtd/nand/r852.c
> > > > @@ -935,7 +935,7 @@ static int  r852_probe(struct pci_dev
> > > > *pci_dev,
> > > > const struct pci_device_id *id)
> > > >  		&dev->card_detect_work, 0);
> > > >  
> > > >  
> > > > -	printk(KERN_NOTICE DRV_NAME ": driver loaded
> > > > successfully\n");
> > > > +	pr_notice(DRV_NAME ": driver loaded
> > > > successfully\n");  
> > > Same here:
> > > 
> > > #define pr_fmt(fmt)	DRV_NAME fmt  
> > I am facing the following errors here.
> > 
> > 
> > 
> > In file included from drivers/mtd/nand/r852.c:22:0:
> > drivers/mtd/nand/r852.h:148:0: warning: "pr_fmt" redefined
> >  #define pr_fmt(fmt)  (DRV_NAME fmt)
> >  ^
> > In file included from ./include/linux/kernel.h:14:0,
> >                  from drivers/mtd/nand/r852.c:10:
> > ./include/linux/printk.h:287:0: note: this is the location of the
> > previous definition
> >  #define pr_fmt(fmt) fmt
> That's because you didn't define pr_fmt() before all the #include
> directives in this driver. See the '#indef pr_fmt' statement in
> printk.h
> which is preventing redefinition of this symbol if the file including
> printk.h (either directly or indirectly) already defines it.

Yes, and that is why I did undef before defining it again in the r852.c
file.
Shouldn't it work in this manner?

> 

-- 
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to outreachy-kernel+unsubscribe@googlegroups.com.
To post to this group, send email to outreachy-kernel@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/1519148238.14621.3.camel%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

  reply	other threads:[~2018-02-20 17:37 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-19 13:13 [Outreachy kernel] [PATCH NAND v2] mtd: nand: Replace printk() with appropriate pr_*macro() Shreeya Patel
2018-02-19 13:30 ` [Outreachy kernel] " Richard Weinberger
2018-02-19 13:40   ` Shreeya Patel
2018-02-19 14:51 ` Boris Brezillon
2018-02-19 14:55   ` Boris Brezillon
2018-02-20 17:06   ` Shreeya Patel
2018-02-20 17:16     ` Boris Brezillon
2018-02-20 17:37       ` Shreeya Patel [this message]
2018-02-20 19:20         ` Boris Brezillon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1519148238.14621.3.camel@gmail.com \
    --to=shreeya.patel23498@gmail.com \
    --cc=boris.brezillon@bootlin.com \
    --cc=boris.brezillon@free-electrons.com \
    --cc=computersforpeace@gmail.com \
    --cc=cyrille.pitchen@wedev4u.fr \
    --cc=dwmw2@infradead.org \
    --cc=ezequiel@vanguardiasur.com.ar \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=marek.vasut@gmail.com \
    --cc=maximlevitsky@gmail.com \
    --cc=outreachy-kernel@googlegroups.com \
    --cc=richard@nod.at \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).