From ae4142fe7bbc632bdf97a8c00fd4039afd70420b Mon Sep 17 00:00:00 2001 From: patacongo Date: Thu, 2 Aug 2012 01:45:56 +0000 Subject: [PATCH] Correct an addressing error in the LPC32 SPIFI MTD driver git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4997 42af7a65-404d-4744-a932-0658087f49c3 --- arch/arm/src/lpc43xx/lpc43_spifi.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/arch/arm/src/lpc43xx/lpc43_spifi.c b/arch/arm/src/lpc43xx/lpc43_spifi.c index 8e633e5d18..e26d705b14 100644 --- a/arch/arm/src/lpc43xx/lpc43_spifi.c +++ b/arch/arm/src/lpc43xx/lpc43_spifi.c @@ -515,7 +515,7 @@ static void lpc43_cacheflush(struct lpc43_dev_s *priv) { /* Get the SPIFI address corresponding to the cached erase block */ - dest = SPIFI_BASE + (priv->blkno << SPIFI_BLKSHIFT); + dest = SPIFI_BASE + ((off_t)priv->blkno << SPIFI_BLKSHIFT); /* Write entire erase block to FLASH */ @@ -554,24 +554,24 @@ static FAR uint8_t *lpc43_cacheread(struct lpc43_dev_s *priv, off_t sector) /* Check if the requested erase block is already in the cache */ - if (!IS_VALID(priv) || blkno != priv->blkno) + if (!IS_VALID(priv) || blkno != (off_t)priv->blkno) { /* No.. Flush any dirty erase block currently in the cache */ lpc43_cacheflush(priv); - /* Read the erase block into the cache */ - /* Get the SPIFI address corresponding to the cached erase block */ + /* Read the new erase block into the cache */ + /* Get the SPIFI address corresponding to the new erase block */ - src = SPIFI_BASE + (priv->blkno << SPIFI_BLKSHIFT); + src = SPIFI_BASE + ((off_t)blkno << SPIFI_BLKSHIFT); - /* Write entire erase block to FLASH */ + /* Read the entire erase block from FLASH */ lpc43_pageread(priv, priv->cache, src, SPIFI_BLKSIZE); /* Mark the sector as cached */ - priv->blkno = blkno; + priv->blkno = (uint16_t)blkno; SET_VALID(priv); /* The data in the cache is valid */ CLR_DIRTY(priv); /* It should match the FLASH contents */