mtd: do use mtd->point directly
authorArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Wed, 28 Dec 2011 13:55:42 +0000 (15:55 +0200)
committerDavid Woodhouse <David.Woodhouse@intel.com>
Mon, 9 Jan 2012 18:26:09 +0000 (18:26 +0000)
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>
fs/jffs2/erase.c
fs/jffs2/readinode.c
fs/jffs2/scan.c
include/linux/mtd/mtd.h

index c59d642cade2b4d17bf3acb0701c3c620da18575..a01cdad6aad1810f0323d6494865f7540d50421c 100644 (file)
@@ -336,12 +336,11 @@ static int jffs2_block_check_erase(struct jffs2_sb_info *c, struct jffs2_erasebl
        uint32_t ofs;
        size_t retlen;
        int ret = -EIO;
+       unsigned long *wordebuf;
 
-       if (c->mtd->point) {
-               unsigned long *wordebuf;
-
-               ret = mtd_point(c->mtd, jeb->offset, c->sector_size, &retlen,
-                               &ebuf, NULL);
+       ret = mtd_point(c->mtd, jeb->offset, c->sector_size, &retlen,
+                       &ebuf, NULL);
+       if (ret != -EOPNOTSUPP) {
                if (ret) {
                        D1(printk(KERN_DEBUG "MTD point failed %d\n", ret));
                        goto do_flash_read;
index fca2f84e1add4baeb3cf3d65dd9d193a875838ed..3093ac4fb24c2966c39b4987040dc9b5a3c33855 100644 (file)
@@ -62,17 +62,15 @@ static int check_node_data(struct jffs2_sb_info *c, struct jffs2_tmp_dnode_info
 #ifndef __ECOS
        /* TODO: instead, incapsulate point() stuff to jffs2_flash_read(),
         * adding and jffs2_flash_read_end() interface. */
-       if (c->mtd->point) {
-               err = mtd_point(c->mtd, ofs, len, &retlen, (void **)&buffer,
-                               NULL);
-               if (!err && retlen < len) {
-                       JFFS2_WARNING("MTD point returned len too short: %zu instead of %u.\n", retlen, tn->csize);
-                       mtd_unpoint(c->mtd, ofs, retlen);
-               } else if (err)
+       err = mtd_point(c->mtd, ofs, len, &retlen, (void **)&buffer, NULL);
+       if (!err && retlen < len) {
+               JFFS2_WARNING("MTD point returned len too short: %zu instead of %u.\n", retlen, tn->csize);
+               mtd_unpoint(c->mtd, ofs, retlen);
+       } else if (err) {
+               if (err != -EOPNOTSUPP)
                        JFFS2_WARNING("MTD point failed: error code %d.\n", err);
-               else
-                       pointed = 1; /* succefully pointed to device */
-       }
+       } else
+               pointed = 1; /* succefully pointed to device */
 #endif
 
        if (!pointed) {
index 83e1665e2574440500997c9dd89c145e83cdc136..f99464833bb2fb6e1ce886a713706b0bd88413ff 100644 (file)
@@ -105,7 +105,7 @@ int jffs2_scan_medium(struct jffs2_sb_info *c)
                        mtd_unpoint(c->mtd, 0, pointlen);
                        flashbuf = NULL;
                }
-               if (ret)
+               if (ret && ret != -EOPNOTSUPP)
                        D1(printk(KERN_DEBUG "MTD point failed %d\n", ret));
        }
 #endif
index 478701566ba787fc58b784ee4d749aa3742748b6..b355a83e7cc2252b393a195f13874835ab88d27a 100644 (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)
 {
        *retlen = 0;
+       if (!mtd->point)
+               return -EOPNOTSUPP;
        return mtd->point(mtd, from, len, retlen, virt, phys);
 }