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

login
register
mail settings
Submitter Stanley.Miao
Date Feb. 3, 2010, 2:56 a.m.
Message ID <1265165796-24686-3-git-send-email-stanley.miao@windriver.com>
Download mbox | patch
Permalink /patch/44334/
State New
Headers show

Comments

Stanley.Miao - Feb. 3, 2010, 2:56 a.m.
Only page-aligned address is permitted in NAND subsystem.

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

Patch

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;