mtd/util nandwrite.c,1.4,1.5

gleixner at infradead.org gleixner at infradead.org
Tue Feb 18 15:53:58 EST 2003


Update of /home/cvs/mtd/util
In directory phoenix.infradead.org:/tmp/cvs-serv23371/mtd/util

Modified Files:
	nandwrite.c 
Log Message:
tglx declares himself healed from temporary brain damage and comes back to the original plan of passing
oob-layout structures. This implies minor changes to filesystem layers, but removes file system dependend
code in nand.c/.h. For userspace apps ioctl (MEMSETOOBSEL) can pass a structure with the layout, which 
has to be used for functions  like read/write, which have no knowledge about oob-layout. see util/nandwrite.c
 



Index: nandwrite.c
===================================================================
RCS file: /home/cvs/mtd/util/nandwrite.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- nandwrite.c	18 Feb 2003 11:35:32 -0000	1.4
+++ nandwrite.c	18 Feb 2003 20:53:55 -0000	1.5
@@ -35,7 +35,6 @@
 
 #include <asm/types.h>
 #include "linux/mtd/mtd.h"
-#include "linux/mtd/nand.h"
 
 #define PROGRAM "nandwrite"
 #define VERSION "1.2"
@@ -46,6 +45,21 @@
 unsigned char writebuf[512];
 unsigned char oobbuf[16];
 
+// oob layouts to pass into the kernel as default
+struct nand_oobinfo none_oobinfo = { 
+	useecc: 0,
+};
+
+struct nand_oobinfo jffs2_oobinfo = { 
+	useecc: 1,
+	eccpos:	{ 0, 1, 2, 3, 6, 7}
+};
+
+struct nand_oobinfo yaffs_oobinfo = { 
+	useecc: 1,
+	eccpos:	{ 8, 9, 10, 13, 14, 15}
+};
+
 void display_help (void)
 {
 	printf("Usage: nandwrite [OPTION] MTD_DEVICE INPUTFILE\n"
@@ -187,8 +201,7 @@
 	
 	// write without ecc ?
 	if (noecc) {
-		int oobsel = NAND_NONE_OOB;
-		if (ioctl (fd, MEMSETOOBSEL, &oobsel) != 0) {
+		if (ioctl (fd, MEMSETOOBSEL, &none_oobinfo) != 0) {
 			perror ("MEMSETOOBSEL");
 			close (fd);
 			exit (1);
@@ -197,8 +210,8 @@
 
 	// force oob layout for jffs2 or yaffs ?
 	if (forcejffs2 || forceyaffs) {
-		int oobsel = forcejffs2 ? NAND_JFFS2_OOB : NAND_YAFFS_OOB;
-		if (ioctl (fd, MEMSETOOBSEL, &oobsel) != 0) {
+		struct nand_oobinfo *oobsel = forcejffs2 ? &jffs2_oobinfo : &yaffs_oobinfo;
+		if (ioctl (fd, MEMSETOOBSEL, oobsel) != 0) {
 			perror ("MEMSETOOBSEL");
 			close (fd);
 			exit (1);





More information about the linux-mtd-cvs mailing list