diff mbox

[v2,4/4] mtd: nand: define pr_fmt() to include __func__ in debug output

Message ID 1307557708-31376-1-git-send-email-computersforpeace@gmail.com
State New, archived
Headers show

Commit Message

Brian Norris June 8, 2011, 6:28 p.m. UTC
Also fix some capitalization that went along with the affected lines.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
---
 drivers/mtd/nand/nand_bbt.c |   44 +++++++++++++++++++++---------------------
 1 files changed, 22 insertions(+), 22 deletions(-)

Comments

Artem Bityutskiy June 9, 2011, 7:10 a.m. UTC | #1
On Wed, 2011-06-08 at 11:28 -0700, Brian Norris wrote:
> Also fix some capitalization that went along with the affected lines.
> 
> Signed-off-by: Brian Norris <computersforpeace@gmail.com>

Thinking about this some more, I do not think it is good idea to
automatically prefix all messages with function name. In many cases this
just makes the kernel binary size larger without a real need.

> -				pr_info("nand_bbt: Error reading bad block table\n");
> +				pr_info("error reading bad block table\n");

Is nand_bbt: really needed here? May be this is not obvious, but isn't
this message unique anyway?

Well, this should be  pr_err(), because this is an error message :-) A
separate pass via all pr_* WRT this aspect would be nice.

>  				return res;
>  			}
> -			pr_warn("nand_bbt: ECC error while reading bad block table\n");
> +			pr_warn("ECC error while reading bad block table\n");

Is nand_bbt: really needed here?

>  		}
>  
>  		/* Analyse data */
> @@ -219,13 +221,13 @@ static int read_bbt(struct mtd_info *mtd, uint8_t *buf, int page, int num,
>  				if (tmp == msk)
>  					continue;
>  				if (reserved_block_code && (tmp == reserved_block_code)) {
> -					pr_debug("nand_read_bbt: Reserved block at 0x%012llx\n",
> +					pr_debug("reserved block at 0x%012llx\n",
>  					       (loff_t)((offs << 2) + (act >> 1)) << this->bbt_erase_shift);

OK, I turned this to pr_info, because this is not a debugging message.
And I do not think the function prefix is needed, I can grep the kernel
to find  it.

And really, in most places the function prefix is not needed.

In general, I think the function prefix is only needed in debugging
messages - dev_dbg() ones. All the other places should not require it in
most of the cases.

I'd do the following clean-ups instead:

1. Go through all messages and see if they are of proper level
(info/error/warning).
2. Go through all messages and thing if the function name prefix brings
   any value or only makes the kernel binary size larger.
diff mbox

Patch

diff --git a/drivers/mtd/nand/nand_bbt.c b/drivers/mtd/nand/nand_bbt.c
index 5835404..3deced4 100644
--- a/drivers/mtd/nand/nand_bbt.c
+++ b/drivers/mtd/nand/nand_bbt.c
@@ -59,6 +59,8 @@ 
  *
  */
 
+#define pr_fmt(fmt) "%s: " fmt, __func__
+
 #include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/mtd/mtd.h>
@@ -205,10 +207,10 @@  static int read_bbt(struct mtd_info *mtd, uint8_t *buf, int page, int num,
 		res = mtd->read(mtd, from, len, &retlen, buf);
 		if (res < 0) {
 			if (retlen != len) {
-				pr_info("nand_bbt: Error reading bad block table\n");
+				pr_info("error reading bad block table\n");
 				return res;
 			}
-			pr_warn("nand_bbt: ECC error while reading bad block table\n");
+			pr_warn("ECC error while reading bad block table\n");
 		}
 
 		/* Analyse data */
@@ -219,13 +221,13 @@  static int read_bbt(struct mtd_info *mtd, uint8_t *buf, int page, int num,
 				if (tmp == msk)
 					continue;
 				if (reserved_block_code && (tmp == reserved_block_code)) {
-					pr_debug("nand_read_bbt: Reserved block at 0x%012llx\n",
+					pr_debug("reserved block at 0x%012llx\n",
 					       (loff_t)((offs << 2) + (act >> 1)) << this->bbt_erase_shift);
 					this->bbt[offs + (act >> 3)] |= 0x2 << (act & 0x06);
 					mtd->ecc_stats.bbtblocks++;
 					continue;
 				}
-				pr_debug("nand_read_bbt: Bad block at 0x%012llx\n",
+				pr_debug("bad block at 0x%012llx\n",
 				       (loff_t)((offs << 2) + (act >> 1)) << this->bbt_erase_shift);
 				/* Factory marked bad or worn out? */
 				if (tmp == 0)
@@ -379,7 +381,7 @@  static int read_abs_bbts(struct mtd_info *mtd, uint8_t *buf,
 		scan_read_raw(mtd, buf, (loff_t)td->pages[0] << this->page_shift,
 			      mtd->writesize, td);
 		td->version[0] = buf[bbt_get_ver_offs(mtd, td)];
-		pr_debug("Bad block table at page %d, version 0x%02X\n",
+		pr_debug("bad block table at page %d, version 0x%02X\n",
 		       td->pages[0], td->version[0]);
 	}
 
@@ -388,7 +390,7 @@  static int read_abs_bbts(struct mtd_info *mtd, uint8_t *buf,
 		scan_read_raw(mtd, buf, (loff_t)md->pages[0] << this->page_shift,
 			      mtd->writesize, td);
 		md->version[0] = buf[bbt_get_ver_offs(mtd, md)];
-		pr_debug("Bad block table at page %d, version 0x%02X\n",
+		pr_debug("bad block table at page %d, version 0x%02X\n",
 		       md->pages[0], md->version[0]);
 	}
 	return 1;
@@ -462,7 +464,7 @@  static int create_bbt(struct mtd_info *mtd, uint8_t *buf,
 	loff_t from;
 	size_t readlen;
 
-	pr_info("Scanning device for bad blocks\n");
+	pr_info("scanning device for bad blocks\n");
 
 	if (bd->options & NAND_BBT_SCANALLPAGES)
 		len = 1 << (this->bbt_erase_shift - this->page_shift);
@@ -491,7 +493,7 @@  static int create_bbt(struct mtd_info *mtd, uint8_t *buf,
 		from = 0;
 	} else {
 		if (chip >= this->numchips) {
-			pr_warn("create_bbt(): chipnr (%d) > available chips (%d)\n",
+			pr_warn("chipnr (%d) > available chips (%d)\n",
 			       chip + 1, this->numchips);
 			return -EINVAL;
 		}
@@ -520,7 +522,7 @@  static int create_bbt(struct mtd_info *mtd, uint8_t *buf,
 
 		if (ret) {
 			this->bbt[i >> 3] |= 0x03 << (i & 0x6);
-			pr_warn("Bad eraseblock %d at 0x%012llx\n",
+			pr_warn("bad eraseblock %d at 0x%012llx\n",
 			       i >> 1, (unsigned long long)from);
 			mtd->ecc_stats.badblocks++;
 		}
@@ -603,9 +605,9 @@  static int search_bbt(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr
 	/* Check, if we found a bbt for each requested chip */
 	for (i = 0; i < chips; i++) {
 		if (td->pages[i] == -1)
-			pr_warn("Bad block table not found for chip %d\n", i);
+			pr_warn("bad block table not found for chip %d\n", i);
 		else
-			pr_debug("Bad block table found at page %d, version "
+			pr_debug("bad block table found at page %d, version "
 				 "0x%02X\n", td->pages[i], td->version[i]);
 	}
 	return 0;
@@ -719,7 +721,7 @@  static int write_bbt(struct mtd_info *mtd, uint8_t *buf,
 			if (!md || md->pages[chip] != page)
 				goto write;
 		}
-		pr_err("No space left to write bad block table\n");
+		pr_err("no space left to write bad block table\n");
 		return -ENOSPC;
 	write:
 
@@ -754,14 +756,12 @@  static int write_bbt(struct mtd_info *mtd, uint8_t *buf,
 			res = mtd->read(mtd, to, len, &retlen, buf);
 			if (res < 0) {
 				if (retlen != len) {
-					pr_info("nand_bbt: Error "
-					       "reading block for writing "
-					       "the bad block table\n");
+					pr_info("error reading block for writing"
+						" the bad block table\n");
 					return res;
 				}
-				pr_warn("nand_bbt: ECC error "
-				       "while reading block for writing "
-				       "bad block table\n");
+				pr_warn("ECC error while reading block for "
+					"writing bad block table\n");
 			}
 			/* Read oob data */
 			ops.ooblen = (len >> this->page_shift) * mtd->oobsize;
@@ -836,8 +836,8 @@  static int write_bbt(struct mtd_info *mtd, uint8_t *buf,
 		if (res < 0)
 			goto outerr;
 
-		pr_debug("Bad block table written to 0x%012llx, version "
-		       "0x%02X\n", (unsigned long long)to, td->version[chip]);
+		pr_debug("bad block table written to 0x%012llx, version "
+			 "0x%02X\n", (unsigned long long)to, td->version[chip]);
 
 		/* Mark it as used */
 		td->pages[chip] = page;
@@ -845,7 +845,7 @@  static int write_bbt(struct mtd_info *mtd, uint8_t *buf,
 	return 0;
 
  outerr:
-	pr_warning("nand_bbt: Error while writing bad block table %d\n", res);
+	pr_warning("error while writing bad block table %d\n", res);
 	return res;
 }
 
@@ -1125,7 +1125,7 @@  int nand_scan_bbt(struct mtd_info *mtd, struct nand_bbt_descr *bd)
 	 */
 	if (!td) {
 		if ((res = nand_memory_bbt(mtd, bd))) {
-			pr_err("nand_bbt: Can't scan flash and build the RAM-based BBT\n");
+			pr_err("can't scan flash and build the RAM-based BBT\n");
 			kfree(this->bbt);
 			this->bbt = NULL;
 		}