aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/onenand/onenand_base.c
diff options
context:
space:
mode:
authorKyungmin Park <kyungmin.park@samsung.com>2007-02-01 19:29:36 -0500
committerKyungmin Park <kyungmin.park@samsung.com>2007-02-01 19:29:36 -0500
commitabf3c0f23df6686a984efc8fae7277fcdaffaa32 (patch)
tree201f8fe3ecdb62e5aceba15f00a3bdb13da9e683 /drivers/mtd/onenand/onenand_base.c
parent4f4fad27aceb87621d40f3068b94b5b11fc0127b (diff)
[MTD] OneNAND: Reduce internal BufferRAM operations
It use blockpage instead of a pair (block, page). It can also cover a small chunk access. 0x00, 0x20, 0x40 and so on. And in JFFS2 behavior, sometimes it reads two pages alternatively. e.g., It first reads A page, B page and A page. So we check another bufferram to find requested page. Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Diffstat (limited to 'drivers/mtd/onenand/onenand_base.c')
-rw-r--r--drivers/mtd/onenand/onenand_base.c47
1 files changed, 23 insertions, 24 deletions
diff --git a/drivers/mtd/onenand/onenand_base.c b/drivers/mtd/onenand/onenand_base.c
index eb94d9496446..9f4fe73bc129 100644
--- a/drivers/mtd/onenand/onenand_base.c
+++ b/drivers/mtd/onenand/onenand_base.c
@@ -577,19 +577,22 @@ static int onenand_write_bufferram(struct mtd_info *mtd, int area,
577static int onenand_check_bufferram(struct mtd_info *mtd, loff_t addr) 577static int onenand_check_bufferram(struct mtd_info *mtd, loff_t addr)
578{ 578{
579 struct onenand_chip *this = mtd->priv; 579 struct onenand_chip *this = mtd->priv;
580 int block, page; 580 int blockpage;
581 int i; 581 unsigned int i;
582 582
583 block = (int) (addr >> this->erase_shift); 583 blockpage = (int) (addr >> this->page_shift);
584 page = (int) (addr >> this->page_shift) & this->page_mask;
585 584
585 /* Is there valid data? */
586 i = ONENAND_CURRENT_BUFFERRAM(this); 586 i = ONENAND_CURRENT_BUFFERRAM(this);
587 if (this->bufferram[i].blockpage == blockpage)
588 return 1;
587 589
588 /* Is there valid data? */ 590 /* Check another BufferRAM */
589 if (this->bufferram[i].block == block && 591 i = ONENAND_NEXT_BUFFERRAM(this);
590 this->bufferram[i].page == page && 592 if (this->bufferram[i].blockpage == blockpage) {
591 this->bufferram[i].valid) 593 ONENAND_SET_NEXT_BUFFERRAM(this);
592 return 1; 594 return 1;
595 }
593 596
594 return 0; 597 return 0;
595} 598}
@@ -602,30 +605,26 @@ static int onenand_check_bufferram(struct mtd_info *mtd, loff_t addr)
602 * 605 *
603 * Update BufferRAM information 606 * Update BufferRAM information
604 */ 607 */
605static int onenand_update_bufferram(struct mtd_info *mtd, loff_t addr, 608static void onenand_update_bufferram(struct mtd_info *mtd, loff_t addr,
606 int valid) 609 int valid)
607{ 610{
608 struct onenand_chip *this = mtd->priv; 611 struct onenand_chip *this = mtd->priv;
609 int block, page; 612 int blockpage;
610 int i; 613 unsigned int i;
611 614
612 block = (int) (addr >> this->erase_shift); 615 blockpage = (int) (addr >> this->page_shift);
613 page = (int) (addr >> this->page_shift) & this->page_mask;
614 616
615 /* Invalidate BufferRAM */ 617 /* Invalidate another BufferRAM */
616 for (i = 0; i < MAX_BUFFERRAM; i++) { 618 i = ONENAND_NEXT_BUFFERRAM(this);
617 if (this->bufferram[i].block == block && 619 if (this->bufferram[i].blockpage == blockpage) {
618 this->bufferram[i].page == page) 620 this->bufferram[i].blockpage = -1;
619 this->bufferram[i].valid = 0;
620 }
621 621
622 /* Update BufferRAM */ 622 /* Update BufferRAM */
623 i = ONENAND_CURRENT_BUFFERRAM(this); 623 i = ONENAND_CURRENT_BUFFERRAM(this);
624 this->bufferram[i].block = block; 624 if (valid)
625 this->bufferram[i].page = page; 625 this->bufferram[i].blockpage = blockpage;
626 this->bufferram[i].valid = valid; 626 else
627 627 this->bufferram[i].blockpage = -1;
628 return 0;
629} 628}
630 629
631/** 630/**