Skip to contentSkip to conversation

mtd: atmel_nand: use dev_err() instead of printk()

PATCH In review Jingoo Han 3 participants 7 messages Dec 20, 2013 – Dec 26, 2013

Subsystems (3)
lore
Share & tools
lore

Jingoo Han

author
#0 lore raw

PATCH 1/4 mtd: atmel_nand: use dev_err() instead of printk()

Use dev_err() instead of printk() to provide a better message to userspace.

---
 drivers/mtd/nand/atmel_nand.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/mtd/nand/atmel_nand.c +3 -3
index 59f08c4..354ca6d 100644
@@ -1962,7 +1962,7 @@ static int atmel_nand_probe(struct platform_device *pdev)
 	/* Allocate memory for the device structure (and zero it) */
 	host = devm_kzalloc(&pdev->dev, sizeof(*host), GFP_KERNEL);
 	if (!host) {
-		printk(KERN_ERR "atmel_nand: failed to allocate device structure.\n");
+		dev_err(&pdev->dev, "atmel_nand: failed to allocate device structure.\n");
 		return -ENOMEM;
 	}
 
@@ -2062,14 +2062,14 @@ static int atmel_nand_probe(struct platform_device *pdev)
 		}
 
 		if (gpio_get_value(host->board.det_pin)) {
-			printk(KERN_INFO "No SmartMedia card inserted.\n");
+			dev_info(&pdev->dev, "No SmartMedia card inserted.\n");
 			res = -ENXIO;
 			goto err_no_card;
 		}
 	}
 
 	if (host->board.on_flash_bbt || on_flash_bbt) {
-		printk(KERN_INFO "atmel_nand: Use On Flash BBT\n");
+		dev_info(&pdev->dev, "atmel_nand: Use On Flash BBT\n");
 		nand_chip->bbt_options |= NAND_BBT_USE_FLASH;
 	}
 
Signature · 1 line
1.7.10.4
author
#1 lore raw

PATCH 2/4 mtd: fsmc_nand: use dev_warn() instead of printk()

Use dev_warn() instead of printk() to provide a better message to userspace.

---
 drivers/mtd/nand/fsmc_nand.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/mtd/nand/fsmc_nand.c +4 -4
index 8b27522..ee65b98 100644
@@ -1108,8 +1108,8 @@ static int __init fsmc_nand_probe(struct platform_device *pdev)
 			host->ecc_place = &fsmc_ecc4_lp_place;
 			break;
 		default:
-			printk(KERN_WARNING "No oob scheme defined for "
-			       "oobsize %d\n", mtd->oobsize);
+			dev_warn(&pdev->dev, "No oob scheme defined for oobsize %d\n",
+				 mtd->oobsize);
 			BUG();
 		}
 	} else {
@@ -1124,8 +1124,8 @@ static int __init fsmc_nand_probe(struct platform_device *pdev)
 			nand->ecc.layout = &fsmc_ecc1_128_layout;
 			break;
 		default:
-			printk(KERN_WARNING "No oob scheme defined for "
-			       "oobsize %d\n", mtd->oobsize);
+			dev_warn(&pdev->dev, "No oob scheme defined for oobsize %d\n",
+				 mtd->oobsize);
 			BUG();
 		}
 	}
Signature · 1 line
1.7.10.4
author
#3 lore raw

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

In reply to Jingoo Han

Use dev_err() instead of printk() to provide a better message to userspace.

---
 drivers/mtd/nand/orion_nand.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/mtd/nand/orion_nand.c +3 -3
index a393a5b..7cd9aed 100644
@@ -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;
 		}
Signature · 1 line
1.7.10.4
author
#6 lore raw

PATCH 4/4 mtd: sharpsl: use dev_err() instead of printk()

In reply to Jingoo Han

Use dev_err() instead of printk() to provide a better message to userspace.

---
 drivers/mtd/nand/sharpsl.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mtd/nand/sharpsl.c +2 -2
index 87908d7..8522f33 100644
@@ -122,7 +122,7 @@ static int sharpsl_nand_probe(struct platform_device *pdev)
 	/* Allocate memory for MTD device structure and private data */
 	sharpsl = kzalloc(sizeof(struct sharpsl_nand), GFP_KERNEL);
 	if (!sharpsl) {
-		printk("Unable to allocate SharpSL NAND MTD device structure.\n");
+		dev_err(&pdev->dev, "Unable to allocate SharpSL NAND MTD device structure.\n");
 		return -ENOMEM;
 	}
 
@@ -136,7 +136,7 @@ static int sharpsl_nand_probe(struct platform_device *pdev)
 	/* map physical address */
 	sharpsl->io = ioremap(r->start, resource_size(r));
 	if (!sharpsl->io) {
-		printk("ioremap to access Sharp SL NAND chip failed\n");
+		dev_err(&pdev->dev, "ioremap to access Sharp SL NAND chip failed\n");
 		err = -EIO;
 		goto err_ioremap;
 	}
Signature · 1 line
1.7.10.4
#4 lore raw

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

In reply to Jingoo Han

Hi Jingoo,

Thanks for the cleanup!

I have some extra requests :-)

On Fri, Dec 20, 2013 at 05:20:50PM +0900, Jingoo Han wrote:
[..]

drivers/mtd/nand/orion_nand.c static int __init orion_nand_probe(struct platform_device *pdev) · line 90

Quoted 10 lines
drivers/mtd/nand/orion_nand.c +1 -1
index a393a5b..7cd9aed 100644
@@ -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).

drivers/mtd/nand/orion_nand.c static int __init orion_nand_probe(struct platform_device *pdev) · line 113

Quoted 6 lines
drivers/mtd/nand/orion_nand.c +1 -1
@@ -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!

Signature · 3 lines
Ezequiel García, Free Electrons
Embedded Linux, Kernel and Android Engineering
http://free-electrons.com
author
#5 lore raw

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

Quoted 24 lines · Ezequiel Garcia

Hi Jingoo,

Thanks for the cleanup!

I have some extra requests :-)

On Fri, Dec 20, 2013 at 05:20:50PM +0900, Jingoo Han wrote:
[..]

drivers/mtd/nand/orion_nand.c static int __init orion_nand_probe(struct platform_device *pdev) · line 90

Quoted 10 lines
drivers/mtd/nand/orion_nand.c +1 -1
index a393a5b..7cd9aed 100644
@@ -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.

Quoted 1 line

(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

Quoted 15 lines

drivers/mtd/nand/orion_nand.c static int __init orion_nand_probe(struct platform_device *pdev) · line 113

Quoted 7 lines
drivers/mtd/nand/orion_nand.c +1 -1
@@ -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