linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mtd-utils: formatting of odd-sized OOB in nanddump
@ 2010-06-16 16:42 Brian Norris
  2010-07-07 14:07 ` Artem Bityutskiy
  0 siblings, 1 reply; 21+ messages in thread
From: Brian Norris @ 2010-06-16 16:42 UTC (permalink / raw)
  To: linux-mtd; +Cc: Brian Norris

Changed OOB output formatting in nanddump.
Most NAND devices have OOB regions with multiples of 16 bytes.
With newer devices, a 218-byte OOB does not split nicely into
lines of 16 bytes. This patch fixes the formatting, allowing a
last line of 10 bytes instead of 16.

Signed-off-by: Brian Norris <norris@broadcom.com>
---
 nanddump.c |   31 ++++++++++++++++++++++---------
 1 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/nanddump.c b/nanddump.c
index e44ab36..190a653 100644
--- a/nanddump.c
+++ b/nanddump.c
@@ -381,15 +381,28 @@ int main(int argc, char * const argv[])
 			}
 
 			for (i = 0; i < meminfo.oobsize; i += 16) {
-				sprintf(pretty_buf, "  OOB Data: %02x %02x %02x %02x %02x %02x "
-						"%02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
-						oobbuf[i], oobbuf[i+1], oobbuf[i+2],
-						oobbuf[i+3], oobbuf[i+4], oobbuf[i+5],
-						oobbuf[i+6], oobbuf[i+7], oobbuf[i+8],
-						oobbuf[i+9], oobbuf[i+10], oobbuf[i+11],
-						oobbuf[i+12], oobbuf[i+13], oobbuf[i+14],
-						oobbuf[i+15]);
-				write(ofd, pretty_buf, 60);
+				/* Check if we have a full 16 bytes left in the OOB */
+				if (i+15 < meminfo.oobsize) {
+					/* Print 16 bytes */
+					sprintf(pretty_buf, "  OOB Data: %02x %02x %02x %02x %02x %02x "
+							"%02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
+							oobbuf[i], oobbuf[i+1], oobbuf[i+2],
+							oobbuf[i+3], oobbuf[i+4], oobbuf[i+5],
+							oobbuf[i+6], oobbuf[i+7], oobbuf[i+8],
+							oobbuf[i+9], oobbuf[i+10], oobbuf[i+11],
+							oobbuf[i+12], oobbuf[i+13], oobbuf[i+14],
+							oobbuf[i+15]);
+					write(ofd, pretty_buf, 60);
+				} else {
+					/* Print 10 bytes */
+					sprintf(pretty_buf, "  OOB Data: %02x %02x %02x %02x %02x %02x "
+							"%02x %02x %02x %02x\n",
+							oobbuf[i], oobbuf[i+1], oobbuf[i+2],
+							oobbuf[i+3], oobbuf[i+4], oobbuf[i+5],
+							oobbuf[i+6], oobbuf[i+7], oobbuf[i+8],
+							oobbuf[i+9]);
+					write(ofd, pretty_buf, 42);
+				}
 			}
 		} else
 			write(ofd, oobbuf, meminfo.oobsize);
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2010-07-21 10:00 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-16 16:42 [PATCH] mtd-utils: formatting of odd-sized OOB in nanddump Brian Norris
2010-07-07 14:07 ` Artem Bityutskiy
2010-07-07 18:21   ` Brian Norris
2010-07-08  4:09     ` Artem Bityutskiy
2010-07-08 20:50       ` [PATCH] mtd-utils update Brian Norris
2010-07-08 20:50         ` [PATCH 1/6] mtd-utils/nanddump.c: Increase max OOB size Brian Norris
2010-07-18  7:17           ` Artem Bityutskiy
2010-07-08 20:50         ` [PATCH 2/6] mtd-utils/nanddump.c: Robust pretty hexdump Brian Norris
2010-07-18  7:18           ` Artem Bityutskiy
2010-07-08 20:50         ` [PATCH 3/6] mtd-utils/nanddump.c: Add canonical (hex+ascii) flag Brian Norris
2010-07-08 20:50         ` [PATCH 4/6] mtd-utils/mkfs.jffs2: fixed warnings Brian Norris
2010-07-18  7:19           ` Artem Bityutskiy
2010-07-08 20:50         ` [PATCH 5/6] mtd-utils/nandtest.c: Fixed indentation Brian Norris
2010-07-18  7:20           ` Artem Bityutskiy
2010-07-08 20:50         ` [PATCH 6/6] mtd-utils/nanddump.c: Add "forcebinary" flag Brian Norris
2010-07-08 22:03           ` Brian Norris
2010-07-18  7:23           ` Artem Bityutskiy
2010-07-19 17:33             ` [PATCH v2 2/6] mtd-utils/nanddump.c: Robust pretty hexdump Brian Norris
2010-07-21  9:54               ` Artem Bityutskiy
2010-07-19 17:33             ` [PATCH v2 3/6] mtd-utils/nanddump.c: Add canonical (hex+ascii) flag Brian Norris
2010-07-19 17:33             ` [PATCH v2 6/6] mtd-utils/nanddump.c: Add "forcebinary" flag Brian Norris

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).