diff mbox

nandwrite: add only write oob option

Message ID 1299491086-27109-1-git-send-email-leiwen@marvell.com
State Accepted
Commit a74619f416f89127138eb7e8168a0b67fb419c64
Headers show

Commit Message

Lei Wen March 7, 2011, 9:44 a.m. UTC
Write only oob part goes different path in nand_base.c, it is better
to have userland program so that we could easy debug this path when
the write only oob fail like the mtd_oobtest in mtd_test suit.

Signed-off-by: Lei Wen <leiwen@marvell.com>
---
 nandwrite.c |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

Comments

Artem Bityutskiy March 8, 2011, 12:05 p.m. UTC | #1
On Mon, 2011-03-07 at 01:44 -0800, Lei Wen wrote:
> Write only oob part goes different path in nand_base.c, it is better
> to have userland program so that we could easy debug this path when
> the write only oob fail like the mtd_oobtest in mtd_test suit.
> 
> Signed-off-by: Lei Wen <leiwen@marvell.com>

Pushed, thanks.
diff mbox

Patch

diff --git a/nandwrite.c b/nandwrite.c
index 7f459cb..6e986c5 100644
--- a/nandwrite.c
+++ b/nandwrite.c
@@ -80,6 +80,7 @@  static void display_help(void)
 "  -n, --noecc             Write without ecc\n"
 "  -N, --noskipbad         Write without bad block skipping\n"
 "  -o, --oob               Image contains oob data\n"
+"  -O, --onlyoob           Image contains oob data and only write the oob part\n"
 "  -r, --raw               Image contains the raw oob data dumped by nanddump\n"
 "  -s addr, --start=addr   Set start address (default is 0)\n"
 "  -p, --pad               Pad to page size\n"
@@ -113,6 +114,7 @@  static long long	mtdoffset = 0;
 static bool		quiet = false;
 static bool		writeoob = false;
 static bool		rawoob = false;
+static bool		onlyoob = false;
 static bool		autoplace = false;
 static bool		markbad = false;
 static bool		forcejffs2 = false;
@@ -129,7 +131,7 @@  static void process_options(int argc, char * const argv[])
 
 	for (;;) {
 		int option_index = 0;
-		static const char *short_options = "ab:fjmnNopqrs:y";
+		static const char *short_options = "ab:fjmnNoOpqrs:y";
 		static const struct option long_options[] = {
 			{"help", no_argument, 0, 0},
 			{"version", no_argument, 0, 0},
@@ -141,6 +143,7 @@  static void process_options(int argc, char * const argv[])
 			{"noecc", no_argument, 0, 'n'},
 			{"noskipbad", no_argument, 0, 'N'},
 			{"oob", no_argument, 0, 'o'},
+			{"onlyoob", no_argument, 0, 'O'},
 			{"pad", no_argument, 0, 'p'},
 			{"quiet", no_argument, 0, 'q'},
 			{"raw", no_argument, 0, 'r'},
@@ -193,6 +196,10 @@  static void process_options(int argc, char * const argv[])
 			case 'o':
 				writeoob = true;
 				break;
+			case 'O':
+				writeoob = true;
+				onlyoob = true;
+				break;
 			case 'p':
 				pad = true;
 				break;
@@ -282,7 +289,7 @@  int main(int argc, char * const argv[])
 
 	process_options(argc, argv);
 
-	if (pad && writeoob) {
+	if (!onlyoob && (pad && writeoob)) {
 		fprintf(stderr, "Can't pad when oob data is present.\n");
 		exit(EXIT_FAILURE);
 	}
@@ -639,7 +646,7 @@  int main(int argc, char * const argv[])
 		}
 
 		/* Write out the Page data */
-		if (mtd_write(&mtd, fd, mtdoffset / mtd.eb_size, mtdoffset % mtd.eb_size,
+		if (!onlyoob && mtd_write(&mtd, fd, mtdoffset / mtd.eb_size, mtdoffset % mtd.eb_size,
 					writebuf, mtd.min_io_size)) {
 			int i;
 			if (errno != EIO) {