Re: [PATCH NAND v2] mtd: nand: Replace printk() with appropriate pr_*macro()

From: Shreeya Patel
Date: Tue Feb 20 2018 - 12:06:53 EST


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@xxxxxxxxx> 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@xxxxxxxxx>
> > ---
> >
> > 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, Â"Enable
> > 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


I tried doing undef and then define, but it didn't work.

>
> >
> > Â return 0;
> > Â
> > Âerror10:
> > diff --git a/drivers/mtd/nand/r852.h b/drivers/mtd/nand/r852.h
> > index 8713c57..63de9b6 100644
> > --- a/drivers/mtd/nand/r852.h
> > +++ b/drivers/mtd/nand/r852.h
> > @@ -149,12 +149,12 @@ struct r852_device {
> > Â
> > Â#define dbg(format, ...) \
> > Â if (debug) \
> > - printk(KERN_DEBUG DRV_NAME ": " format "\n", ##
> > __VA_ARGS__)
> > + pr_debug(DRV_NAME ": " format "\n", ##
> > __VA_ARGS__)
> > Â
> > Â#define dbg_verbose(format, ...) \
> > Â if (debug > 1) \
> > - printk(KERN_DEBUG DRV_NAME ": " format "\n", ##
> > __VA_ARGS__)
> > + pr_debug(DRV_NAME ": " format "\n", ##
> > __VA_ARGS__)
> > Â
> And here as well.
>
> Regards,
>
> Boris
>