From ac7c6cbd5de56435bf6e16517c1586a4d2494853 Mon Sep 17 00:00:00 2001 From: Yonghui Yu Date: Thu, 22 Jun 2017 16:36:04 +0800 Subject: [PATCH] mtd: nand: fix rsv info save PD#146160: mtd: nand: fix rsv info save operations 1. fix pages calculations 2. update valid flag after 1st write. Change-Id: I498ff0b6e11939813d69141d8d18be30d15d8b1c Signed-off-by: Yonghui Yu --- drivers/amlogic/mtd/rsv_manage.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/amlogic/mtd/rsv_manage.c b/drivers/amlogic/mtd/rsv_manage.c index 6f25978..e80a19d 100644 --- a/drivers/amlogic/mtd/rsv_manage.c +++ b/drivers/amlogic/mtd/rsv_manage.c @@ -601,7 +601,6 @@ int aml_nand_save_rsv_info(struct mtd_info *mtd, int error = 0, pages_per_blk, i = 1; loff_t addr = 0; struct erase_info erase_info; - struct aml_nand_chip *aml_chip = mtd_to_nand_chip(mtd); pages_per_blk = mtd->erasesize / mtd->writesize; /*solve these abnormals caused by power off and ecc error*/ @@ -609,11 +608,10 @@ int aml_nand_save_rsv_info(struct mtd_info *mtd, || (nandrsv_info->valid_node->status & ECC_ABNORMAL_FLAG)) nandrsv_info->valid_node->phy_page_addr = pages_per_blk; - if ((mtd->writesize < nandrsv_info->size) - && (aml_chip->aml_nandenv_info->valid == 1)) + if (mtd->writesize < nandrsv_info->size) i = (nandrsv_info->size + mtd->writesize - 1) / mtd->writesize; - pr_info("%s:%d,valid=%d, pages=%d\n", __func__, __LINE__, - aml_chip->aml_nandenv_info->valid, i); + pr_info("%s:%d, %s: valid=%d, pages=%d\n", __func__, __LINE__, + nandrsv_info->name, nandrsv_info->valid, i); RE_SEARCH: if (nandrsv_info->valid) { /*pr_info("%s:%d,phy_page_addr=%d,pages=%d\n", @@ -711,7 +709,8 @@ if ((nandrsv_info->valid_node->phy_page_addr+i) > pages_per_blk) { pr_info("update nand env FAILED!\n"); return 1; } - + if (!nandrsv_info->valid) + nandrsv_info->valid = 1; /* clear status when write successfully*/ nandrsv_info->valid_node->status = 0; return error; -- 2.7.4