[PATCH v2] mtd/nand: Print source of error message

Tormod Volden lists.tormod at gmail.com
Sat Jan 12 05:34:27 EST 2013


From: Tormod Volden <debian.tormod at gmail.com>

Add the function name to the error message.

These messages are not very helpful:

[183356.176682] uncorrectable error :
[183356.180273] uncorrectable error :
[183356.184194] uncorrectable error :
[183356.187773] uncorrectable error :
[183356.191280] uncorrectable error :

Signed-off-by: Tormod Volden <debian.tormod at gmail.com>
---

Vikram Narayanan wrote:
> Better to use %s and __func__.
> Despite adding the function name, it'd be much better to briefly convey
> what has happened.

Hi Vikram,

I agree. I also replaced printk with pr_err which seems to be preferred
nowadays.

Sorry I can not help much with the better solution since I don't know this
code. The function is called via function pointers so it is not straight-
forward to find all callers and check their code.

Regards,
Tormod


 drivers/mtd/nand/nand_ecc.c |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/nand/nand_ecc.c b/drivers/mtd/nand/nand_ecc.c
index b7cfe0d..526fa3b 100644
--- a/drivers/mtd/nand/nand_ecc.c
+++ b/drivers/mtd/nand/nand_ecc.c
@@ -55,8 +55,7 @@ struct mtd_info;
 #define MODULE_AUTHOR(x)	/* x */
 #define MODULE_DESCRIPTION(x)	/* x */
 
-#define printk printf
-#define KERN_ERR		""
+#define pr_err printf
 #endif
 
 /*
@@ -507,7 +506,7 @@ int __nand_correct_data(unsigned char *buf,
 	if ((bitsperbyte[b0] + bitsperbyte[b1] + bitsperbyte[b2]) == 1)
 		return 1;	/* error in ECC data; no action needed */
 
-	printk(KERN_ERR "uncorrectable error : ");
+	pr_err("%s: uncorrectable error : ", __func__);
 	return -1;
 }
 EXPORT_SYMBOL(__nand_correct_data);
-- 
1.7.9.5




More information about the linux-mtd mailing list