mtd: mtdconcat: return -EOPNOTSUPP if block_markbad is undefined
PATCH 1/4 mtd: mtdconcat: return -EOPNOTSUPP if block_markbad is undefined
From: Artem Bityutskiy <[email protected]>
The main 'mtd_block_markbad()' function returns -EOPNOTSUPP if the '->block_markbad' method is undefined, and mtdconcat should do the same. Fix this by simply removing the 'mtd_can_have_bb()' because it is not really necessary. It could be treated as an optimization, but this function is expected to be used so rarely that it does not matter.
--- drivers/mtd/mtdconcat.c | 3 --- 1 files changed, 0 insertions(+), 3 deletions(-)
drivers/mtd/mtdconcat.c +0 -3
@@ -673,9 +673,6 @@ static int concat_block_markbad(struct mtd_info *mtd, loff_t ofs)struct mtd_concat *concat =CONCAT (mtd);int i, err = -EINVAL ; -if (!mtd_can_have_bb (concat->subdev[0 ])) -return 0 ; -if (ofs > mtd->size)return -EINVAL ;
Signature · 1 line
1.7.9
PATCH 2/4 mtdoops: clean-up new MTD API usage
From: Artem Bityutskiy <[email protected]>
Let's remove useless 'mtd_can_have_bb()' function invocations.
--- drivers/mtd/mtdoops.c | 9 ++++----- 1 files changed, 4 insertions(+), 5 deletions(-)
drivers/mtd/mtdoops.c +4 -5
@@ -169,7 +169,7 @@ static void mtdoops_workfunc_erase(struct work_struct *work) cxt->nextpage =0 ; } -while (mtd_can_have_bb (mtd)) { +while (1 ) { ret =mtd_block_isbad (mtd, cxt->nextpage * record_size);if (!ret)break ;
@@ -199,9 +199,9 @@ badblock:return ; } -if (mtd_can_have_bb (mtd) && ret == -EIO ) { +if (ret == -EIO ) { ret =mtd_block_markbad (mtd, cxt->nextpage * record_size); -if (ret <0 ) { +if (ret <0 && ret != -EOPNOTSUPP ) {printk (KERN_ERR "mtdoops: block_markbad failed, aborting\n" );return ; }
@@ -257,8 +257,7 @@ static void find_next_position(struct mtdoops_context *cxt)size_t retlen;for (page =0 ; page < cxt->oops_pages; page++) { -if (mtd_can_have_bb (mtd) && -mtd_block_isbad (mtd, page * record_size)) +if (mtd_block_isbad (mtd, page * record_size))continue ;/* Assume the page is used */ mark_page_used (cxt, page);
Signature · 1 line
1.7.9
PATCH 3/4 mtd: nftlcore: remove out-of-date and now irrelevant piece of code
In reply to Artem BityutskiyFrom: Artem Bityutskiy <[email protected]>
--- drivers/mtd/nftlcore.c | 7 ------- 1 files changed, 0 insertions(+), 7 deletions(-)
drivers/mtd/nftlcore.c +0 -7
@@ -56,13 +56,6 @@ static void nftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)if (memcmp (mtd->name,"DiskOnChip" ,10 ))return ; -if (!mtd_can_have_bb (mtd)) { -printk (KERN_ERR -"NFTL no longer supports the old DiskOnChip drivers loaded via docprobe.\n" -"Please use the new diskonchip driver under the NAND subsystem.\n" ); -return ; - } -pr_debug ("NFTL: add_mtd for %s\n" , mtd->name); nftl =kzalloc (sizeof (struct NFTLrecord ),GFP_KERNEL );
Signature · 1 line
1.7.9
PATCH 4/4 mtd: redboot: remove useless code
In reply to Artem BityutskiyFrom: Artem Bityutskiy <[email protected]>
We do not need to invoke 'mtd_can_have_bb()' before invoking 'mtd_block_isbad()' because the latter already handles the case when the MTD device does not support bad blocks.
--- drivers/mtd/redboot.c | 6 ++---- 1 files changed, 2 insertions(+), 4 deletions(-)
drivers/mtd/redboot.c +2 -4
@@ -78,8 +78,7 @@ static int parse_redboot_partitions(struct mtd_info *master,if ( directory <0 ) { offset = master->size + directory * master->erasesize; -while (mtd_can_have_bb (master) && -mtd_block_isbad (master, offset)) { +while (mtd_block_isbad (master, offset)) {if (!offset) { nogood:printk (KERN_NOTICE "Failed to find a non-bad block to check for RedBoot partition table\n" );
@@ -89,8 +88,7 @@ static int parse_redboot_partitions(struct mtd_info *master, } }else { offset = directory * master->erasesize; -while (mtd_can_have_bb (master) && -mtd_block_isbad (master, offset)) { +while (mtd_block_isbad (master, offset)) { offset += master->erasesize;if (offset == master->size) goto nogood;
Signature · 1 line
1.7.9