Message ID | 1460114003-19926-1-git-send-email-zajec5@gmail.com (mailing list archive) |
---|---|
State | Not Applicable |
Headers | show |
On Fri, 2016-04-08 at 13:13 +0200, Rafał Miłecki wrote: > 1) Use pr_fmt to keep messages consistent > 2) Don't warn if kzalloc fails as it dumps stack on its own > 3) Use %pR format for displaying whole resource to avoid: > warning: format ‘%08llx’ expects type ‘long long unsigned int’, but > argument 2 has type ‘resource_size_t’ thanks
On Fri, Apr 8, 2016 at 2:13 PM, Rafał Miłecki <zajec5@gmail.com> wrote: > 1) Use pr_fmt to keep messages consistent > 2) Don't warn if kzalloc fails as it dumps stack on its own > 3) Use %pR format for displaying whole resource to avoid: > warning: format ‘%08llx’ expects type ‘long long unsigned int’, but argument 2 has type ‘resource_size_t’ > > Signed-off-by: Rafał Miłecki <zajec5@gmail.com> > --- > drivers/mtd/nand/pasemi_nand.c | 9 ++++----- > 1 file changed, 4 insertions(+), 5 deletions(-) > > diff --git a/drivers/mtd/nand/pasemi_nand.c b/drivers/mtd/nand/pasemi_nand.c > index 63fcb8c..e8372b4 100644 > --- a/drivers/mtd/nand/pasemi_nand.c > +++ b/drivers/mtd/nand/pasemi_nand.c > @@ -22,6 +22,8 @@ > > #undef DEBUG > > +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt > + > #include <linux/slab.h> > #include <linux/module.h> > #include <linux/mtd/mtd.h> > @@ -112,8 +114,6 @@ static int pasemi_nand_probe(struct platform_device *ofdev) > /* Allocate memory for MTD device structure and private data */ > chip = kzalloc(sizeof(struct nand_chip), GFP_KERNEL); > if (!chip) { > - printk(KERN_WARNING > - "Unable to allocate PASEMI NAND MTD device structure\n"); > err = -ENOMEM; > goto out; > } > @@ -163,13 +163,12 @@ static int pasemi_nand_probe(struct platform_device *ofdev) > } > > if (mtd_device_register(pasemi_nand_mtd, NULL, 0)) { > - printk(KERN_ERR "pasemi_nand: Unable to register MTD device\n"); > + pr_err("Unable to register MTD device\n"); And why not to use dev_err(&ofdev->dev, …); ? > err = -ENODEV; > goto out_lpc; > } > > - printk(KERN_INFO "PA Semi NAND flash at %08llx, control at I/O %x\n", > - res.start, lpcctl); > + pr_info("PA Semi NAND flash at %pR, control at I/O %x\n", &res, lpcctl); > Ditto. > return 0; > > -- > 1.8.4.5 >
Hi, On Sat, 9 Apr 2016 12:50:35 +0300 Andy Shevchenko <andy.shevchenko@gmail.com> wrote: > On Fri, Apr 8, 2016 at 2:13 PM, Rafał Miłecki <zajec5@gmail.com> wrote: > > 1) Use pr_fmt to keep messages consistent > > 2) Don't warn if kzalloc fails as it dumps stack on its own > > 3) Use %pR format for displaying whole resource to avoid: > > warning: format ‘%08llx’ expects type ‘long long unsigned int’, but argument 2 has type ‘resource_size_t’ > > > > Signed-off-by: Rafał Miłecki <zajec5@gmail.com> > > --- > > drivers/mtd/nand/pasemi_nand.c | 9 ++++----- > > 1 file changed, 4 insertions(+), 5 deletions(-) > > > > diff --git a/drivers/mtd/nand/pasemi_nand.c b/drivers/mtd/nand/pasemi_nand.c > > index 63fcb8c..e8372b4 100644 > > --- a/drivers/mtd/nand/pasemi_nand.c > > +++ b/drivers/mtd/nand/pasemi_nand.c > > @@ -22,6 +22,8 @@ > > > > #undef DEBUG > > > > +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt > > + > > #include <linux/slab.h> > > #include <linux/module.h> > > #include <linux/mtd/mtd.h> > > @@ -112,8 +114,6 @@ static int pasemi_nand_probe(struct platform_device *ofdev) > > /* Allocate memory for MTD device structure and private data */ > > chip = kzalloc(sizeof(struct nand_chip), GFP_KERNEL); > > if (!chip) { > > - printk(KERN_WARNING > > - "Unable to allocate PASEMI NAND MTD device structure\n"); > > err = -ENOMEM; > > goto out; > > } > > @@ -163,13 +163,12 @@ static int pasemi_nand_probe(struct platform_device *ofdev) > > } > > > > if (mtd_device_register(pasemi_nand_mtd, NULL, 0)) { > > - printk(KERN_ERR "pasemi_nand: Unable to register MTD device\n"); > > + pr_err("Unable to register MTD device\n"); > > And why not to use dev_err(&ofdev->dev, …); ? Yep, I think it's better to use dev_err(). Best Regards, Boris
diff --git a/drivers/mtd/nand/pasemi_nand.c b/drivers/mtd/nand/pasemi_nand.c index 63fcb8c..e8372b4 100644 --- a/drivers/mtd/nand/pasemi_nand.c +++ b/drivers/mtd/nand/pasemi_nand.c @@ -22,6 +22,8 @@ #undef DEBUG +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + #include <linux/slab.h> #include <linux/module.h> #include <linux/mtd/mtd.h> @@ -112,8 +114,6 @@ static int pasemi_nand_probe(struct platform_device *ofdev) /* Allocate memory for MTD device structure and private data */ chip = kzalloc(sizeof(struct nand_chip), GFP_KERNEL); if (!chip) { - printk(KERN_WARNING - "Unable to allocate PASEMI NAND MTD device structure\n"); err = -ENOMEM; goto out; } @@ -163,13 +163,12 @@ static int pasemi_nand_probe(struct platform_device *ofdev) } if (mtd_device_register(pasemi_nand_mtd, NULL, 0)) { - printk(KERN_ERR "pasemi_nand: Unable to register MTD device\n"); + pr_err("Unable to register MTD device\n"); err = -ENODEV; goto out_lpc; } - printk(KERN_INFO "PA Semi NAND flash at %08llx, control at I/O %x\n", - res.start, lpcctl); + pr_info("PA Semi NAND flash at %pR, control at I/O %x\n", &res, lpcctl); return 0;
1) Use pr_fmt to keep messages consistent 2) Don't warn if kzalloc fails as it dumps stack on its own 3) Use %pR format for displaying whole resource to avoid: warning: format ‘%08llx’ expects type ‘long long unsigned int’, but argument 2 has type ‘resource_size_t’ Signed-off-by: Rafał Miłecki <zajec5@gmail.com> --- drivers/mtd/nand/pasemi_nand.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)