[Yaffs] [PATCH 2/2] check if the start address is page-align…

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Stanley.Miao
Date:  
To: linux-mtd
CC: yaffs
Old-Topics: [Yaffs] [PATCH 1/2] Fix the bug of writing a yaffs2 image to NAND
Subject: [Yaffs] [PATCH 2/2] check if the start address is page-aligned.
Only page-aligned address is permitted in NAND subsystem.

Signed-off-by: Stanley.Miao <>
---
 nandwrite.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)


diff --git a/nandwrite.c b/nandwrite.c
index 1e30ad1..fbb1153 100644
--- a/nandwrite.c
+++ b/nandwrite.c
@@ -306,6 +306,14 @@ int main(int argc, char * const argv[])
         close(fd);
         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);
+    }


     if (autoplace) {
         /* Read the current oob info */
-- 
1.5.4.3