diff mbox

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

Message ID 1274185390-3066-3-git-send-email-stanley.miao@windriver.com
State New, archived
Headers show

Commit Message

Stanley.Miao May 18, 2010, 12:23 p.m. UTC
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(-)

Comments

Artem Bityutskiy May 22, 2010, 5:39 a.m. UTC | #1
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.
diff mbox

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