mtd: do not use mtd->get_unmapped_area directly
authorArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Fri, 30 Dec 2011 12:31:57 +0000 (14:31 +0200)
committerDavid Woodhouse <David.Woodhouse@intel.com>
Mon, 9 Jan 2012 18:26:10 +0000 (18:26 +0000)
Remove direct usage of mtd->get_unmapped_area. Instead, just call
'mtd_get_unmapped_area()' which will return -EOPNOTSUPP if the function
is not implemented and test for this error code.

Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
drivers/mtd/mtdchar.c
drivers/mtd/mtdconcat.c
include/linux/mtd/mtd.h

index c501eec17b387adf38f060cbc3bfa6c77840d979..55f0961103a778503618b33215a26b79f029fc95 100644 (file)
@@ -1124,25 +1124,21 @@ static unsigned long mtdchar_get_unmapped_area(struct file *file,
 {
        struct mtd_file_info *mfi = file->private_data;
        struct mtd_info *mtd = mfi->mtd;
+       unsigned long offset;
+       int ret;
 
-       if (mtd->get_unmapped_area) {
-               unsigned long offset;
-
-               if (addr != 0)
-                       return (unsigned long) -EINVAL;
-
-               if (len > mtd->size || pgoff >= (mtd->size >> PAGE_SHIFT))
-                       return (unsigned long) -EINVAL;
+       if (addr != 0)
+               return (unsigned long) -EINVAL;
 
-               offset = pgoff << PAGE_SHIFT;
-               if (offset > mtd->size - len)
-                       return (unsigned long) -EINVAL;
+       if (len > mtd->size || pgoff >= (mtd->size >> PAGE_SHIFT))
+               return (unsigned long) -EINVAL;
 
-               return mtd_get_unmapped_area(mtd, len, offset, flags);
-       }
+       offset = pgoff << PAGE_SHIFT;
+       if (offset > mtd->size - len)
+               return (unsigned long) -EINVAL;
 
-       /* can't map directly */
-       return (unsigned long) -ENOSYS;
+       ret = mtd_get_unmapped_area(mtd, len, offset, flags);
+       return ret == -EOPNOTSUPP ? -ENOSYS : ret;
 }
 #endif
 
index f694b51e7856eb0bee70879983d86fa3b8df7e13..9119f76f87fffa9faceecf600505d1c499d2b3ef 100644 (file)
@@ -726,11 +726,7 @@ static unsigned long concat_get_unmapped_area(struct mtd_info *mtd,
                if (offset + len > subdev->size)
                        return (unsigned long) -EINVAL;
 
-               if (subdev->get_unmapped_area)
-                       return mtd_get_unmapped_area(subdev, len, offset,
-                                                    flags);
-
-               break;
+               return mtd_get_unmapped_area(subdev, len, offset, flags);
        }
 
        return (unsigned long) -ENOSYS;
index b355a83e7cc2252b393a195f13874835ab88d27a..2c2a92247e5a93dae465ffbe23a12015ea3880e2 100644 (file)
@@ -280,6 +280,8 @@ static inline unsigned long mtd_get_unmapped_area(struct mtd_info *mtd,
                                                  unsigned long offset,
                                                  unsigned long flags)
 {
+       if (!mtd->get_unmapped_area)
+               return -EOPNOTSUPP;
        return mtd->get_unmapped_area(mtd, len, offset, flags);
 }