Commit 480b9dfb authored by Adrian Hunter's avatar Adrian Hunter Committed by David Woodhouse

[MTD] OneNAND: Invalidate bufferRAM after erase

OneNAND has internal bufferRAMs.  The driver keeps track of
what is in the bufferRAM to save having to load from the
NAND core.  After an erase operation, the driver must
mark bufferRAM invalid if it refers to the erased block.
Signed-off-by: default avatarAdrian Hunter <ext-adrian.hunter@nokia.com>
Signed-off-by: default avatarDavid Woodhouse <dwmw2@infradead.org>
parent 678c857f
...@@ -635,6 +635,29 @@ static void onenand_update_bufferram(struct mtd_info *mtd, loff_t addr, ...@@ -635,6 +635,29 @@ static void onenand_update_bufferram(struct mtd_info *mtd, loff_t addr,
this->bufferram[i].blockpage = -1; this->bufferram[i].blockpage = -1;
} }
/**
* onenand_invalidate_bufferram - [GENERIC] Invalidate BufferRAM information
* @param mtd MTD data structure
* @param addr start address to invalidate
* @param len length to invalidate
*
* Invalidate BufferRAM information
*/
static void onenand_invalidate_bufferram(struct mtd_info *mtd, loff_t addr,
unsigned int len)
{
struct onenand_chip *this = mtd->priv;
int i;
loff_t end_addr = addr + len;
/* Invalidate BufferRAM */
for (i = 0; i < MAX_BUFFERRAM; i++) {
loff_t buf_addr = this->bufferram[i].blockpage << this->page_shift;
if (buf_addr >= addr && buf_addr < end_addr)
this->bufferram[i].blockpage = -1;
}
}
/** /**
* onenand_get_device - [GENERIC] Get chip for selected access * onenand_get_device - [GENERIC] Get chip for selected access
* @param mtd MTD device structure * @param mtd MTD device structure
...@@ -1476,6 +1499,8 @@ static int onenand_erase(struct mtd_info *mtd, struct erase_info *instr) ...@@ -1476,6 +1499,8 @@ static int onenand_erase(struct mtd_info *mtd, struct erase_info *instr)
this->command(mtd, ONENAND_CMD_ERASE, addr, block_size); this->command(mtd, ONENAND_CMD_ERASE, addr, block_size);
onenand_invalidate_bufferram(mtd, addr, block_size);
ret = this->wait(mtd, FL_ERASING); ret = this->wait(mtd, FL_ERASING);
/* Check, if it is write protected */ /* Check, if it is write protected */
if (ret) { if (ret) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment