提交 38134565 编写于 作者: A Artem Bityutskiy 提交者: David Woodhouse

mtd: do not use mtd->lock, unlock and is_locked directly

Instead, call the corresponding MTD API function which will return
'-EOPNOTSUPP' if the operation is not supported.
Signed-off-by: NArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: NDavid Woodhouse <David.Woodhouse@intel.com>
上级 327cf292
...@@ -204,8 +204,7 @@ scb2_flash_remove(struct pci_dev *dev) ...@@ -204,8 +204,7 @@ scb2_flash_remove(struct pci_dev *dev)
return; return;
/* disable flash writes */ /* 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); mtd_device_unregister(scb2_mtd);
map_destroy(scb2_mtd); map_destroy(scb2_mtd);
......
...@@ -814,10 +814,7 @@ static int mtdchar_ioctl(struct file *file, u_int cmd, u_long arg) ...@@ -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))) if (copy_from_user(&einfo, argp, sizeof(einfo)))
return -EFAULT; return -EFAULT;
if (!mtd->lock) ret = mtd_lock(mtd, einfo.start, einfo.length);
ret = -EOPNOTSUPP;
else
ret = mtd_lock(mtd, einfo.start, einfo.length);
break; break;
} }
...@@ -828,10 +825,7 @@ static int mtdchar_ioctl(struct file *file, u_int cmd, u_long arg) ...@@ -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))) if (copy_from_user(&einfo, argp, sizeof(einfo)))
return -EFAULT; return -EFAULT;
if (!mtd->unlock) ret = mtd_unlock(mtd, einfo.start, einfo.length);
ret = -EOPNOTSUPP;
else
ret = mtd_unlock(mtd, einfo.start, einfo.length);
break; break;
} }
...@@ -842,10 +836,7 @@ static int mtdchar_ioctl(struct file *file, u_int cmd, u_long arg) ...@@ -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))) if (copy_from_user(&einfo, argp, sizeof(einfo)))
return -EFAULT; return -EFAULT;
if (!mtd->is_locked) ret = mtd_is_locked(mtd, einfo.start, einfo.length);
ret = -EOPNOTSUPP;
else
ret = mtd_is_locked(mtd, einfo.start, einfo.length);
break; break;
} }
......
...@@ -555,12 +555,9 @@ static int concat_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len) ...@@ -555,12 +555,9 @@ static int concat_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
else else
size = len; size = len;
if (subdev->lock) { err = mtd_lock(subdev, ofs, size);
err = mtd_lock(subdev, ofs, size); if (err)
if (err) break;
break;
} else
err = -EOPNOTSUPP;
len -= size; len -= size;
if (len == 0) if (len == 0)
...@@ -595,12 +592,9 @@ static int concat_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len) ...@@ -595,12 +592,9 @@ static int concat_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
else else
size = len; size = len;
if (subdev->unlock) { err = mtd_unlock(subdev, ofs, size);
err = mtd_unlock(subdev, ofs, size); if (err)
if (err) break;
break;
} else
err = -EOPNOTSUPP;
len -= size; len -= size;
if (len == 0) if (len == 0)
......
...@@ -339,9 +339,9 @@ int add_mtd_device(struct mtd_info *mtd) ...@@ -339,9 +339,9 @@ int add_mtd_device(struct mtd_info *mtd)
mtd->writesize_mask = (1 << mtd->writesize_shift) - 1; mtd->writesize_mask = (1 << mtd->writesize_shift) - 1;
/* Some chips always power up locked. Unlock them now */ /* Some chips always power up locked. Unlock them now */
if ((mtd->flags & MTD_WRITEABLE) if ((mtd->flags & MTD_WRITEABLE) && (mtd->flags & MTD_POWERUP_LOCK)) {
&& (mtd->flags & MTD_POWERUP_LOCK) && mtd->unlock) { error = mtd_unlock(mtd, 0, mtd->size);
if (mtd_unlock(mtd, 0, mtd->size)) if (error && error != -EOPNOTSUPP)
printk(KERN_WARNING printk(KERN_WARNING
"%s: unlock failed, writes may not work\n", "%s: unlock failed, writes may not work\n",
mtd->name); mtd->name);
......
...@@ -406,16 +406,22 @@ static inline void mtd_sync(struct mtd_info *mtd) ...@@ -406,16 +406,22 @@ static inline void mtd_sync(struct mtd_info *mtd)
/* Chip-supported device locking */ /* Chip-supported device locking */
static inline int mtd_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len) 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); return mtd->lock(mtd, ofs, len);
} }
static inline int mtd_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t 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); return mtd->unlock(mtd, ofs, len);
} }
static inline int mtd_is_locked(struct mtd_info *mtd, loff_t ofs, uint64_t 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); return mtd->is_locked(mtd, ofs, len);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册