aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/mtdconcat.c
diff options
context:
space:
mode:
authorArtem Bityutskiy <artem.bityutskiy@linux.intel.com>2012-02-03 09:23:52 -0500
committerDavid Woodhouse <David.Woodhouse@intel.com>2012-03-26 19:28:18 -0400
commit5def48982b778aaebe201f85af7170b7d0a6619f (patch)
tree2920f1b524698877fab8521ee04349a5e285e47d /drivers/mtd/mtdconcat.c
parent8273a0c911d8e068297ef70aa7241ee78db4c712 (diff)
mtd: do not duplicate length and offset checks in drivers
We already verify that offset and length are within the MTD device size in the MTD API functions. Let's remove the duplicated checks in drivers. This patch only affects the following API's: 'mtd_erase()' 'mtd_point()' 'mtd_unpoint()' 'mtd_get_unmapped_area()' 'mtd_read()' 'mtd_write()' 'mtd_panic_write()' 'mtd_lock()' 'mtd_unlock()' 'mtd_is_locked()' 'mtd_block_isbad()' 'mtd_block_markbad()' This patch adds a bit of noise by removing too sparse empty lines, but this is not too bad. Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers/mtd/mtdconcat.c')
-rw-r--r--drivers/mtd/mtdconcat.c26
1 files changed, 0 insertions, 26 deletions
diff --git a/drivers/mtd/mtdconcat.c b/drivers/mtd/mtdconcat.c
index d826a8a50e73..1f2071803931 100644
--- a/drivers/mtd/mtdconcat.c
+++ b/drivers/mtd/mtdconcat.c
@@ -185,10 +185,6 @@ concat_writev(struct mtd_info *mtd, const struct kvec *vecs,
185 for (i = 0; i < count; i++) 185 for (i = 0; i < count; i++)
186 total_len += vecs[i].iov_len; 186 total_len += vecs[i].iov_len;
187 187
188 /* Do not allow write past end of device */
189 if ((to + total_len) > mtd->size)
190 return -EINVAL;
191
192 /* Check alignment */ 188 /* Check alignment */
193 if (mtd->writesize > 1) { 189 if (mtd->writesize > 1) {
194 uint64_t __to = to; 190 uint64_t __to = to;
@@ -406,12 +402,6 @@ static int concat_erase(struct mtd_info *mtd, struct erase_info *instr)
406 if (!(mtd->flags & MTD_WRITEABLE)) 402 if (!(mtd->flags & MTD_WRITEABLE))
407 return -EROFS; 403 return -EROFS;
408 404
409 if (instr->addr > concat->mtd.size)
410 return -EINVAL;
411
412 if (instr->len + instr->addr > concat->mtd.size)
413 return -EINVAL;
414
415 /* 405 /*
416 * Check for proper erase block alignment of the to-be-erased area. 406 * Check for proper erase block alignment of the to-be-erased area.
417 * It is easier to do this based on the super device's erase 407 * It is easier to do this based on the super device's erase
@@ -538,9 +528,6 @@ static int concat_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
538 struct mtd_concat *concat = CONCAT(mtd); 528 struct mtd_concat *concat = CONCAT(mtd);
539 int i, err = -EINVAL; 529 int i, err = -EINVAL;
540 530
541 if ((len + ofs) > mtd->size)
542 return -EINVAL;
543
544 for (i = 0; i < concat->num_subdev; i++) { 531 for (i = 0; i < concat->num_subdev; i++) {
545 struct mtd_info *subdev = concat->subdev[i]; 532 struct mtd_info *subdev = concat->subdev[i];
546 uint64_t size; 533 uint64_t size;
@@ -575,9 +562,6 @@ static int concat_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
575 struct mtd_concat *concat = CONCAT(mtd); 562 struct mtd_concat *concat = CONCAT(mtd);
576 int i, err = 0; 563 int i, err = 0;
577 564
578 if ((len + ofs) > mtd->size)
579 return -EINVAL;
580
581 for (i = 0; i < concat->num_subdev; i++) { 565 for (i = 0; i < concat->num_subdev; i++) {
582 struct mtd_info *subdev = concat->subdev[i]; 566 struct mtd_info *subdev = concat->subdev[i];
583 uint64_t size; 567 uint64_t size;
@@ -650,9 +634,6 @@ static int concat_block_isbad(struct mtd_info *mtd, loff_t ofs)
650 if (!mtd_can_have_bb(concat->subdev[0])) 634 if (!mtd_can_have_bb(concat->subdev[0]))
651 return res; 635 return res;
652 636
653 if (ofs > mtd->size)
654 return -EINVAL;
655
656 for (i = 0; i < concat->num_subdev; i++) { 637 for (i = 0; i < concat->num_subdev; i++) {
657 struct mtd_info *subdev = concat->subdev[i]; 638 struct mtd_info *subdev = concat->subdev[i];
658 639
@@ -673,9 +654,6 @@ static int concat_block_markbad(struct mtd_info *mtd, loff_t ofs)
673 struct mtd_concat *concat = CONCAT(mtd); 654 struct mtd_concat *concat = CONCAT(mtd);
674 int i, err = -EINVAL; 655 int i, err = -EINVAL;
675 656
676 if (ofs > mtd->size)
677 return -EINVAL;
678
679 for (i = 0; i < concat->num_subdev; i++) { 657 for (i = 0; i < concat->num_subdev; i++) {
680 struct mtd_info *subdev = concat->subdev[i]; 658 struct mtd_info *subdev = concat->subdev[i];
681 659
@@ -713,10 +691,6 @@ static unsigned long concat_get_unmapped_area(struct mtd_info *mtd,
713 continue; 691 continue;
714 } 692 }
715 693
716 /* we've found the subdev over which the mapping will reside */
717 if (offset + len > subdev->size)
718 return (unsigned long) -EINVAL;
719
720 return mtd_get_unmapped_area(subdev, len, offset, flags); 694 return mtd_get_unmapped_area(subdev, len, offset, flags);
721 } 695 }
722 696