mtd: do use mtd->point directly

Remove direct usage of the "mtd->point" function pointer. Instead,
test the mtd_point() return code for '-EOPNOTSUPP'.

Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
This commit is contained in:
Artem Bityutskiy 2011-12-28 15:55:42 +02:00 committed by David Woodhouse
parent fc002e3c32
commit 10934478e4
4 changed files with 15 additions and 16 deletions

View File

@ -336,12 +336,11 @@ static int jffs2_block_check_erase(struct jffs2_sb_info *c, struct jffs2_erasebl
uint32_t ofs; uint32_t ofs;
size_t retlen; size_t retlen;
int ret = -EIO; int ret = -EIO;
unsigned long *wordebuf;
if (c->mtd->point) { ret = mtd_point(c->mtd, jeb->offset, c->sector_size, &retlen,
unsigned long *wordebuf; &ebuf, NULL);
if (ret != -EOPNOTSUPP) {
ret = mtd_point(c->mtd, jeb->offset, c->sector_size, &retlen,
&ebuf, NULL);
if (ret) { if (ret) {
D1(printk(KERN_DEBUG "MTD point failed %d\n", ret)); D1(printk(KERN_DEBUG "MTD point failed %d\n", ret));
goto do_flash_read; goto do_flash_read;

View File

@ -62,17 +62,15 @@ static int check_node_data(struct jffs2_sb_info *c, struct jffs2_tmp_dnode_info
#ifndef __ECOS #ifndef __ECOS
/* TODO: instead, incapsulate point() stuff to jffs2_flash_read(), /* TODO: instead, incapsulate point() stuff to jffs2_flash_read(),
* adding and jffs2_flash_read_end() interface. */ * adding and jffs2_flash_read_end() interface. */
if (c->mtd->point) { err = mtd_point(c->mtd, ofs, len, &retlen, (void **)&buffer, NULL);
err = mtd_point(c->mtd, ofs, len, &retlen, (void **)&buffer, if (!err && retlen < len) {
NULL); JFFS2_WARNING("MTD point returned len too short: %zu instead of %u.\n", retlen, tn->csize);
if (!err && retlen < len) { mtd_unpoint(c->mtd, ofs, retlen);
JFFS2_WARNING("MTD point returned len too short: %zu instead of %u.\n", retlen, tn->csize); } else if (err) {
mtd_unpoint(c->mtd, ofs, retlen); if (err != -EOPNOTSUPP)
} else if (err)
JFFS2_WARNING("MTD point failed: error code %d.\n", err); JFFS2_WARNING("MTD point failed: error code %d.\n", err);
else } else
pointed = 1; /* succefully pointed to device */ pointed = 1; /* succefully pointed to device */
}
#endif #endif
if (!pointed) { if (!pointed) {

View File

@ -105,7 +105,7 @@ int jffs2_scan_medium(struct jffs2_sb_info *c)
mtd_unpoint(c->mtd, 0, pointlen); mtd_unpoint(c->mtd, 0, pointlen);
flashbuf = NULL; flashbuf = NULL;
} }
if (ret) if (ret && ret != -EOPNOTSUPP)
D1(printk(KERN_DEBUG "MTD point failed %d\n", ret)); D1(printk(KERN_DEBUG "MTD point failed %d\n", ret));
} }
#endif #endif

View File

@ -259,6 +259,8 @@ static inline int mtd_point(struct mtd_info *mtd, loff_t from, size_t len,
size_t *retlen, void **virt, resource_size_t *phys) size_t *retlen, void **virt, resource_size_t *phys)
{ {
*retlen = 0; *retlen = 0;
if (!mtd->point)
return -EOPNOTSUPP;
return mtd->point(mtd, from, len, retlen, virt, phys); return mtd->point(mtd, from, len, retlen, virt, phys);
} }