diff mbox

[3/4] mtd: orion_nand: use dev_err() instead of printk()

Message ID 001901cefd5c$644dec50$2ce9c4f0$%han@samsung.com
State New, archived
Headers show

Commit Message

Jingoo Han Dec. 20, 2013, 8:20 a.m. UTC
Use dev_err() instead of printk() to provide a better message
to userspace.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
---
 drivers/mtd/nand/orion_nand.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Ezequiel Garcia Dec. 21, 2013, 2:22 p.m. UTC | #1
Hi Jingoo,

Thanks for the cleanup!

I have some extra requests :-)

On Fri, Dec 20, 2013 at 05:20:50PM +0900, Jingoo Han wrote:
[..]
> diff --git a/drivers/mtd/nand/orion_nand.c b/drivers/mtd/nand/orion_nand.c
> index a393a5b..7cd9aed 100644
> --- a/drivers/mtd/nand/orion_nand.c
> +++ b/drivers/mtd/nand/orion_nand.c
> @@ -87,7 +87,7 @@ static int __init orion_nand_probe(struct platform_device *pdev)
>  
>  	nc = kzalloc(sizeof(struct nand_chip) + sizeof(struct mtd_info), GFP_KERNEL);
>  	if (!nc) {
> -		printk(KERN_ERR "orion_nand: failed to allocate device structure.\n");
> +		dev_err(&pdev->dev, "orion_nand: failed to allocate device structure.\n");

Instead of this replacement, can you remove the error message entirely?
It's redundant for a driver to print anything after an allocation error, since an
out-of-memory condition will print quite enough information.

(Google for "Joe Perches OOM" and you'll find lots of patches removing this prints).

> @@ -110,7 +110,7 @@ static int __init orion_nand_probe(struct platform_device *pdev)
>  		board = devm_kzalloc(&pdev->dev, sizeof(struct orion_nand_data),
>  					GFP_KERNEL);
>  		if (!board) {
> -			printk(KERN_ERR "orion_nand: failed to allocate board structure.\n");
> +			dev_err(&pdev->dev, "orion_nand: failed to allocate board structure.\n");

Ditto.

Thanks!
Jingoo Han Dec. 26, 2013, 1:50 a.m. UTC | #2
On Saturday, December 21, 2013 11:22 PM, Ezequiel Garcia wrote:
> 
> Hi Jingoo,
> 
> Thanks for the cleanup!
> 
> I have some extra requests :-)
> 
> On Fri, Dec 20, 2013 at 05:20:50PM +0900, Jingoo Han wrote:
> [..]
> > diff --git a/drivers/mtd/nand/orion_nand.c b/drivers/mtd/nand/orion_nand.c
> > index a393a5b..7cd9aed 100644
> > --- a/drivers/mtd/nand/orion_nand.c
> > +++ b/drivers/mtd/nand/orion_nand.c
> > @@ -87,7 +87,7 @@ static int __init orion_nand_probe(struct platform_device *pdev)
> >
> >  	nc = kzalloc(sizeof(struct nand_chip) + sizeof(struct mtd_info), GFP_KERNEL);
> >  	if (!nc) {
> > -		printk(KERN_ERR "orion_nand: failed to allocate device structure.\n");
> > +		dev_err(&pdev->dev, "orion_nand: failed to allocate device structure.\n");
> 
> Instead of this replacement, can you remove the error message entirely?
> It's redundant for a driver to print anything after an allocation error, since an
> out-of-memory condition will print quite enough information.
> 
> (Google for "Joe Perches OOM" and you'll find lots of patches removing this prints).

OK, I see.

I checked the patches about OOM from Joe Perches.
I will send another patch to remove OOM error message,
instead of this patch. Thank you for your comment.

Best regards,
Jingoo Han

> 
> > @@ -110,7 +110,7 @@ static int __init orion_nand_probe(struct platform_device *pdev)
> >  		board = devm_kzalloc(&pdev->dev, sizeof(struct orion_nand_data),
> >  					GFP_KERNEL);
> >  		if (!board) {
> > -			printk(KERN_ERR "orion_nand: failed to allocate board structure.\n");
> > +			dev_err(&pdev->dev, "orion_nand: failed to allocate board structure.\n");
> 
> Ditto.
> 
> Thanks!
> --
> Ezequiel GarcĂ­a, Free Electrons
> Embedded Linux, Kernel and Android Engineering
> http://free-electrons.com
diff mbox

Patch

diff --git a/drivers/mtd/nand/orion_nand.c b/drivers/mtd/nand/orion_nand.c
index a393a5b..7cd9aed 100644
--- a/drivers/mtd/nand/orion_nand.c
+++ b/drivers/mtd/nand/orion_nand.c
@@ -87,7 +87,7 @@  static int __init orion_nand_probe(struct platform_device *pdev)
 
 	nc = kzalloc(sizeof(struct nand_chip) + sizeof(struct mtd_info), GFP_KERNEL);
 	if (!nc) {
-		printk(KERN_ERR "orion_nand: failed to allocate device structure.\n");
+		dev_err(&pdev->dev, "orion_nand: failed to allocate device structure.\n");
 		ret = -ENOMEM;
 		goto no_res;
 	}
@@ -101,7 +101,7 @@  static int __init orion_nand_probe(struct platform_device *pdev)
 
 	io_base = ioremap(res->start, resource_size(res));
 	if (!io_base) {
-		printk(KERN_ERR "orion_nand: ioremap failed\n");
+		dev_err(&pdev->dev, "orion_nand: ioremap failed\n");
 		ret = -EIO;
 		goto no_res;
 	}
@@ -110,7 +110,7 @@  static int __init orion_nand_probe(struct platform_device *pdev)
 		board = devm_kzalloc(&pdev->dev, sizeof(struct orion_nand_data),
 					GFP_KERNEL);
 		if (!board) {
-			printk(KERN_ERR "orion_nand: failed to allocate board structure.\n");
+			dev_err(&pdev->dev, "orion_nand: failed to allocate board structure.\n");
 			ret = -ENOMEM;
 			goto no_res;
 		}