diff options
-rw-r--r-- | drivers/mtd/chips/cfi_cmdset_0001.c | 3 | ||||
-rw-r--r-- | drivers/mtd/chips/cfi_cmdset_0002.c | 9 | ||||
-rw-r--r-- | drivers/mtd/chips/cfi_cmdset_0020.c | 3 | ||||
-rw-r--r-- | drivers/mtd/devices/block2mtd.c | 3 | ||||
-rw-r--r-- | drivers/mtd/devices/lart.c | 3 | ||||
-rw-r--r-- | drivers/mtd/devices/m25p80.c | 12 | ||||
-rw-r--r-- | drivers/mtd/devices/mtd_dataflash.c | 10 | ||||
-rw-r--r-- | drivers/mtd/devices/spear_smi.c | 6 | ||||
-rw-r--r-- | drivers/mtd/devices/sst25l.c | 8 | ||||
-rw-r--r-- | drivers/mtd/lpddr/lpddr_cmds.c | 1 | ||||
-rw-r--r-- | drivers/mtd/maps/vmu-flash.c | 8 | ||||
-rw-r--r-- | drivers/mtd/mtdcore.c | 21 | ||||
-rw-r--r-- | drivers/mtd/nand/nand_base.c | 10 |
13 files changed, 21 insertions, 76 deletions
diff --git a/drivers/mtd/chips/cfi_cmdset_0001.c b/drivers/mtd/chips/cfi_cmdset_0001.c index dc66df6ab58a..2d9669047ed4 100644 --- a/drivers/mtd/chips/cfi_cmdset_0001.c +++ b/drivers/mtd/chips/cfi_cmdset_0001.c | |||
@@ -1566,9 +1566,6 @@ static int cfi_intelext_write_words (struct mtd_info *mtd, loff_t to , size_t le | |||
1566 | int chipnum; | 1566 | int chipnum; |
1567 | unsigned long ofs; | 1567 | unsigned long ofs; |
1568 | 1568 | ||
1569 | if (!len) | ||
1570 | return 0; | ||
1571 | |||
1572 | chipnum = to >> cfi->chipshift; | 1569 | chipnum = to >> cfi->chipshift; |
1573 | ofs = to - (chipnum << cfi->chipshift); | 1570 | ofs = to - (chipnum << cfi->chipshift); |
1574 | 1571 | ||
diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c index a89d899efad4..c1d4624ce6e7 100644 --- a/drivers/mtd/chips/cfi_cmdset_0002.c +++ b/drivers/mtd/chips/cfi_cmdset_0002.c | |||
@@ -1246,9 +1246,6 @@ static int cfi_amdstd_write_words(struct mtd_info *mtd, loff_t to, size_t len, | |||
1246 | unsigned long ofs, chipstart; | 1246 | unsigned long ofs, chipstart; |
1247 | DECLARE_WAITQUEUE(wait, current); | 1247 | DECLARE_WAITQUEUE(wait, current); |
1248 | 1248 | ||
1249 | if (!len) | ||
1250 | return 0; | ||
1251 | |||
1252 | chipnum = to >> cfi->chipshift; | 1249 | chipnum = to >> cfi->chipshift; |
1253 | ofs = to - (chipnum << cfi->chipshift); | 1250 | ofs = to - (chipnum << cfi->chipshift); |
1254 | chipstart = cfi->chips[chipnum].start; | 1251 | chipstart = cfi->chips[chipnum].start; |
@@ -1487,9 +1484,6 @@ static int cfi_amdstd_write_buffers(struct mtd_info *mtd, loff_t to, size_t len, | |||
1487 | int chipnum; | 1484 | int chipnum; |
1488 | unsigned long ofs; | 1485 | unsigned long ofs; |
1489 | 1486 | ||
1490 | if (!len) | ||
1491 | return 0; | ||
1492 | |||
1493 | chipnum = to >> cfi->chipshift; | 1487 | chipnum = to >> cfi->chipshift; |
1494 | ofs = to - (chipnum << cfi->chipshift); | 1488 | ofs = to - (chipnum << cfi->chipshift); |
1495 | 1489 | ||
@@ -1697,9 +1691,6 @@ static int cfi_amdstd_panic_write(struct mtd_info *mtd, loff_t to, size_t len, | |||
1697 | int ret = 0; | 1691 | int ret = 0; |
1698 | int chipnum; | 1692 | int chipnum; |
1699 | 1693 | ||
1700 | if (!len) | ||
1701 | return 0; | ||
1702 | |||
1703 | chipnum = to >> cfi->chipshift; | 1694 | chipnum = to >> cfi->chipshift; |
1704 | ofs = to - (chipnum << cfi->chipshift); | 1695 | ofs = to - (chipnum << cfi->chipshift); |
1705 | chipstart = cfi->chips[chipnum].start; | 1696 | chipstart = cfi->chips[chipnum].start; |
diff --git a/drivers/mtd/chips/cfi_cmdset_0020.c b/drivers/mtd/chips/cfi_cmdset_0020.c index d690b7d6952b..096993f9711e 100644 --- a/drivers/mtd/chips/cfi_cmdset_0020.c +++ b/drivers/mtd/chips/cfi_cmdset_0020.c | |||
@@ -615,9 +615,6 @@ static int cfi_staa_write_buffers (struct mtd_info *mtd, loff_t to, | |||
615 | int chipnum; | 615 | int chipnum; |
616 | unsigned long ofs; | 616 | unsigned long ofs; |
617 | 617 | ||
618 | if (!len) | ||
619 | return 0; | ||
620 | |||
621 | chipnum = to >> cfi->chipshift; | 618 | chipnum = to >> cfi->chipshift; |
622 | ofs = to - (chipnum << cfi->chipshift); | 619 | ofs = to - (chipnum << cfi->chipshift); |
623 | 620 | ||
diff --git a/drivers/mtd/devices/block2mtd.c b/drivers/mtd/devices/block2mtd.c index ba2d74b01c7e..a4a80b742e65 100644 --- a/drivers/mtd/devices/block2mtd.c +++ b/drivers/mtd/devices/block2mtd.c | |||
@@ -178,9 +178,6 @@ static int block2mtd_write(struct mtd_info *mtd, loff_t to, size_t len, | |||
178 | struct block2mtd_dev *dev = mtd->priv; | 178 | struct block2mtd_dev *dev = mtd->priv; |
179 | int err; | 179 | int err; |
180 | 180 | ||
181 | if (!len) | ||
182 | return 0; | ||
183 | |||
184 | mutex_lock(&dev->write_mutex); | 181 | mutex_lock(&dev->write_mutex); |
185 | err = _block2mtd_write(dev, buf, to, len, retlen); | 182 | err = _block2mtd_write(dev, buf, to, len, retlen); |
186 | mutex_unlock(&dev->write_mutex); | 183 | mutex_unlock(&dev->write_mutex); |
diff --git a/drivers/mtd/devices/lart.c b/drivers/mtd/devices/lart.c index 6fb8dba76959..82bd00af5cc3 100644 --- a/drivers/mtd/devices/lart.c +++ b/drivers/mtd/devices/lart.c | |||
@@ -437,9 +437,6 @@ static int flash_read (struct mtd_info *mtd,loff_t from,size_t len,size_t *retle | |||
437 | printk (KERN_DEBUG "%s(from = 0x%.8x, len = %d)\n", __func__, (__u32)from, len); | 437 | printk (KERN_DEBUG "%s(from = 0x%.8x, len = %d)\n", __func__, (__u32)from, len); |
438 | #endif | 438 | #endif |
439 | 439 | ||
440 | /* sanity checks */ | ||
441 | if (!len) return (0); | ||
442 | |||
443 | /* we always read len bytes */ | 440 | /* we always read len bytes */ |
444 | *retlen = len; | 441 | *retlen = len; |
445 | 442 | ||
diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c index 45cc4a1ae5b0..1924d247c1cb 100644 --- a/drivers/mtd/devices/m25p80.c +++ b/drivers/mtd/devices/m25p80.c | |||
@@ -346,10 +346,6 @@ static int m25p80_read(struct mtd_info *mtd, loff_t from, size_t len, | |||
346 | pr_debug("%s: %s from 0x%08x, len %zd\n", dev_name(&flash->spi->dev), | 346 | pr_debug("%s: %s from 0x%08x, len %zd\n", dev_name(&flash->spi->dev), |
347 | __func__, (u32)from, len); | 347 | __func__, (u32)from, len); |
348 | 348 | ||
349 | /* sanity checks */ | ||
350 | if (!len) | ||
351 | return 0; | ||
352 | |||
353 | spi_message_init(&m); | 349 | spi_message_init(&m); |
354 | memset(t, 0, (sizeof t)); | 350 | memset(t, 0, (sizeof t)); |
355 | 351 | ||
@@ -408,10 +404,6 @@ static int m25p80_write(struct mtd_info *mtd, loff_t to, size_t len, | |||
408 | pr_debug("%s: %s to 0x%08x, len %zd\n", dev_name(&flash->spi->dev), | 404 | pr_debug("%s: %s to 0x%08x, len %zd\n", dev_name(&flash->spi->dev), |
409 | __func__, (u32)to, len); | 405 | __func__, (u32)to, len); |
410 | 406 | ||
411 | /* sanity checks */ | ||
412 | if (!len) | ||
413 | return(0); | ||
414 | |||
415 | spi_message_init(&m); | 407 | spi_message_init(&m); |
416 | memset(t, 0, (sizeof t)); | 408 | memset(t, 0, (sizeof t)); |
417 | 409 | ||
@@ -495,10 +487,6 @@ static int sst_write(struct mtd_info *mtd, loff_t to, size_t len, | |||
495 | pr_debug("%s: %s to 0x%08x, len %zd\n", dev_name(&flash->spi->dev), | 487 | pr_debug("%s: %s to 0x%08x, len %zd\n", dev_name(&flash->spi->dev), |
496 | __func__, (u32)to, len); | 488 | __func__, (u32)to, len); |
497 | 489 | ||
498 | /* sanity checks */ | ||
499 | if (!len) | ||
500 | return 0; | ||
501 | |||
502 | spi_message_init(&m); | 490 | spi_message_init(&m); |
503 | memset(t, 0, (sizeof t)); | 491 | memset(t, 0, (sizeof t)); |
504 | 492 | ||
diff --git a/drivers/mtd/devices/mtd_dataflash.c b/drivers/mtd/devices/mtd_dataflash.c index c76b4464e8b9..928fb0e6d73a 100644 --- a/drivers/mtd/devices/mtd_dataflash.c +++ b/drivers/mtd/devices/mtd_dataflash.c | |||
@@ -249,10 +249,6 @@ static int dataflash_read(struct mtd_info *mtd, loff_t from, size_t len, | |||
249 | pr_debug("%s: read 0x%x..0x%x\n", dev_name(&priv->spi->dev), | 249 | pr_debug("%s: read 0x%x..0x%x\n", dev_name(&priv->spi->dev), |
250 | (unsigned)from, (unsigned)(from + len)); | 250 | (unsigned)from, (unsigned)(from + len)); |
251 | 251 | ||
252 | /* Sanity checks */ | ||
253 | if (!len) | ||
254 | return 0; | ||
255 | |||
256 | /* Calculate flash page/byte address */ | 252 | /* Calculate flash page/byte address */ |
257 | addr = (((unsigned)from / priv->page_size) << priv->page_offset) | 253 | addr = (((unsigned)from / priv->page_size) << priv->page_offset) |
258 | + ((unsigned)from % priv->page_size); | 254 | + ((unsigned)from % priv->page_size); |
@@ -321,10 +317,6 @@ static int dataflash_write(struct mtd_info *mtd, loff_t to, size_t len, | |||
321 | pr_debug("%s: write 0x%x..0x%x\n", | 317 | pr_debug("%s: write 0x%x..0x%x\n", |
322 | dev_name(&spi->dev), (unsigned)to, (unsigned)(to + len)); | 318 | dev_name(&spi->dev), (unsigned)to, (unsigned)(to + len)); |
323 | 319 | ||
324 | /* Sanity checks */ | ||
325 | if (!len) | ||
326 | return 0; | ||
327 | |||
328 | spi_message_init(&msg); | 320 | spi_message_init(&msg); |
329 | 321 | ||
330 | x[0].tx_buf = command = priv->command; | 322 | x[0].tx_buf = command = priv->command; |
@@ -479,8 +471,6 @@ static ssize_t otp_read(struct spi_device *spi, unsigned base, | |||
479 | 471 | ||
480 | if ((off + len) > 64) | 472 | if ((off + len) > 64) |
481 | len = 64 - off; | 473 | len = 64 - off; |
482 | if (len == 0) | ||
483 | return len; | ||
484 | 474 | ||
485 | spi_message_init(&m); | 475 | spi_message_init(&m); |
486 | 476 | ||
diff --git a/drivers/mtd/devices/spear_smi.c b/drivers/mtd/devices/spear_smi.c index 2cdbcc65b39f..f45dd37b771e 100644 --- a/drivers/mtd/devices/spear_smi.c +++ b/drivers/mtd/devices/spear_smi.c | |||
@@ -563,9 +563,6 @@ static int spear_mtd_read(struct mtd_info *mtd, loff_t from, size_t len, | |||
563 | u32 ctrlreg1, val; | 563 | u32 ctrlreg1, val; |
564 | int ret; | 564 | int ret; |
565 | 565 | ||
566 | if (!len) | ||
567 | return 0; | ||
568 | |||
569 | if (!flash || !dev) | 566 | if (!flash || !dev) |
570 | return -ENODEV; | 567 | return -ENODEV; |
571 | 568 | ||
@@ -662,9 +659,6 @@ static int spear_mtd_write(struct mtd_info *mtd, loff_t to, size_t len, | |||
662 | if (!flash || !dev) | 659 | if (!flash || !dev) |
663 | return -ENODEV; | 660 | return -ENODEV; |
664 | 661 | ||
665 | if (!len) | ||
666 | return 0; | ||
667 | |||
668 | if (flash->bank > dev->num_flashes - 1) { | 662 | if (flash->bank > dev->num_flashes - 1) { |
669 | dev_err(&dev->pdev->dev, "Invalid Bank Num"); | 663 | dev_err(&dev->pdev->dev, "Invalid Bank Num"); |
670 | return -EINVAL; | 664 | return -EINVAL; |
diff --git a/drivers/mtd/devices/sst25l.c b/drivers/mtd/devices/sst25l.c index 5c2613c99e4a..51b2df33b8e9 100644 --- a/drivers/mtd/devices/sst25l.c +++ b/drivers/mtd/devices/sst25l.c | |||
@@ -220,10 +220,6 @@ static int sst25l_read(struct mtd_info *mtd, loff_t from, size_t len, | |||
220 | unsigned char command[4]; | 220 | unsigned char command[4]; |
221 | int ret; | 221 | int ret; |
222 | 222 | ||
223 | /* Sanity checking */ | ||
224 | if (len == 0) | ||
225 | return 0; | ||
226 | |||
227 | spi_message_init(&message); | 223 | spi_message_init(&message); |
228 | memset(&transfer, 0, sizeof(transfer)); | 224 | memset(&transfer, 0, sizeof(transfer)); |
229 | 225 | ||
@@ -265,10 +261,6 @@ static int sst25l_write(struct mtd_info *mtd, loff_t to, size_t len, | |||
265 | int i, j, ret, bytes, copied = 0; | 261 | int i, j, ret, bytes, copied = 0; |
266 | unsigned char command[5]; | 262 | unsigned char command[5]; |
267 | 263 | ||
268 | /* Sanity checks */ | ||
269 | if (!len) | ||
270 | return 0; | ||
271 | |||
272 | if ((uint32_t)to % mtd->writesize) | 264 | if ((uint32_t)to % mtd->writesize) |
273 | return -EINVAL; | 265 | return -EINVAL; |
274 | 266 | ||
diff --git a/drivers/mtd/lpddr/lpddr_cmds.c b/drivers/mtd/lpddr/lpddr_cmds.c index a92906ba535d..d3cfe26beeaa 100644 --- a/drivers/mtd/lpddr/lpddr_cmds.c +++ b/drivers/mtd/lpddr/lpddr_cmds.c | |||
@@ -639,7 +639,6 @@ static int lpddr_writev(struct mtd_info *mtd, const struct kvec *vecs, | |||
639 | int chipnum; | 639 | int chipnum; |
640 | unsigned long ofs, vec_seek, i; | 640 | unsigned long ofs, vec_seek, i; |
641 | int wbufsize = 1 << lpddr->qinfo->BufSizeShift; | 641 | int wbufsize = 1 << lpddr->qinfo->BufSizeShift; |
642 | |||
643 | size_t len = 0; | 642 | size_t len = 0; |
644 | 643 | ||
645 | for (i = 0; i < count; i++) | 644 | for (i = 0; i < count; i++) |
diff --git a/drivers/mtd/maps/vmu-flash.c b/drivers/mtd/maps/vmu-flash.c index 48a803e2cd2e..2e2b0945edc7 100644 --- a/drivers/mtd/maps/vmu-flash.c +++ b/drivers/mtd/maps/vmu-flash.c | |||
@@ -360,9 +360,6 @@ static int vmu_flash_read(struct mtd_info *mtd, loff_t from, size_t len, | |||
360 | int index = 0, retval, partition, leftover, numblocks; | 360 | int index = 0, retval, partition, leftover, numblocks; |
361 | unsigned char cx; | 361 | unsigned char cx; |
362 | 362 | ||
363 | if (len < 1) | ||
364 | return -EIO; | ||
365 | |||
366 | mpart = mtd->priv; | 363 | mpart = mtd->priv; |
367 | mdev = mpart->mdev; | 364 | mdev = mpart->mdev; |
368 | partition = mpart->partition; | 365 | partition = mpart->partition; |
@@ -434,11 +431,6 @@ static int vmu_flash_write(struct mtd_info *mtd, loff_t to, size_t len, | |||
434 | partition = mpart->partition; | 431 | partition = mpart->partition; |
435 | card = maple_get_drvdata(mdev); | 432 | card = maple_get_drvdata(mdev); |
436 | 433 | ||
437 | /* simple sanity checks */ | ||
438 | if (len < 1) { | ||
439 | error = -EIO; | ||
440 | goto failed; | ||
441 | } | ||
442 | numblocks = card->parts[partition].numblocks; | 434 | numblocks = card->parts[partition].numblocks; |
443 | if (to + len > numblocks * card->blocklen) | 435 | if (to + len > numblocks * card->blocklen) |
444 | len = numblocks * card->blocklen - to; | 436 | len = numblocks * card->blocklen - to; |
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c index b20346e9fecb..6acc4fb254e2 100644 --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c | |||
@@ -695,6 +695,11 @@ int mtd_erase(struct mtd_info *mtd, struct erase_info *instr) | |||
695 | return -EINVAL; | 695 | return -EINVAL; |
696 | if (!(mtd->flags & MTD_WRITEABLE)) | 696 | if (!(mtd->flags & MTD_WRITEABLE)) |
697 | return -EROFS; | 697 | return -EROFS; |
698 | if (!instr->len) { | ||
699 | instr->state = MTD_ERASE_DONE; | ||
700 | mtd_erase_callback(instr); | ||
701 | return 0; | ||
702 | } | ||
698 | return mtd->_erase(mtd, instr); | 703 | return mtd->_erase(mtd, instr); |
699 | } | 704 | } |
700 | EXPORT_SYMBOL_GPL(mtd_erase); | 705 | EXPORT_SYMBOL_GPL(mtd_erase); |
@@ -713,6 +718,8 @@ int mtd_point(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, | |||
713 | return -EOPNOTSUPP; | 718 | return -EOPNOTSUPP; |
714 | if (from < 0 || from > mtd->size || len > mtd->size - from) | 719 | if (from < 0 || from > mtd->size || len > mtd->size - from) |
715 | return -EINVAL; | 720 | return -EINVAL; |
721 | if (!len) | ||
722 | return 0; | ||
716 | return mtd->_point(mtd, from, len, retlen, virt, phys); | 723 | return mtd->_point(mtd, from, len, retlen, virt, phys); |
717 | } | 724 | } |
718 | EXPORT_SYMBOL_GPL(mtd_point); | 725 | EXPORT_SYMBOL_GPL(mtd_point); |
@@ -724,6 +731,8 @@ int mtd_unpoint(struct mtd_info *mtd, loff_t from, size_t len) | |||
724 | return -EOPNOTSUPP; | 731 | return -EOPNOTSUPP; |
725 | if (from < 0 || from > mtd->size || len > mtd->size - from) | 732 | if (from < 0 || from > mtd->size || len > mtd->size - from) |
726 | return -EINVAL; | 733 | return -EINVAL; |
734 | if (!len) | ||
735 | return 0; | ||
727 | return mtd->_unpoint(mtd, from, len); | 736 | return mtd->_unpoint(mtd, from, len); |
728 | } | 737 | } |
729 | EXPORT_SYMBOL_GPL(mtd_unpoint); | 738 | EXPORT_SYMBOL_GPL(mtd_unpoint); |
@@ -750,6 +759,8 @@ int mtd_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, | |||
750 | *retlen = 0; | 759 | *retlen = 0; |
751 | if (from < 0 || from > mtd->size || len > mtd->size - from) | 760 | if (from < 0 || from > mtd->size || len > mtd->size - from) |
752 | return -EINVAL; | 761 | return -EINVAL; |
762 | if (!len) | ||
763 | return 0; | ||
753 | return mtd->_read(mtd, from, len, retlen, buf); | 764 | return mtd->_read(mtd, from, len, retlen, buf); |
754 | } | 765 | } |
755 | EXPORT_SYMBOL_GPL(mtd_read); | 766 | EXPORT_SYMBOL_GPL(mtd_read); |
@@ -762,6 +773,8 @@ int mtd_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, | |||
762 | return -EINVAL; | 773 | return -EINVAL; |
763 | if (!mtd->_write || !(mtd->flags & MTD_WRITEABLE)) | 774 | if (!mtd->_write || !(mtd->flags & MTD_WRITEABLE)) |
764 | return -EROFS; | 775 | return -EROFS; |
776 | if (!len) | ||
777 | return 0; | ||
765 | return mtd->_write(mtd, to, len, retlen, buf); | 778 | return mtd->_write(mtd, to, len, retlen, buf); |
766 | } | 779 | } |
767 | EXPORT_SYMBOL_GPL(mtd_write); | 780 | EXPORT_SYMBOL_GPL(mtd_write); |
@@ -783,6 +796,8 @@ int mtd_panic_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, | |||
783 | return -EINVAL; | 796 | return -EINVAL; |
784 | if (!(mtd->flags & MTD_WRITEABLE)) | 797 | if (!(mtd->flags & MTD_WRITEABLE)) |
785 | return -EROFS; | 798 | return -EROFS; |
799 | if (!len) | ||
800 | return 0; | ||
786 | return mtd->_panic_write(mtd, to, len, retlen, buf); | 801 | return mtd->_panic_write(mtd, to, len, retlen, buf); |
787 | } | 802 | } |
788 | EXPORT_SYMBOL_GPL(mtd_panic_write); | 803 | EXPORT_SYMBOL_GPL(mtd_panic_write); |
@@ -794,6 +809,8 @@ int mtd_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len) | |||
794 | return -EOPNOTSUPP; | 809 | return -EOPNOTSUPP; |
795 | if (ofs < 0 || ofs > mtd->size || len > mtd->size - ofs) | 810 | if (ofs < 0 || ofs > mtd->size || len > mtd->size - ofs) |
796 | return -EINVAL; | 811 | return -EINVAL; |
812 | if (!len) | ||
813 | return 0; | ||
797 | return mtd->_lock(mtd, ofs, len); | 814 | return mtd->_lock(mtd, ofs, len); |
798 | } | 815 | } |
799 | EXPORT_SYMBOL_GPL(mtd_lock); | 816 | EXPORT_SYMBOL_GPL(mtd_lock); |
@@ -804,6 +821,8 @@ int mtd_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len) | |||
804 | return -EOPNOTSUPP; | 821 | return -EOPNOTSUPP; |
805 | if (ofs < 0 || ofs > mtd->size || len > mtd->size - ofs) | 822 | if (ofs < 0 || ofs > mtd->size || len > mtd->size - ofs) |
806 | return -EINVAL; | 823 | return -EINVAL; |
824 | if (!len) | ||
825 | return 0; | ||
807 | return mtd->_unlock(mtd, ofs, len); | 826 | return mtd->_unlock(mtd, ofs, len); |
808 | } | 827 | } |
809 | EXPORT_SYMBOL_GPL(mtd_unlock); | 828 | EXPORT_SYMBOL_GPL(mtd_unlock); |
@@ -814,6 +833,8 @@ int mtd_is_locked(struct mtd_info *mtd, loff_t ofs, uint64_t len) | |||
814 | return -EOPNOTSUPP; | 833 | return -EOPNOTSUPP; |
815 | if (ofs < 0 || ofs > mtd->size || len > mtd->size - ofs) | 834 | if (ofs < 0 || ofs > mtd->size || len > mtd->size - ofs) |
816 | return -EINVAL; | 835 | return -EINVAL; |
836 | if (!len) | ||
837 | return 0; | ||
817 | return mtd->_is_locked(mtd, ofs, len); | 838 | return mtd->_is_locked(mtd, ofs, len); |
818 | } | 839 | } |
819 | EXPORT_SYMBOL_GPL(mtd_is_locked); | 840 | EXPORT_SYMBOL_GPL(mtd_is_locked); |
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index dd182c8591a9..5822e3a47ded 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c | |||
@@ -1614,9 +1614,6 @@ static int nand_read(struct mtd_info *mtd, loff_t from, size_t len, | |||
1614 | struct mtd_oob_ops ops; | 1614 | struct mtd_oob_ops ops; |
1615 | int ret; | 1615 | int ret; |
1616 | 1616 | ||
1617 | if (!len) | ||
1618 | return 0; | ||
1619 | |||
1620 | nand_get_device(chip, mtd, FL_READING); | 1617 | nand_get_device(chip, mtd, FL_READING); |
1621 | ops.len = len; | 1618 | ops.len = len; |
1622 | ops.datbuf = buf; | 1619 | ops.datbuf = buf; |
@@ -2313,10 +2310,6 @@ static int panic_nand_write(struct mtd_info *mtd, loff_t to, size_t len, | |||
2313 | struct mtd_oob_ops ops; | 2310 | struct mtd_oob_ops ops; |
2314 | int ret; | 2311 | int ret; |
2315 | 2312 | ||
2316 | /* Do not allow reads past end of device */ | ||
2317 | if (!len) | ||
2318 | return 0; | ||
2319 | |||
2320 | /* Wait for the device to get ready */ | 2313 | /* Wait for the device to get ready */ |
2321 | panic_nand_wait(mtd, chip, 400); | 2314 | panic_nand_wait(mtd, chip, 400); |
2322 | 2315 | ||
@@ -2351,9 +2344,6 @@ static int nand_write(struct mtd_info *mtd, loff_t to, size_t len, | |||
2351 | struct mtd_oob_ops ops; | 2344 | struct mtd_oob_ops ops; |
2352 | int ret; | 2345 | int ret; |
2353 | 2346 | ||
2354 | if (!len) | ||
2355 | return 0; | ||
2356 | |||
2357 | nand_get_device(chip, mtd, FL_WRITING); | 2347 | nand_get_device(chip, mtd, FL_WRITING); |
2358 | ops.len = len; | 2348 | ops.len = len; |
2359 | ops.datbuf = (uint8_t *)buf; | 2349 | ops.datbuf = (uint8_t *)buf; |