Skip to content

Commit

Permalink
mtd: nand: avoid skip bad block in last part [1/1]
Browse files Browse the repository at this point in the history
PD#167168

Problem:
in mtd add partition process, last part
should not skip bad block in any situation

Solution:
remove the last part from counting process

Verify:
axg_s400

Change-Id: Ic5dbaff98efa9d74e526d350b7c04b9d2084eb47
Signed-off-by: Yi Zeng <[email protected]>
  • Loading branch information
Yi Zeng authored and Xiaobo Gu committed Jul 2, 2018
1 parent d5c0a23 commit 41894ce
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion drivers/mtd/nand/amlogic_mtd/aml_mtd.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ typedef struct _ext_info{
#define NAND_FIPMODE_DISCRETE (1)

/* if you don't need skip the bad blocks when add
* partitions, please open this macro.
* partitions, please enable this macro.
* #define CONFIG_NOT_SKIP_BAD_BLOCK
*/

Expand Down
25 changes: 12 additions & 13 deletions drivers/mtd/nand/amlogic_mtd/aml_nand.c
Original file line number Diff line number Diff line change
Expand Up @@ -1691,20 +1691,18 @@ static int aml_nand_add_partition(struct aml_nand_chip *aml_chip)
struct mtd_partition *parts;
int nr, i, ret = 0;
loff_t adjust_offset = 0;
uint64_t mini_part_size, part_size = 0;
uint64_t part_size = 0;
int reserved_part_blk_num = RESERVED_BLOCK_NUM;
uint64_t fip_part_size = 0;
int normal_base = 0;
#ifndef CONFIG_NOT_SKIP_BAD_BLOCK
int phys_erase_shift, error = 0;
uint64_t start_blk = 0;
uint64_t start_blk = 0, part_blk = 0;
loff_t offset;

phys_erase_shift = fls(mtd->erasesize) - 1;
#endif

mini_part_size =
(mtd->erasesize > MINI_PART_SIZE ) ? mtd->erasesize : MINI_PART_SIZE;
if (!strncmp((char*)plat->name,
NAND_BOOT_NAME, strlen((const char*)NAND_BOOT_NAME))) {\
/* boot partition must be set as this because of romboot restrict */
Expand Down Expand Up @@ -1759,28 +1757,29 @@ static int aml_nand_add_partition(struct aml_nand_chip *aml_chip)
return -ENOMEM;
}
temp_parts->offset = adjust_offset;
if (temp_parts->size < mini_part_size)
part_size = mini_part_size;
else
part_size = temp_parts->size;
if ((i == nr - 1) && (mtd->size > adjust_offset))
part_size = temp_parts->size;
if (i == nr - 1)
part_size = mtd->size - adjust_offset;
#ifndef CONFIG_NOT_SKIP_BAD_BLOCK
offset = 0;
start_blk = 0;
part_blk = part_size >> phys_erase_shift;
do {
offset = adjust_offset + start_blk *
mtd->erasesize;
error = mtd->_block_isbad(mtd, offset);
if (error) {
pr_info("%s:%d factory bad addr=%llx\n",
__func__, __LINE__,
(uint64_t)(offset >> phys_erase_shift));
adjust_offset += mtd->erasesize;
continue;
(uint64_t)(offset >>
phys_erase_shift));
if (i != nr - 1) {
adjust_offset += mtd->erasesize;
continue;
}
}
start_blk++;
} while (start_blk < (part_size >> phys_erase_shift));
} while (start_blk < part_blk);
#endif
if (temp_parts->name == NULL) {
temp_parts->name =
Expand Down

0 comments on commit 41894ce

Please sign in to comment.