aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/nand
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/nand
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/nand')
-rw-r--r--drivers/mtd/nand/nand_base.c28
1 files changed, 0 insertions, 28 deletions
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 13a56d3e8aec..dd182c8591a9 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -123,12 +123,6 @@ static int check_offs_len(struct mtd_info *mtd,
123 ret = -EINVAL; 123 ret = -EINVAL;
124 } 124 }
125 125
126 /* Do not allow past end of device */
127 if (ofs + len > mtd->size) {
128 pr_debug("%s: past end of device\n", __func__);
129 ret = -EINVAL;
130 }
131
132 return ret; 126 return ret;
133} 127}
134 128
@@ -1620,25 +1614,17 @@ static int nand_read(struct mtd_info *mtd, loff_t from, size_t len,
1620 struct mtd_oob_ops ops; 1614 struct mtd_oob_ops ops;
1621 int ret; 1615 int ret;
1622 1616
1623 /* Do not allow reads past end of device */
1624 if ((from + len) > mtd->size)
1625 return -EINVAL;
1626 if (!len) 1617 if (!len)
1627 return 0; 1618 return 0;
1628 1619
1629 nand_get_device(chip, mtd, FL_READING); 1620 nand_get_device(chip, mtd, FL_READING);
1630
1631 ops.len = len; 1621 ops.len = len;
1632 ops.datbuf = buf; 1622 ops.datbuf = buf;
1633 ops.oobbuf = NULL; 1623 ops.oobbuf = NULL;
1634 ops.mode = 0; 1624 ops.mode = 0;
1635
1636 ret = nand_do_read_ops(mtd, from, &ops); 1625 ret = nand_do_read_ops(mtd, from, &ops);
1637
1638 *retlen = ops.retlen; 1626 *retlen = ops.retlen;
1639
1640 nand_release_device(mtd); 1627 nand_release_device(mtd);
1641
1642 return ret; 1628 return ret;
1643} 1629}
1644 1630
@@ -2328,8 +2314,6 @@ static int panic_nand_write(struct mtd_info *mtd, loff_t to, size_t len,
2328 int ret; 2314 int ret;
2329 2315
2330 /* Do not allow reads past end of device */ 2316 /* Do not allow reads past end of device */
2331 if ((to + len) > mtd->size)
2332 return -EINVAL;
2333 if (!len) 2317 if (!len)
2334 return 0; 2318 return 0;
2335 2319
@@ -2367,25 +2351,17 @@ static int nand_write(struct mtd_info *mtd, loff_t to, size_t len,
2367 struct mtd_oob_ops ops; 2351 struct mtd_oob_ops ops;
2368 int ret; 2352 int ret;
2369 2353
2370 /* Do not allow reads past end of device */
2371 if ((to + len) > mtd->size)
2372 return -EINVAL;
2373 if (!len) 2354 if (!len)
2374 return 0; 2355 return 0;
2375 2356
2376 nand_get_device(chip, mtd, FL_WRITING); 2357 nand_get_device(chip, mtd, FL_WRITING);
2377
2378 ops.len = len; 2358 ops.len = len;
2379 ops.datbuf = (uint8_t *)buf; 2359 ops.datbuf = (uint8_t *)buf;
2380 ops.oobbuf = NULL; 2360 ops.oobbuf = NULL;
2381 ops.mode = 0; 2361 ops.mode = 0;
2382
2383 ret = nand_do_write_ops(mtd, to, &ops); 2362 ret = nand_do_write_ops(mtd, to, &ops);
2384
2385 *retlen = ops.retlen; 2363 *retlen = ops.retlen;
2386
2387 nand_release_device(mtd); 2364 nand_release_device(mtd);
2388
2389 return ret; 2365 return ret;
2390} 2366}
2391 2367
@@ -2749,10 +2725,6 @@ static void nand_sync(struct mtd_info *mtd)
2749 */ 2725 */
2750static int nand_block_isbad(struct mtd_info *mtd, loff_t offs) 2726static int nand_block_isbad(struct mtd_info *mtd, loff_t offs)
2751{ 2727{
2752 /* Check for invalid offset */
2753 if (offs > mtd->size)
2754 return -EINVAL;
2755
2756 return nand_block_checkbad(mtd, offs, 1, 0); 2728 return nand_block_checkbad(mtd, offs, 1, 0);
2757} 2729}
2758 2730