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 <md@semihalf.com>
This commit is contained in:
rkujawa 2013-02-15 17:46:53 +00:00
parent b99a618c86
commit b97cbd07b3
1 changed files with 3 additions and 3 deletions

View File

@ -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 sc)
(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