]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
mtd: do not use mtd->lock, unlock and is_locked directly
authorArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Fri, 30 Dec 2011 15:00:35 +0000 (17:00 +0200)
committerDavid Woodhouse <David.Woodhouse@intel.com>
Mon, 9 Jan 2012 18:26:22 +0000 (18:26 +0000)
Instead, call the corresponding MTD API function which will return
'-EOPNOTSUPP' if the operation is not supported.

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

index 01af34778de39b4b618a09326fd4e0ed3a64d112..934a72c8007880407247915d1d814225c45d65f2 100644 (file)
@@ -204,8 +204,7 @@ scb2_flash_remove(struct pci_dev *dev)
                return;
 
        /* disable flash writes */
-       if (scb2_mtd->lock)
-               mtd_lock(scb2_mtd, 0, scb2_mtd->size);
+       mtd_lock(scb2_mtd, 0, scb2_mtd->size);
 
        mtd_device_unregister(scb2_mtd);
        map_destroy(scb2_mtd);
index 23a51104aeb5fcb04ebefe07b0a21895c847876d..92da621b1425a34690239f07eaa5a68ef693e0a8 100644 (file)
@@ -814,10 +814,7 @@ static int mtdchar_ioctl(struct file *file, u_int cmd, u_long arg)
                if (copy_from_user(&einfo, argp, sizeof(einfo)))
                        return -EFAULT;
 
-               if (!mtd->lock)
-                       ret = -EOPNOTSUPP;
-               else
-                       ret = mtd_lock(mtd, einfo.start, einfo.length);
+               ret = mtd_lock(mtd, einfo.start, einfo.length);
                break;
        }
 
@@ -828,10 +825,7 @@ static int mtdchar_ioctl(struct file *file, u_int cmd, u_long arg)
                if (copy_from_user(&einfo, argp, sizeof(einfo)))
                        return -EFAULT;
 
-               if (!mtd->unlock)
-                       ret = -EOPNOTSUPP;
-               else
-                       ret = mtd_unlock(mtd, einfo.start, einfo.length);
+               ret = mtd_unlock(mtd, einfo.start, einfo.length);
                break;
        }
 
@@ -842,10 +836,7 @@ static int mtdchar_ioctl(struct file *file, u_int cmd, u_long arg)
                if (copy_from_user(&einfo, argp, sizeof(einfo)))
                        return -EFAULT;
 
-               if (!mtd->is_locked)
-                       ret = -EOPNOTSUPP;
-               else
-                       ret = mtd_is_locked(mtd, einfo.start, einfo.length);
+               ret = mtd_is_locked(mtd, einfo.start, einfo.length);
                break;
        }
 
index 9119f76f87fffa9faceecf600505d1c499d2b3ef..aaafb5e187653a6365560f7cf77c2ee80f529b57 100644 (file)
@@ -555,12 +555,9 @@ static int concat_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
                else
                        size = len;
 
-               if (subdev->lock) {
-                       err = mtd_lock(subdev, ofs, size);
-                       if (err)
-                               break;
-               } else
-                       err = -EOPNOTSUPP;
+               err = mtd_lock(subdev, ofs, size);
+               if (err)
+                       break;
 
                len -= size;
                if (len == 0)
@@ -595,12 +592,9 @@ static int concat_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
                else
                        size = len;
 
-               if (subdev->unlock) {
-                       err = mtd_unlock(subdev, ofs, size);
-                       if (err)
-                               break;
-               } else
-                       err = -EOPNOTSUPP;
+               err = mtd_unlock(subdev, ofs, size);
+               if (err)
+                       break;
 
                len -= size;
                if (len == 0)
index 4d0f3e557bd170ebc0e2332c9477f571244f189e..66494ee5355a9a857670a2eaa360b4b8f9311265 100644 (file)
@@ -339,9 +339,9 @@ int add_mtd_device(struct mtd_info *mtd)
        mtd->writesize_mask = (1 << mtd->writesize_shift) - 1;
 
        /* Some chips always power up locked. Unlock them now */
-       if ((mtd->flags & MTD_WRITEABLE)
-           && (mtd->flags & MTD_POWERUP_LOCK) && mtd->unlock) {
-               if (mtd_unlock(mtd, 0, mtd->size))
+       if ((mtd->flags & MTD_WRITEABLE) && (mtd->flags & MTD_POWERUP_LOCK)) {
+               error = mtd_unlock(mtd, 0, mtd->size);
+               if (error && error != -EOPNOTSUPP)
                        printk(KERN_WARNING
                               "%s: unlock failed, writes may not work\n",
                               mtd->name);
index 305f12b940f43a48f5d8a1fc0154e48de025ca2b..6c91ba59c229263cc55c611ae24ff363213fd37f 100644 (file)
@@ -406,16 +406,22 @@ static inline void mtd_sync(struct mtd_info *mtd)
 /* Chip-supported device locking */
 static inline int mtd_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
 {
+       if (!mtd->lock)
+               return -EOPNOTSUPP;
        return mtd->lock(mtd, ofs, len);
 }
 
 static inline int mtd_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
 {
+       if (!mtd->unlock)
+               return -EOPNOTSUPP;
        return mtd->unlock(mtd, ofs, len);
 }
 
 static inline int mtd_is_locked(struct mtd_info *mtd, loff_t ofs, uint64_t len)
 {
+       if (!mtd->is_locked)
+               return -EOPNOTSUPP;
        return mtd->is_locked(mtd, ofs, len);
 }