[PATCH 08/10] nand: refuse to write data if not beginning on a page boundary

Sascha Hauer s.hauer at pengutronix.de
Thu Dec 3 04:53:53 EST 2009


Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 drivers/nand/nand.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/drivers/nand/nand.c b/drivers/nand/nand.c
index a058df2..f79f7c3 100644
--- a/drivers/nand/nand.c
+++ b/drivers/nand/nand.c
@@ -58,12 +58,17 @@ static ssize_t nand_write(struct cdev* cdev, const void *buf, size_t _count, ulo
 	void *wrbuf = NULL;
 	size_t count = _count;
 
+	if (NOTALIGNED(offset)) {
+		printf("offset 0x%08x not page aligned\n", offset);
+		return -EINVAL;
+	}
+
 	debug("write: 0x%08x 0x%08x\n", offset, count);
 
 	while (count) {
 		now = count > info->writesize ? info->writesize : count;
 
-		if (NOTALIGNED(now) || NOTALIGNED(offset)) {
+		if (NOTALIGNED(now)) {
 			debug("not aligned: %d %d\n", info->writesize, (offset % info->writesize));
 			wrbuf = xmalloc(info->writesize);
 			memset(wrbuf, 0xff, info->writesize);
-- 
1.6.5.2





More information about the u-boot-v2 mailing list