diff options
author | Artem Bityutskiy <artem.bityutskiy@linux.intel.com> | 2011-12-30 10:00:35 -0500 |
---|---|---|
committer | David Woodhouse <David.Woodhouse@intel.com> | 2012-01-09 13:26:22 -0500 |
commit | 381345652fca688aeaa967c231e5075cf68d05b6 (patch) | |
tree | 5f23ecdd28165d15109c6fd7ad0c4c573f094707 | |
parent | 327cf2922b4edf0439b219469722d2a502e37349 (diff) |
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: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
-rw-r--r-- | drivers/mtd/maps/scb2_flash.c | 3 | ||||
-rw-r--r-- | drivers/mtd/mtdchar.c | 15 | ||||
-rw-r--r-- | drivers/mtd/mtdconcat.c | 18 | ||||
-rw-r--r-- | drivers/mtd/mtdcore.c | 6 | ||||
-rw-r--r-- | include/linux/mtd/mtd.h | 6 |
5 files changed, 19 insertions, 29 deletions
diff --git a/drivers/mtd/maps/scb2_flash.c b/drivers/mtd/maps/scb2_flash.c index 01af34778de3..934a72c80078 100644 --- a/drivers/mtd/maps/scb2_flash.c +++ b/drivers/mtd/maps/scb2_flash.c | |||
@@ -204,8 +204,7 @@ scb2_flash_remove(struct pci_dev *dev) | |||
204 | return; | 204 | return; |
205 | 205 | ||
206 | /* disable flash writes */ | 206 | /* disable flash writes */ |
207 | if (scb2_mtd->lock) | 207 | mtd_lock(scb2_mtd, 0, scb2_mtd->size); |
208 | mtd_lock(scb2_mtd, 0, scb2_mtd->size); | ||
209 | 208 | ||
210 | mtd_device_unregister(scb2_mtd); | 209 | mtd_device_unregister(scb2_mtd); |
211 | map_destroy(scb2_mtd); | 210 | map_destroy(scb2_mtd); |
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c index 23a51104aeb5..92da621b1425 100644 --- a/drivers/mtd/mtdchar.c +++ b/drivers/mtd/mtdchar.c | |||
@@ -814,10 +814,7 @@ static int mtdchar_ioctl(struct file *file, u_int cmd, u_long arg) | |||
814 | if (copy_from_user(&einfo, argp, sizeof(einfo))) | 814 | if (copy_from_user(&einfo, argp, sizeof(einfo))) |
815 | return -EFAULT; | 815 | return -EFAULT; |
816 | 816 | ||
817 | if (!mtd->lock) | 817 | ret = mtd_lock(mtd, einfo.start, einfo.length); |
818 | ret = -EOPNOTSUPP; | ||
819 | else | ||
820 | ret = mtd_lock(mtd, einfo.start, einfo.length); | ||
821 | break; | 818 | break; |
822 | } | 819 | } |
823 | 820 | ||
@@ -828,10 +825,7 @@ static int mtdchar_ioctl(struct file *file, u_int cmd, u_long arg) | |||
828 | if (copy_from_user(&einfo, argp, sizeof(einfo))) | 825 | if (copy_from_user(&einfo, argp, sizeof(einfo))) |
829 | return -EFAULT; | 826 | return -EFAULT; |
830 | 827 | ||
831 | if (!mtd->unlock) | 828 | ret = mtd_unlock(mtd, einfo.start, einfo.length); |
832 | ret = -EOPNOTSUPP; | ||
833 | else | ||
834 | ret = mtd_unlock(mtd, einfo.start, einfo.length); | ||
835 | break; | 829 | break; |
836 | } | 830 | } |
837 | 831 | ||
@@ -842,10 +836,7 @@ static int mtdchar_ioctl(struct file *file, u_int cmd, u_long arg) | |||
842 | if (copy_from_user(&einfo, argp, sizeof(einfo))) | 836 | if (copy_from_user(&einfo, argp, sizeof(einfo))) |
843 | return -EFAULT; | 837 | return -EFAULT; |
844 | 838 | ||
845 | if (!mtd->is_locked) | 839 | ret = mtd_is_locked(mtd, einfo.start, einfo.length); |
846 | ret = -EOPNOTSUPP; | ||
847 | else | ||
848 | ret = mtd_is_locked(mtd, einfo.start, einfo.length); | ||
849 | break; | 840 | break; |
850 | } | 841 | } |
851 | 842 | ||
diff --git a/drivers/mtd/mtdconcat.c b/drivers/mtd/mtdconcat.c index 9119f76f87ff..aaafb5e18765 100644 --- a/drivers/mtd/mtdconcat.c +++ b/drivers/mtd/mtdconcat.c | |||
@@ -555,12 +555,9 @@ static int concat_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len) | |||
555 | else | 555 | else |
556 | size = len; | 556 | size = len; |
557 | 557 | ||
558 | if (subdev->lock) { | 558 | err = mtd_lock(subdev, ofs, size); |
559 | err = mtd_lock(subdev, ofs, size); | 559 | if (err) |
560 | if (err) | 560 | break; |
561 | break; | ||
562 | } else | ||
563 | err = -EOPNOTSUPP; | ||
564 | 561 | ||
565 | len -= size; | 562 | len -= size; |
566 | if (len == 0) | 563 | if (len == 0) |
@@ -595,12 +592,9 @@ static int concat_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len) | |||
595 | else | 592 | else |
596 | size = len; | 593 | size = len; |
597 | 594 | ||
598 | if (subdev->unlock) { | 595 | err = mtd_unlock(subdev, ofs, size); |
599 | err = mtd_unlock(subdev, ofs, size); | 596 | if (err) |
600 | if (err) | 597 | break; |
601 | break; | ||
602 | } else | ||
603 | err = -EOPNOTSUPP; | ||
604 | 598 | ||
605 | len -= size; | 599 | len -= size; |
606 | if (len == 0) | 600 | if (len == 0) |
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c index 4d0f3e557bd1..66494ee5355a 100644 --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c | |||
@@ -339,9 +339,9 @@ int add_mtd_device(struct mtd_info *mtd) | |||
339 | mtd->writesize_mask = (1 << mtd->writesize_shift) - 1; | 339 | mtd->writesize_mask = (1 << mtd->writesize_shift) - 1; |
340 | 340 | ||
341 | /* Some chips always power up locked. Unlock them now */ | 341 | /* Some chips always power up locked. Unlock them now */ |
342 | if ((mtd->flags & MTD_WRITEABLE) | 342 | if ((mtd->flags & MTD_WRITEABLE) && (mtd->flags & MTD_POWERUP_LOCK)) { |
343 | && (mtd->flags & MTD_POWERUP_LOCK) && mtd->unlock) { | 343 | error = mtd_unlock(mtd, 0, mtd->size); |
344 | if (mtd_unlock(mtd, 0, mtd->size)) | 344 | if (error && error != -EOPNOTSUPP) |
345 | printk(KERN_WARNING | 345 | printk(KERN_WARNING |
346 | "%s: unlock failed, writes may not work\n", | 346 | "%s: unlock failed, writes may not work\n", |
347 | mtd->name); | 347 | mtd->name); |
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h index 305f12b940f4..6c91ba59c229 100644 --- a/include/linux/mtd/mtd.h +++ b/include/linux/mtd/mtd.h | |||
@@ -406,16 +406,22 @@ static inline void mtd_sync(struct mtd_info *mtd) | |||
406 | /* Chip-supported device locking */ | 406 | /* Chip-supported device locking */ |
407 | static inline int mtd_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len) | 407 | static inline int mtd_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len) |
408 | { | 408 | { |
409 | if (!mtd->lock) | ||
410 | return -EOPNOTSUPP; | ||
409 | return mtd->lock(mtd, ofs, len); | 411 | return mtd->lock(mtd, ofs, len); |
410 | } | 412 | } |
411 | 413 | ||
412 | static inline int mtd_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len) | 414 | static inline int mtd_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len) |
413 | { | 415 | { |
416 | if (!mtd->unlock) | ||
417 | return -EOPNOTSUPP; | ||
414 | return mtd->unlock(mtd, ofs, len); | 418 | return mtd->unlock(mtd, ofs, len); |
415 | } | 419 | } |
416 | 420 | ||
417 | static inline int mtd_is_locked(struct mtd_info *mtd, loff_t ofs, uint64_t len) | 421 | static inline int mtd_is_locked(struct mtd_info *mtd, loff_t ofs, uint64_t len) |
418 | { | 422 | { |
423 | if (!mtd->is_locked) | ||
424 | return -EOPNOTSUPP; | ||
419 | return mtd->is_locked(mtd, ofs, len); | 425 | return mtd->is_locked(mtd, ofs, len); |
420 | } | 426 | } |
421 | 427 | ||