Commit 381345652fca688aeaa967c231e5075cf68d05b6
Committed by
David Woodhouse
1 parent
327cf2922b
Exists in
master
and in
20 other branches
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>
Showing 5 changed files with 19 additions and 29 deletions Side-by-side Diff
drivers/mtd/maps/scb2_flash.c
drivers/mtd/mtdchar.c
... | ... | @@ -814,10 +814,7 @@ |
814 | 814 | if (copy_from_user(&einfo, argp, sizeof(einfo))) |
815 | 815 | return -EFAULT; |
816 | 816 | |
817 | - if (!mtd->lock) | |
818 | - ret = -EOPNOTSUPP; | |
819 | - else | |
820 | - ret = mtd_lock(mtd, einfo.start, einfo.length); | |
817 | + ret = mtd_lock(mtd, einfo.start, einfo.length); | |
821 | 818 | break; |
822 | 819 | } |
823 | 820 | |
... | ... | @@ -828,10 +825,7 @@ |
828 | 825 | if (copy_from_user(&einfo, argp, sizeof(einfo))) |
829 | 826 | return -EFAULT; |
830 | 827 | |
831 | - if (!mtd->unlock) | |
832 | - ret = -EOPNOTSUPP; | |
833 | - else | |
834 | - ret = mtd_unlock(mtd, einfo.start, einfo.length); | |
828 | + ret = mtd_unlock(mtd, einfo.start, einfo.length); | |
835 | 829 | break; |
836 | 830 | } |
837 | 831 | |
... | ... | @@ -842,10 +836,7 @@ |
842 | 836 | if (copy_from_user(&einfo, argp, sizeof(einfo))) |
843 | 837 | return -EFAULT; |
844 | 838 | |
845 | - if (!mtd->is_locked) | |
846 | - ret = -EOPNOTSUPP; | |
847 | - else | |
848 | - ret = mtd_is_locked(mtd, einfo.start, einfo.length); | |
839 | + ret = mtd_is_locked(mtd, einfo.start, einfo.length); | |
849 | 840 | break; |
850 | 841 | } |
851 | 842 |
drivers/mtd/mtdconcat.c
... | ... | @@ -555,12 +555,9 @@ |
555 | 555 | else |
556 | 556 | size = len; |
557 | 557 | |
558 | - if (subdev->lock) { | |
559 | - err = mtd_lock(subdev, ofs, size); | |
560 | - if (err) | |
561 | - break; | |
562 | - } else | |
563 | - err = -EOPNOTSUPP; | |
558 | + err = mtd_lock(subdev, ofs, size); | |
559 | + if (err) | |
560 | + break; | |
564 | 561 | |
565 | 562 | len -= size; |
566 | 563 | if (len == 0) |
... | ... | @@ -595,12 +592,9 @@ |
595 | 592 | else |
596 | 593 | size = len; |
597 | 594 | |
598 | - if (subdev->unlock) { | |
599 | - err = mtd_unlock(subdev, ofs, size); | |
600 | - if (err) | |
601 | - break; | |
602 | - } else | |
603 | - err = -EOPNOTSUPP; | |
595 | + err = mtd_unlock(subdev, ofs, size); | |
596 | + if (err) | |
597 | + break; | |
604 | 598 | |
605 | 599 | len -= size; |
606 | 600 | if (len == 0) |
drivers/mtd/mtdcore.c
... | ... | @@ -339,9 +339,9 @@ |
339 | 339 | mtd->writesize_mask = (1 << mtd->writesize_shift) - 1; |
340 | 340 | |
341 | 341 | /* Some chips always power up locked. Unlock them now */ |
342 | - if ((mtd->flags & MTD_WRITEABLE) | |
343 | - && (mtd->flags & MTD_POWERUP_LOCK) && mtd->unlock) { | |
344 | - if (mtd_unlock(mtd, 0, mtd->size)) | |
342 | + if ((mtd->flags & MTD_WRITEABLE) && (mtd->flags & MTD_POWERUP_LOCK)) { | |
343 | + error = mtd_unlock(mtd, 0, mtd->size); | |
344 | + if (error && error != -EOPNOTSUPP) | |
345 | 345 | printk(KERN_WARNING |
346 | 346 | "%s: unlock failed, writes may not work\n", |
347 | 347 | mtd->name); |
include/linux/mtd/mtd.h
... | ... | @@ -406,16 +406,22 @@ |
406 | 406 | /* Chip-supported device locking */ |
407 | 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 | 411 | return mtd->lock(mtd, ofs, len); |
410 | 412 | } |
411 | 413 | |
412 | 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 | 418 | return mtd->unlock(mtd, ofs, len); |
415 | 419 | } |
416 | 420 | |
417 | 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 | 425 | return mtd->is_locked(mtd, ofs, len); |
420 | 426 | } |
421 | 427 |