Commit f2933e86ad93a8d1287079d59e67afd6f4166a9d
Committed by
Prasad Joshi
1 parent
bbe0138712
Exists in
master
and in
20 other branches
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 <joern@logfs.org>
Showing 1 changed file with 12 additions and 14 deletions Side-by-side Diff
fs/logfs/dev_mtd.c
... | ... | @@ -150,14 +150,13 @@ |
150 | 150 | filler_t *filler = mtd_readpage; |
151 | 151 | struct mtd_info *mtd = super->s_mtd; |
152 | 152 | |
153 | - if (!mtd->block_isbad) | |
154 | - return NULL; | |
155 | - | |
156 | 153 | *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 | + } | |
161 | 160 | } |
162 | 161 | BUG_ON(*ofs & ~PAGE_MASK); |
163 | 162 | return read_cache_page(mapping, *ofs >> PAGE_SHIFT, filler, sb); |
164 | 163 | |
... | ... | @@ -170,14 +169,13 @@ |
170 | 169 | filler_t *filler = mtd_readpage; |
171 | 170 | struct mtd_info *mtd = super->s_mtd; |
172 | 171 | |
173 | - if (!mtd->block_isbad) | |
174 | - return NULL; | |
175 | - | |
176 | 172 | *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 | + } | |
181 | 179 | } |
182 | 180 | *ofs = *ofs + mtd->erasesize - 0x1000; |
183 | 181 | BUG_ON(*ofs & ~PAGE_MASK); |