Skip to content

Commit f2933e8

Browse files
Joern Engeljoshi-prasad
authored andcommitted
Logfs: Allow NULL block_isbad() methods
Not all mtd drivers define block_isbad(). Let's assume no bad blocks instead of refusing to mount. Signed-off-by: Joern Engel <[email protected]>
1 parent bbe0138 commit f2933e8

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

fs/logfs/dev_mtd.c

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -150,14 +150,13 @@ static struct page *mtd_find_first_sb(struct super_block *sb, u64 *ofs)
150150
filler_t *filler = mtd_readpage;
151151
struct mtd_info *mtd = super->s_mtd;
152152

153-
if (!mtd->block_isbad)
154-
return NULL;
155-
156153
*ofs = 0;
157-
while (mtd->block_isbad(mtd, *ofs)) {
158-
*ofs += mtd->erasesize;
159-
if (*ofs >= mtd->size)
160-
return NULL;
154+
if (mtd->block_isbad) {
155+
while (mtd->block_isbad(mtd, *ofs)) {
156+
*ofs += mtd->erasesize;
157+
if (*ofs >= mtd->size)
158+
return NULL;
159+
}
161160
}
162161
BUG_ON(*ofs & ~PAGE_MASK);
163162
return read_cache_page(mapping, *ofs >> PAGE_SHIFT, filler, sb);
@@ -170,14 +169,13 @@ static struct page *mtd_find_last_sb(struct super_block *sb, u64 *ofs)
170169
filler_t *filler = mtd_readpage;
171170
struct mtd_info *mtd = super->s_mtd;
172171

173-
if (!mtd->block_isbad)
174-
return NULL;
175-
176172
*ofs = mtd->size - mtd->erasesize;
177-
while (mtd->block_isbad(mtd, *ofs)) {
178-
*ofs -= mtd->erasesize;
179-
if (*ofs <= 0)
180-
return NULL;
173+
if (mtd->block_isbad) {
174+
while (mtd->block_isbad(mtd, *ofs)) {
175+
*ofs -= mtd->erasesize;
176+
if (*ofs <= 0)
177+
return NULL;
178+
}
181179
}
182180
*ofs = *ofs + mtd->erasesize - 0x1000;
183181
BUG_ON(*ofs & ~PAGE_MASK);

0 commit comments

Comments
 (0)