Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1374144 > unrolled thread

[PATCH] mtd: nand: pasemi: switch to pr_* functions

Started byRafał Miłecki <zajec5@gmail.com>
First post2016-04-08 12:40 +0200
Last post2016-04-13 14:00 +0200
Articles 8 — 4 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] mtd: nand: pasemi: switch to pr_* functions Rafał Miłecki <zajec5@gmail.com> - 2016-04-08 12:40 +0200
    Re: [PATCH] mtd: nand: pasemi: switch to pr_* functions Joe Perches <joe@perches.com> - 2016-04-08 13:00 +0200
    [PATCH V2] mtd: nand: pasemi: switch to pr_* functions Rafał Miłecki <zajec5@gmail.com> - 2016-04-08 13:20 +0200
      Re: [PATCH V2] mtd: nand: pasemi: switch to pr_* functions Joe Perches <joe@perches.com> - 2016-04-08 19:00 +0200
      Re: [PATCH V2] mtd: nand: pasemi: switch to pr_* functions Andy Shevchenko <andy.shevchenko@gmail.com> - 2016-04-09 12:00 +0200
        Re: [PATCH V2] mtd: nand: pasemi: switch to pr_* functions Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-04-13 09:50 +0200
      [PATCH V3] mtd: nand: pasemi: switch to dev_* printing functions Rafał Miłecki <zajec5@gmail.com> - 2016-04-13 11:50 +0200
        Re: [PATCH V3] mtd: nand: pasemi: switch to dev_* printing  functions Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-04-13 14:00 +0200

#1374144 — [PATCH] mtd: nand: pasemi: switch to pr_* functions

FromRafał Miłecki <zajec5@gmail.com>
Date2016-04-08 12:40 +0200
Subject[PATCH] mtd: nand: pasemi: switch to pr_* functions
Message-ID<rlBZw-2oe-19@gated-at.bofh.it>
This patch also replaces %08llx with %08zx for printing resource start
address. Old format was triggering:
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..e928549 100644
--- a/drivers/mtd/nand/pasemi_nand.c
+++ b/drivers/mtd/nand/pasemi_nand.c
@@ -112,8 +112,7 @@ 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");
+		pr_warn("Unable to allocate PASEMI NAND MTD device structure\n");
 		err = -ENOMEM;
 		goto out;
 	}
@@ -163,13 +162,13 @@ 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("pasemi_nand: 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 %08zx, control at I/O %x\n", res.start,
+		lpcctl);
 
 	return 0;
 
-- 
1.8.4.5

[toc] | [next] | [standalone]


#1374154

FromJoe Perches <joe@perches.com>
Date2016-04-08 13:00 +0200
Message-ID<rlCiS-2wH-17@gated-at.bofh.it>
In reply to#1374144
On Fri, 2016-04-08 at 12:33 +0200, Rafał Miłecki wrote:
> This patch also replaces %08llx with %08zx for printing resource start
> address. Old format was triggering:
> warning: format ‘%08llx’ expects type ‘long long unsigned int’, but argument 2 has type ‘resource_size_t’

trivia:

> diff --git a/drivers/mtd/nand/pasemi_nand.c b/drivers/mtd/nand/pasemi_nand.c
[]
> @@ -112,8 +112,7 @@ 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");
> +		pr_warn("Unable to allocate PASEMI NAND MTD device structure\n");

Maybe remove this unnecessary as there's an OOM stack dump.

>  		err = -ENOMEM;
>  		goto out;
>  	}
> @@ -163,13 +162,13 @@ 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("pasemi_nand: Unable to register MTD device\n");

Maybe remove the embedded "pasemi_nand: " and add
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
before the first #include?

>  		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 %08zx, control at I/O %x\n", res.start,
> +		lpcctl);

Maybe use %pR, &res instead of res.start?

	pr_info("PA Semi NAND flash at %pR, control at I/O %x\n", &res, lpcctl);

[toc] | [prev] | [next] | [standalone]


#1374165 — [PATCH V2] mtd: nand: pasemi: switch to pr_* functions

FromRafał Miłecki <zajec5@gmail.com>
Date2016-04-08 13:20 +0200
Subject[PATCH V2] mtd: nand: pasemi: switch to pr_* functions
Message-ID<rlCCe-2Wb-9@gated-at.bofh.it>
In reply to#1374144
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");
 		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.8.4.5

[toc] | [prev] | [next] | [standalone]


#1374364 — Re: [PATCH V2] mtd: nand: pasemi: switch to pr_* functions

FromJoe Perches <joe@perches.com>
Date2016-04-08 19:00 +0200
SubjectRe: [PATCH V2] mtd: nand: pasemi: switch to pr_* functions
Message-ID<rlHVg-6PT-11@gated-at.bofh.it>
In reply to#1374165
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

[toc] | [prev] | [next] | [standalone]


#1374594 — Re: [PATCH V2] mtd: nand: pasemi: switch to pr_* functions

FromAndy Shevchenko <andy.shevchenko@gmail.com>
Date2016-04-09 12:00 +0200
SubjectRe: [PATCH V2] mtd: nand: pasemi: switch to pr_* functions
Message-ID<rlXQm-2VC-7@gated-at.bofh.it>
In reply to#1374165
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
>



-- 
With Best Regards,
Andy Shevchenko

[toc] | [prev] | [next] | [standalone]


#1377613 — Re: [PATCH V2] mtd: nand: pasemi: switch to pr_* functions

FromBoris Brezillon <boris.brezillon@free-electrons.com>
Date2016-04-13 09:50 +0200
SubjectRe: [PATCH V2] mtd: nand: pasemi: switch to pr_* functions
Message-ID<rnnIK-64i-11@gated-at.bofh.it>
In reply to#1374594
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

-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

[toc] | [prev] | [next] | [standalone]


#1377703 — [PATCH V3] mtd: nand: pasemi: switch to dev_* printing functions

FromRafał Miłecki <zajec5@gmail.com>
Date2016-04-13 11:50 +0200
Subject[PATCH V3] mtd: nand: pasemi: switch to dev_* printing functions
Message-ID<rnpAS-7Is-21@gated-at.bofh.it>
In reply to#1374165
It also contains some minor related changes:
1) Don't warn if kzalloc fails as it dumps stack on its own
2) 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>
---
V3: Switch to dev_* instead of pr_*
---
 drivers/mtd/nand/pasemi_nand.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/mtd/nand/pasemi_nand.c b/drivers/mtd/nand/pasemi_nand.c
index 63fcb8c..5de7591 100644
--- a/drivers/mtd/nand/pasemi_nand.c
+++ b/drivers/mtd/nand/pasemi_nand.c
@@ -92,8 +92,9 @@ int pasemi_device_ready(struct mtd_info *mtd)
 
 static int pasemi_nand_probe(struct platform_device *ofdev)
 {
+	struct device *dev = &ofdev->dev;
 	struct pci_dev *pdev;
-	struct device_node *np = ofdev->dev.of_node;
+	struct device_node *np = dev->of_node;
 	struct resource res;
 	struct nand_chip *chip;
 	int err = 0;
@@ -107,13 +108,11 @@ static int pasemi_nand_probe(struct platform_device *ofdev)
 	if (pasemi_nand_mtd)
 		return -ENODEV;
 
-	pr_debug("pasemi_nand at %pR\n", &res);
+	dev_dbg(dev, "pasemi_nand at %pR\n", &res);
 
 	/* 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;
 	}
@@ -121,7 +120,7 @@ static int pasemi_nand_probe(struct platform_device *ofdev)
 	pasemi_nand_mtd = nand_to_mtd(chip);
 
 	/* Link the private data with the MTD structure */
-	pasemi_nand_mtd->dev.parent = &ofdev->dev;
+	pasemi_nand_mtd->dev.parent = dev;
 
 	chip->IO_ADDR_R = of_iomap(np, 0);
 	chip->IO_ADDR_W = chip->IO_ADDR_R;
@@ -163,13 +162,13 @@ 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");
+		dev_err(dev, "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);
+	dev_info(dev, "PA Semi NAND flash at %pR, control at I/O %x\n", &res,
+		 lpcctl);
 
 	return 0;
 
-- 
1.8.4.5

[toc] | [prev] | [next] | [standalone]


#1377849 — Re: [PATCH V3] mtd: nand: pasemi: switch to dev_* printing functions

FromBoris Brezillon <boris.brezillon@free-electrons.com>
Date2016-04-13 14:00 +0200
SubjectRe: [PATCH V3] mtd: nand: pasemi: switch to dev_* printing functions
Message-ID<rnrCF-Gd-1@gated-at.bofh.it>
In reply to#1377703
On Wed, 13 Apr 2016 11:48:05 +0200
Rafał Miłecki <zajec5@gmail.com> wrote:

> It also contains some minor related changes:
> 1) Don't warn if kzalloc fails as it dumps stack on its own
> 2) 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>

Applied with a slightly different commit message to avoid "Possible
unwrapped commit description" checkpatch warning.

Thanks,

Boris

> ---
> V3: Switch to dev_* instead of pr_*
> ---
>  drivers/mtd/nand/pasemi_nand.c | 15 +++++++--------
>  1 file changed, 7 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/mtd/nand/pasemi_nand.c b/drivers/mtd/nand/pasemi_nand.c
> index 63fcb8c..5de7591 100644
> --- a/drivers/mtd/nand/pasemi_nand.c
> +++ b/drivers/mtd/nand/pasemi_nand.c
> @@ -92,8 +92,9 @@ int pasemi_device_ready(struct mtd_info *mtd)
>  
>  static int pasemi_nand_probe(struct platform_device *ofdev)
>  {
> +	struct device *dev = &ofdev->dev;
>  	struct pci_dev *pdev;
> -	struct device_node *np = ofdev->dev.of_node;
> +	struct device_node *np = dev->of_node;
>  	struct resource res;
>  	struct nand_chip *chip;
>  	int err = 0;
> @@ -107,13 +108,11 @@ static int pasemi_nand_probe(struct platform_device *ofdev)
>  	if (pasemi_nand_mtd)
>  		return -ENODEV;
>  
> -	pr_debug("pasemi_nand at %pR\n", &res);
> +	dev_dbg(dev, "pasemi_nand at %pR\n", &res);
>  
>  	/* 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;
>  	}
> @@ -121,7 +120,7 @@ static int pasemi_nand_probe(struct platform_device *ofdev)
>  	pasemi_nand_mtd = nand_to_mtd(chip);
>  
>  	/* Link the private data with the MTD structure */
> -	pasemi_nand_mtd->dev.parent = &ofdev->dev;
> +	pasemi_nand_mtd->dev.parent = dev;
>  
>  	chip->IO_ADDR_R = of_iomap(np, 0);
>  	chip->IO_ADDR_W = chip->IO_ADDR_R;
> @@ -163,13 +162,13 @@ 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");
> +		dev_err(dev, "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);
> +	dev_info(dev, "PA Semi NAND flash at %pR, control at I/O %x\n", &res,
> +		 lpcctl);
>  
>  	return 0;
>  



-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web