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

login
register
mail settings
Submitter Stanley.Miao
Date May 18, 2010, 12:23 p.m.
Message ID <1274185390-3066-3-git-send-email-stanley.miao@windriver.com>
Download mbox | patch
Permalink /patch/52871/
State New
Headers show

Comments

Stanley.Miao - May 18, 2010, 12:23 p.m.
Only page-aligned address is permitted in NAND subsystem.

Signed-off-by: Stanley.Miao <stanley.miao@windriver.com>
---
 nandwrite.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
Artem Bityutskiy - May 22, 2010, 5:39 a.m.
On Tue, 2010-05-18 at 20:23 +0800, Stanley.Miao wrote:
> Only page-aligned address is permitted in NAND subsystem.
> 
> Signed-off-by: Stanley.Miao <stanley.miao@windriver.com>

Pushed both patches to the mtd-utils repo, thanks. However, I had to fix
a tiny white-space damage for you:

Applying: nandwrite: check if the start address is page-aligned.
/home/dedekind/git/mtd-utils/.git/rebase-apply/patch:13: trailing
whitespace.

Patch

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 */