diff options
author | Joern Engel <joern@logfs.org> | 2011-08-05 05:09:55 -0400 |
---|---|---|
committer | Prasad Joshi <prasadjoshi.linux@gmail.com> | 2012-01-28 01:13:40 -0500 |
commit | f2933e86ad93a8d1287079d59e67afd6f4166a9d (patch) | |
tree | 43aa0955e24127ca0e54546defa0e321365e35dc | |
parent | bbe01387129f76fa4bec17904eb14c4bdc3c179f (diff) |
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>
-rw-r--r-- | fs/logfs/dev_mtd.c | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/fs/logfs/dev_mtd.c b/fs/logfs/dev_mtd.c index 339e17e9133d..d054d7e975ca 100644 --- a/fs/logfs/dev_mtd.c +++ b/fs/logfs/dev_mtd.c | |||
@@ -150,14 +150,13 @@ static struct page *mtd_find_first_sb(struct super_block *sb, u64 *ofs) | |||
150 | filler_t *filler = mtd_readpage; | 150 | filler_t *filler = mtd_readpage; |
151 | struct mtd_info *mtd = super->s_mtd; | 151 | struct mtd_info *mtd = super->s_mtd; |
152 | 152 | ||
153 | if (!mtd->block_isbad) | ||
154 | return NULL; | ||
155 | |||
156 | *ofs = 0; | 153 | *ofs = 0; |
157 | while (mtd->block_isbad(mtd, *ofs)) { | 154 | if (mtd->block_isbad) { |
158 | *ofs += mtd->erasesize; | 155 | while (mtd->block_isbad(mtd, *ofs)) { |
159 | if (*ofs >= mtd->size) | 156 | *ofs += mtd->erasesize; |
160 | return NULL; | 157 | if (*ofs >= mtd->size) |
158 | return NULL; | ||
159 | } | ||
161 | } | 160 | } |
162 | BUG_ON(*ofs & ~PAGE_MASK); | 161 | BUG_ON(*ofs & ~PAGE_MASK); |
163 | return read_cache_page(mapping, *ofs >> PAGE_SHIFT, filler, sb); | 162 | 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) | |||
170 | filler_t *filler = mtd_readpage; | 169 | filler_t *filler = mtd_readpage; |
171 | struct mtd_info *mtd = super->s_mtd; | 170 | struct mtd_info *mtd = super->s_mtd; |
172 | 171 | ||
173 | if (!mtd->block_isbad) | ||
174 | return NULL; | ||
175 | |||
176 | *ofs = mtd->size - mtd->erasesize; | 172 | *ofs = mtd->size - mtd->erasesize; |
177 | while (mtd->block_isbad(mtd, *ofs)) { | 173 | if (mtd->block_isbad) { |
178 | *ofs -= mtd->erasesize; | 174 | while (mtd->block_isbad(mtd, *ofs)) { |
179 | if (*ofs <= 0) | 175 | *ofs -= mtd->erasesize; |
180 | return NULL; | 176 | if (*ofs <= 0) |
177 | return NULL; | ||
178 | } | ||
181 | } | 179 | } |
182 | *ofs = *ofs + mtd->erasesize - 0x1000; | 180 | *ofs = *ofs + mtd->erasesize - 0x1000; |
183 | BUG_ON(*ofs & ~PAGE_MASK); | 181 | BUG_ON(*ofs & ~PAGE_MASK); |