[PATCH 2/5] check if the start address is page-aligned.

Stanley.Miao stanley.miao at windriver.com
Tue Feb 2 21:56:33 EST 2010


Only page-aligned address is permitted in NAND subsystem.

Signed-off-by: Stanley.Miao <stanley.miao at windriver.com>
---
 nandwrite.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/nandwrite.c b/nandwrite.c
index c66eda0..c66ab54 100644
--- a/nandwrite.c
+++ b/nandwrite.c
@@ -248,6 +248,13 @@ int main(int argc, char * const argv[])
 		exit (EXIT_FAILURE);
 	}
 
+	if (mtdoffset & (meminfo.writesize - 1)) {
+		fprintf(stderr, "The start address is not page-aligned !\n"
+				"The pagesize of this NAND Flash is 0x%x.\n",
+				meminfo.writesize);
+		close(fd);
+		exit(EXIT_FAILURE);
+	}
 
 	oob.length = meminfo.oobsize;
 	oob.ptr =  oobbuf;
-- 
1.5.4.3




More information about the linux-mtd mailing list