Module Name:    src
Committed By:   rkujawa
Date:           Fri Feb 15 17:46:53 UTC 2013

Modified Files:
        src/sys/dev/spi: spiflash.c

Log Message:
Fix wrong calculation of destination pointer in writes.

Existing calculation of destination pointer was always causing unnecessary 
erases of SPI Flash memory and was always writing each consecutive 2048 byte 
blocks of data into the same address of the SPI Flash memory. This commit fixes 
issue with writes of multiple blocks using 'dd' tool.

Patch from Semihalf.
Author: Michal Dubiel <m...@semihalf.com>


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/dev/spi/spiflash.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/spi/spiflash.c
diff -u src/sys/dev/spi/spiflash.c:1.10 src/sys/dev/spi/spiflash.c:1.11
--- src/sys/dev/spi/spiflash.c:1.10	Tue Jan 13 13:35:54 2009
+++ src/sys/dev/spi/spiflash.c	Fri Feb 15 17:46:53 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: spiflash.c,v 1.10 2009/01/13 13:35:54 yamt Exp $ */
+/* $NetBSD: spiflash.c,v 1.11 2013/02/15 17:46:53 rkujawa Exp $ */
 
 /*-
  * Copyright (c) 2006 Urbana-Champaign Independent Media Center.
@@ -42,7 +42,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: spiflash.c,v 1.10 2009/01/13 13:35:54 yamt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spiflash.c,v 1.11 2013/02/15 17:46:53 rkujawa Exp $");
 
 #include <sys/param.h>
 #include <sys/conf.h>
@@ -436,7 +436,7 @@ spiflash_process_write(spiflash_handle_t
 			    (unsigned)bp->b_blkno, bp->b_bcount, resid));
 
 		data = bp->b_data;
-		dst = save + (bp->b_blkno - blkno) * DEV_BSIZE;
+		dst = save + (bp->b_blkno * DEV_BSIZE) - base;
 
 		/*
 		 * NOR flash bits.  We can clear a bit, but we cannot

Reply via email to