aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtem Bityutskiy <artem.bityutskiy@linux.intel.com>2012-02-06 05:39:07 -0500
committerDavid Woodhouse <David.Woodhouse@intel.com>2012-03-26 19:29:34 -0400
commit834247ec7e281dee839fe4a04bc1bbf0c7395172 (patch)
treec037c578ba572d9104a2341013acde044a8ca052
parent664addc248d2fed68d013d26ff2fc796d7134259 (diff)
mtd: remove retlen zeroing duplication
The MTD API function now zero the 'retlen' parameter before calling the driver's method — do not do this again in drivers. This removes duplicated '*retlen = 0' assignent from the following methods: 'mtd_point()' 'mtd_read()' 'mtd_write()' 'mtd_writev()' 'mtd_panic_write()' Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
-rw-r--r--drivers/mtd/chips/cfi_cmdset_0001.c5
-rw-r--r--drivers/mtd/chips/cfi_cmdset_0002.c12
-rw-r--r--drivers/mtd/chips/cfi_cmdset_0020.c3
-rw-r--r--drivers/mtd/chips/map_absent.c2
-rw-r--r--drivers/mtd/devices/block2mtd.c5
-rw-r--r--drivers/mtd/devices/doc2000.c4
-rw-r--r--drivers/mtd/devices/doc2001.c1
-rw-r--r--drivers/mtd/devices/doc2001plus.c1
-rw-r--r--drivers/mtd/devices/lart.c2
-rw-r--r--drivers/mtd/devices/m25p80.c7
-rw-r--r--drivers/mtd/devices/mtd_dataflash.c4
-rw-r--r--drivers/mtd/devices/phram.c2
-rw-r--r--drivers/mtd/devices/spear_smi.c10
-rw-r--r--drivers/mtd/devices/sst25l.c3
-rw-r--r--drivers/mtd/lpddr/lpddr_cmds.c3
-rw-r--r--drivers/mtd/mtdconcat.c6
-rw-r--r--drivers/mtd/mtdcore.c1
-rw-r--r--drivers/mtd/onenand/onenand_base.c3
18 files changed, 1 insertions, 73 deletions
diff --git a/drivers/mtd/chips/cfi_cmdset_0001.c b/drivers/mtd/chips/cfi_cmdset_0001.c
index 27008ae8f695..dc66df6ab58a 100644
--- a/drivers/mtd/chips/cfi_cmdset_0001.c
+++ b/drivers/mtd/chips/cfi_cmdset_0001.c
@@ -1334,7 +1334,6 @@ static int cfi_intelext_point(struct mtd_info *mtd, loff_t from, size_t len,
1334 ofs = from - (chipnum << cfi->chipshift); 1334 ofs = from - (chipnum << cfi->chipshift);
1335 1335
1336 *virt = map->virt + cfi->chips[chipnum].start + ofs; 1336 *virt = map->virt + cfi->chips[chipnum].start + ofs;
1337 *retlen = 0;
1338 if (phys) 1337 if (phys)
1339 *phys = map->phys + cfi->chips[chipnum].start + ofs; 1338 *phys = map->phys + cfi->chips[chipnum].start + ofs;
1340 1339
@@ -1460,8 +1459,6 @@ static int cfi_intelext_read (struct mtd_info *mtd, loff_t from, size_t len, siz
1460 chipnum = (from >> cfi->chipshift); 1459 chipnum = (from >> cfi->chipshift);
1461 ofs = from - (chipnum << cfi->chipshift); 1460 ofs = from - (chipnum << cfi->chipshift);
1462 1461
1463 *retlen = 0;
1464
1465 while (len) { 1462 while (len) {
1466 unsigned long thislen; 1463 unsigned long thislen;
1467 1464
@@ -1569,7 +1566,6 @@ static int cfi_intelext_write_words (struct mtd_info *mtd, loff_t to , size_t le
1569 int chipnum; 1566 int chipnum;
1570 unsigned long ofs; 1567 unsigned long ofs;
1571 1568
1572 *retlen = 0;
1573 if (!len) 1569 if (!len)
1574 return 0; 1570 return 0;
1575 1571
@@ -1817,7 +1813,6 @@ static int cfi_intelext_writev (struct mtd_info *mtd, const struct kvec *vecs,
1817 for (i = 0; i < count; i++) 1813 for (i = 0; i < count; i++)
1818 len += vecs[i].iov_len; 1814 len += vecs[i].iov_len;
1819 1815
1820 *retlen = 0;
1821 if (!len) 1816 if (!len)
1822 return 0; 1817 return 0;
1823 1818
diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c
index 27ac0622abe3..a89d899efad4 100644
--- a/drivers/mtd/chips/cfi_cmdset_0002.c
+++ b/drivers/mtd/chips/cfi_cmdset_0002.c
@@ -1017,13 +1017,9 @@ static int cfi_amdstd_read (struct mtd_info *mtd, loff_t from, size_t len, size_
1017 int ret = 0; 1017 int ret = 0;
1018 1018
1019 /* ofs: offset within the first chip that the first read should start */ 1019 /* ofs: offset within the first chip that the first read should start */
1020
1021 chipnum = (from >> cfi->chipshift); 1020 chipnum = (from >> cfi->chipshift);
1022 ofs = from - (chipnum << cfi->chipshift); 1021 ofs = from - (chipnum << cfi->chipshift);
1023 1022
1024
1025 *retlen = 0;
1026
1027 while (len) { 1023 while (len) {
1028 unsigned long thislen; 1024 unsigned long thislen;
1029 1025
@@ -1101,16 +1097,11 @@ static int cfi_amdstd_secsi_read (struct mtd_info *mtd, loff_t from, size_t len,
1101 int chipnum; 1097 int chipnum;
1102 int ret = 0; 1098 int ret = 0;
1103 1099
1104
1105 /* ofs: offset within the first chip that the first read should start */ 1100 /* ofs: offset within the first chip that the first read should start */
1106
1107 /* 8 secsi bytes per chip */ 1101 /* 8 secsi bytes per chip */
1108 chipnum=from>>3; 1102 chipnum=from>>3;
1109 ofs=from & 7; 1103 ofs=from & 7;
1110 1104
1111
1112 *retlen = 0;
1113
1114 while (len) { 1105 while (len) {
1115 unsigned long thislen; 1106 unsigned long thislen;
1116 1107
@@ -1255,7 +1246,6 @@ static int cfi_amdstd_write_words(struct mtd_info *mtd, loff_t to, size_t len,
1255 unsigned long ofs, chipstart; 1246 unsigned long ofs, chipstart;
1256 DECLARE_WAITQUEUE(wait, current); 1247 DECLARE_WAITQUEUE(wait, current);
1257 1248
1258 *retlen = 0;
1259 if (!len) 1249 if (!len)
1260 return 0; 1250 return 0;
1261 1251
@@ -1497,7 +1487,6 @@ static int cfi_amdstd_write_buffers(struct mtd_info *mtd, loff_t to, size_t len,
1497 int chipnum; 1487 int chipnum;
1498 unsigned long ofs; 1488 unsigned long ofs;
1499 1489
1500 *retlen = 0;
1501 if (!len) 1490 if (!len)
1502 return 0; 1491 return 0;
1503 1492
@@ -1708,7 +1697,6 @@ static int cfi_amdstd_panic_write(struct mtd_info *mtd, loff_t to, size_t len,
1708 int ret = 0; 1697 int ret = 0;
1709 int chipnum; 1698 int chipnum;
1710 1699
1711 *retlen = 0;
1712 if (!len) 1700 if (!len)
1713 return 0; 1701 return 0;
1714 1702
diff --git a/drivers/mtd/chips/cfi_cmdset_0020.c b/drivers/mtd/chips/cfi_cmdset_0020.c
index 160402fb65d1..d690b7d6952b 100644
--- a/drivers/mtd/chips/cfi_cmdset_0020.c
+++ b/drivers/mtd/chips/cfi_cmdset_0020.c
@@ -394,8 +394,6 @@ static int cfi_staa_read (struct mtd_info *mtd, loff_t from, size_t len, size_t
394 chipnum = (from >> cfi->chipshift); 394 chipnum = (from >> cfi->chipshift);
395 ofs = from - (chipnum << cfi->chipshift); 395 ofs = from - (chipnum << cfi->chipshift);
396 396
397 *retlen = 0;
398
399 while (len) { 397 while (len) {
400 unsigned long thislen; 398 unsigned long thislen;
401 399
@@ -617,7 +615,6 @@ static int cfi_staa_write_buffers (struct mtd_info *mtd, loff_t to,
617 int chipnum; 615 int chipnum;
618 unsigned long ofs; 616 unsigned long ofs;
619 617
620 *retlen = 0;
621 if (!len) 618 if (!len)
622 return 0; 619 return 0;
623 620
diff --git a/drivers/mtd/chips/map_absent.c b/drivers/mtd/chips/map_absent.c
index 6be2eddfea45..f7a5bca92aef 100644
--- a/drivers/mtd/chips/map_absent.c
+++ b/drivers/mtd/chips/map_absent.c
@@ -70,13 +70,11 @@ static struct mtd_info *map_absent_probe(struct map_info *map)
70 70
71static int map_absent_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf) 71static int map_absent_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf)
72{ 72{
73 *retlen = 0;
74 return -ENODEV; 73 return -ENODEV;
75} 74}
76 75
77static int map_absent_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf) 76static int map_absent_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf)
78{ 77{
79 *retlen = 0;
80 return -ENODEV; 78 return -ENODEV;
81} 79}
82 80
diff --git a/drivers/mtd/devices/block2mtd.c b/drivers/mtd/devices/block2mtd.c
index 4c2f84c2a7c7..ba2d74b01c7e 100644
--- a/drivers/mtd/devices/block2mtd.c
+++ b/drivers/mtd/devices/block2mtd.c
@@ -104,9 +104,6 @@ static int block2mtd_read(struct mtd_info *mtd, loff_t from, size_t len,
104 int offset = from & (PAGE_SIZE-1); 104 int offset = from & (PAGE_SIZE-1);
105 int cpylen; 105 int cpylen;
106 106
107 if (retlen)
108 *retlen = 0;
109
110 while (len) { 107 while (len) {
111 if ((offset + len) > PAGE_SIZE) 108 if ((offset + len) > PAGE_SIZE)
112 cpylen = PAGE_SIZE - offset; // multiple pages 109 cpylen = PAGE_SIZE - offset; // multiple pages
@@ -143,8 +140,6 @@ static int _block2mtd_write(struct block2mtd_dev *dev, const u_char *buf,
143 int offset = to & ~PAGE_MASK; // page offset 140 int offset = to & ~PAGE_MASK; // page offset
144 int cpylen; 141 int cpylen;
145 142
146 if (retlen)
147 *retlen = 0;
148 while (len) { 143 while (len) {
149 if ((offset+len) > PAGE_SIZE) 144 if ((offset+len) > PAGE_SIZE)
150 cpylen = PAGE_SIZE - offset; // multiple pages 145 cpylen = PAGE_SIZE - offset; // multiple pages
diff --git a/drivers/mtd/devices/doc2000.c b/drivers/mtd/devices/doc2000.c
index ee4ee0b8440d..7ad7b054800c 100644
--- a/drivers/mtd/devices/doc2000.c
+++ b/drivers/mtd/devices/doc2000.c
@@ -603,8 +603,6 @@ static int doc_read(struct mtd_info *mtd, loff_t from, size_t len,
603 size_t left = len; 603 size_t left = len;
604 604
605 mutex_lock(&this->lock); 605 mutex_lock(&this->lock);
606
607 *retlen = 0;
608 while (left) { 606 while (left) {
609 len = left; 607 len = left;
610 608
@@ -745,8 +743,6 @@ static int doc_write(struct mtd_info *mtd, loff_t to, size_t len,
745 int status; 743 int status;
746 744
747 mutex_lock(&this->lock); 745 mutex_lock(&this->lock);
748
749 *retlen = 0;
750 while (left) { 746 while (left) {
751 len = left; 747 len = left;
752 748
diff --git a/drivers/mtd/devices/doc2001.c b/drivers/mtd/devices/doc2001.c
index 17844155a685..7bff54e62cd5 100644
--- a/drivers/mtd/devices/doc2001.c
+++ b/drivers/mtd/devices/doc2001.c
@@ -591,7 +591,6 @@ static int doc_write (struct mtd_info *mtd, loff_t to, size_t len,
591 printk("Error programming flash\n"); 591 printk("Error programming flash\n");
592 /* Error in programming 592 /* Error in programming
593 FIXME: implement Bad Block Replacement (in nftl.c ??) */ 593 FIXME: implement Bad Block Replacement (in nftl.c ??) */
594 *retlen = 0;
595 ret = -EIO; 594 ret = -EIO;
596 } 595 }
597 dummy = ReadDOC(docptr, LastDataRead); 596 dummy = ReadDOC(docptr, LastDataRead);
diff --git a/drivers/mtd/devices/doc2001plus.c b/drivers/mtd/devices/doc2001plus.c
index a472bab7ef2b..4a03d869ad03 100644
--- a/drivers/mtd/devices/doc2001plus.c
+++ b/drivers/mtd/devices/doc2001plus.c
@@ -792,7 +792,6 @@ static int doc_write(struct mtd_info *mtd, loff_t to, size_t len,
792 printk("MTD: Error 0x%x programming at 0x%x\n", dummy, (int)to); 792 printk("MTD: Error 0x%x programming at 0x%x\n", dummy, (int)to);
793 /* Error in programming 793 /* Error in programming
794 FIXME: implement Bad Block Replacement (in nftl.c ??) */ 794 FIXME: implement Bad Block Replacement (in nftl.c ??) */
795 *retlen = 0;
796 ret = -EIO; 795 ret = -EIO;
797 } 796 }
798 dummy = ReadDOC(docptr, Mplus_LastDataRead); 797 dummy = ReadDOC(docptr, Mplus_LastDataRead);
diff --git a/drivers/mtd/devices/lart.c b/drivers/mtd/devices/lart.c
index c9ae60112a90..6fb8dba76959 100644
--- a/drivers/mtd/devices/lart.c
+++ b/drivers/mtd/devices/lart.c
@@ -518,8 +518,6 @@ static int flash_write (struct mtd_info *mtd,loff_t to,size_t len,size_t *retlen
518 printk (KERN_DEBUG "%s(to = 0x%.8x, len = %d)\n", __func__, (__u32)to, len); 518 printk (KERN_DEBUG "%s(to = 0x%.8x, len = %d)\n", __func__, (__u32)to, len);
519#endif 519#endif
520 520
521 *retlen = 0;
522
523 /* sanity checks */ 521 /* sanity checks */
524 if (!len) return (0); 522 if (!len) return (0);
525 523
diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index 0955a8f4fd25..45cc4a1ae5b0 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -365,9 +365,6 @@ static int m25p80_read(struct mtd_info *mtd, loff_t from, size_t len,
365 t[1].len = len; 365 t[1].len = len;
366 spi_message_add_tail(&t[1], &m); 366 spi_message_add_tail(&t[1], &m);
367 367
368 /* Byte count starts at zero. */
369 *retlen = 0;
370
371 mutex_lock(&flash->lock); 368 mutex_lock(&flash->lock);
372 369
373 /* Wait till previous write/erase is done. */ 370 /* Wait till previous write/erase is done. */
@@ -411,8 +408,6 @@ static int m25p80_write(struct mtd_info *mtd, loff_t to, size_t len,
411 pr_debug("%s: %s to 0x%08x, len %zd\n", dev_name(&flash->spi->dev), 408 pr_debug("%s: %s to 0x%08x, len %zd\n", dev_name(&flash->spi->dev),
412 __func__, (u32)to, len); 409 __func__, (u32)to, len);
413 410
414 *retlen = 0;
415
416 /* sanity checks */ 411 /* sanity checks */
417 if (!len) 412 if (!len)
418 return(0); 413 return(0);
@@ -500,8 +495,6 @@ static int sst_write(struct mtd_info *mtd, loff_t to, size_t len,
500 pr_debug("%s: %s to 0x%08x, len %zd\n", dev_name(&flash->spi->dev), 495 pr_debug("%s: %s to 0x%08x, len %zd\n", dev_name(&flash->spi->dev),
501 __func__, (u32)to, len); 496 __func__, (u32)to, len);
502 497
503 *retlen = 0;
504
505 /* sanity checks */ 498 /* sanity checks */
506 if (!len) 499 if (!len)
507 return 0; 500 return 0;
diff --git a/drivers/mtd/devices/mtd_dataflash.c b/drivers/mtd/devices/mtd_dataflash.c
index fc5c78171844..c76b4464e8b9 100644
--- a/drivers/mtd/devices/mtd_dataflash.c
+++ b/drivers/mtd/devices/mtd_dataflash.c
@@ -249,8 +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 *retlen = 0;
253
254 /* Sanity checks */ 252 /* Sanity checks */
255 if (!len) 253 if (!len)
256 return 0; 254 return 0;
@@ -323,8 +321,6 @@ static int dataflash_write(struct mtd_info *mtd, loff_t to, size_t len,
323 pr_debug("%s: write 0x%x..0x%x\n", 321 pr_debug("%s: write 0x%x..0x%x\n",
324 dev_name(&spi->dev), (unsigned)to, (unsigned)(to + len)); 322 dev_name(&spi->dev), (unsigned)to, (unsigned)(to + len));
325 323
326 *retlen = 0;
327
328 /* Sanity checks */ 324 /* Sanity checks */
329 if (!len) 325 if (!len)
330 return 0; 326 return 0;
diff --git a/drivers/mtd/devices/phram.c b/drivers/mtd/devices/phram.c
index d0e8dc69fe1c..d3474a48d097 100644
--- a/drivers/mtd/devices/phram.c
+++ b/drivers/mtd/devices/phram.c
@@ -85,8 +85,6 @@ static int phram_write(struct mtd_info *mtd, loff_t to, size_t len,
85 return 0; 85 return 0;
86} 86}
87 87
88
89
90static void unregister_devices(void) 88static void unregister_devices(void)
91{ 89{
92 struct phram_mtd_list *this, *safe; 90 struct phram_mtd_list *this, *safe;
diff --git a/drivers/mtd/devices/spear_smi.c b/drivers/mtd/devices/spear_smi.c
index 2238ab916a06..2cdbcc65b39f 100644
--- a/drivers/mtd/devices/spear_smi.c
+++ b/drivers/mtd/devices/spear_smi.c
@@ -574,11 +574,6 @@ static int spear_mtd_read(struct mtd_info *mtd, loff_t from, size_t len,
574 return -EINVAL; 574 return -EINVAL;
575 } 575 }
576 576
577 if (!retlen)
578 return -EINVAL;
579 else
580 *retlen = 0;
581
582 /* select address as per bank number */ 577 /* select address as per bank number */
583 src = flash->base_addr + from; 578 src = flash->base_addr + from;
584 579
@@ -675,11 +670,6 @@ static int spear_mtd_write(struct mtd_info *mtd, loff_t to, size_t len,
675 return -EINVAL; 670 return -EINVAL;
676 } 671 }
677 672
678 if (!retlen)
679 return -EINVAL;
680 else
681 *retlen = 0;
682
683 /* select address as per bank number */ 673 /* select address as per bank number */
684 dest = flash->base_addr + to; 674 dest = flash->base_addr + to;
685 mutex_lock(&flash->lock); 675 mutex_lock(&flash->lock);
diff --git a/drivers/mtd/devices/sst25l.c b/drivers/mtd/devices/sst25l.c
index 99d4a3c510d7..5c2613c99e4a 100644
--- a/drivers/mtd/devices/sst25l.c
+++ b/drivers/mtd/devices/sst25l.c
@@ -224,9 +224,6 @@ static int sst25l_read(struct mtd_info *mtd, loff_t from, size_t len,
224 if (len == 0) 224 if (len == 0)
225 return 0; 225 return 0;
226 226
227 if (retlen)
228 *retlen = 0;
229
230 spi_message_init(&message); 227 spi_message_init(&message);
231 memset(&transfer, 0, sizeof(transfer)); 228 memset(&transfer, 0, sizeof(transfer));
232 229
diff --git a/drivers/mtd/lpddr/lpddr_cmds.c b/drivers/mtd/lpddr/lpddr_cmds.c
index 0f3731c6b3f6..a92906ba535d 100644
--- a/drivers/mtd/lpddr/lpddr_cmds.c
+++ b/drivers/mtd/lpddr/lpddr_cmds.c
@@ -535,9 +535,7 @@ static int lpddr_point(struct mtd_info *mtd, loff_t adr, size_t len,
535 535
536 /* ofs: offset within the first chip that the first read should start */ 536 /* ofs: offset within the first chip that the first read should start */
537 ofs = adr - (chipnum << lpddr->chipshift); 537 ofs = adr - (chipnum << lpddr->chipshift);
538
539 *mtdbuf = (void *)map->virt + chip->start + ofs; 538 *mtdbuf = (void *)map->virt + chip->start + ofs;
540 *retlen = 0;
541 539
542 while (len) { 540 while (len) {
543 unsigned long thislen; 541 unsigned long thislen;
@@ -647,7 +645,6 @@ static int lpddr_writev(struct mtd_info *mtd, const struct kvec *vecs,
647 for (i = 0; i < count; i++) 645 for (i = 0; i < count; i++)
648 len += vecs[i].iov_len; 646 len += vecs[i].iov_len;
649 647
650 *retlen = 0;
651 if (!len) 648 if (!len)
652 return 0; 649 return 0;
653 650
diff --git a/drivers/mtd/mtdconcat.c b/drivers/mtd/mtdconcat.c
index dd24232265e6..f7a31cc44480 100644
--- a/drivers/mtd/mtdconcat.c
+++ b/drivers/mtd/mtdconcat.c
@@ -72,8 +72,6 @@ concat_read(struct mtd_info *mtd, loff_t from, size_t len,
72 int ret = 0, err; 72 int ret = 0, err;
73 int i; 73 int i;
74 74
75 *retlen = 0;
76
77 for (i = 0; i < concat->num_subdev; i++) { 75 for (i = 0; i < concat->num_subdev; i++) {
78 struct mtd_info *subdev = concat->subdev[i]; 76 struct mtd_info *subdev = concat->subdev[i];
79 size_t size, retsize; 77 size_t size, retsize;
@@ -126,8 +124,6 @@ concat_write(struct mtd_info *mtd, loff_t to, size_t len,
126 int err = -EINVAL; 124 int err = -EINVAL;
127 int i; 125 int i;
128 126
129 *retlen = 0;
130
131 for (i = 0; i < concat->num_subdev; i++) { 127 for (i = 0; i < concat->num_subdev; i++) {
132 struct mtd_info *subdev = concat->subdev[i]; 128 struct mtd_info *subdev = concat->subdev[i];
133 size_t size, retsize; 129 size_t size, retsize;
@@ -169,8 +165,6 @@ concat_writev(struct mtd_info *mtd, const struct kvec *vecs,
169 int i; 165 int i;
170 int err = -EINVAL; 166 int err = -EINVAL;
171 167
172 *retlen = 0;
173
174 /* Calculate total length of data */ 168 /* Calculate total length of data */
175 for (i = 0; i < count; i++) 169 for (i = 0; i < count; i++)
176 total_len += vecs[i].iov_len; 170 total_len += vecs[i].iov_len;
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index b9b28647adef..ead52b388492 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -744,6 +744,7 @@ EXPORT_SYMBOL_GPL(mtd_get_unmapped_area);
744int mtd_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, 744int mtd_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen,
745 u_char *buf) 745 u_char *buf)
746{ 746{
747 *retlen = 0;
747 if (from < 0 || from > mtd->size || len > mtd->size - from) 748 if (from < 0 || from > mtd->size || len > mtd->size - from)
748 return -EINVAL; 749 return -EINVAL;
749 return mtd->_read(mtd, from, len, retlen, buf); 750 return mtd->_read(mtd, from, len, retlen, buf);
diff --git a/drivers/mtd/onenand/onenand_base.c b/drivers/mtd/onenand/onenand_base.c
index 9c6445d372ce..a1592cf755f3 100644
--- a/drivers/mtd/onenand/onenand_base.c
+++ b/drivers/mtd/onenand/onenand_base.c
@@ -1753,9 +1753,6 @@ static int onenand_panic_write(struct mtd_info *mtd, loff_t to, size_t len,
1753 pr_debug("%s: to = 0x%08x, len = %i\n", __func__, (unsigned int)to, 1753 pr_debug("%s: to = 0x%08x, len = %i\n", __func__, (unsigned int)to,
1754 (int)len); 1754 (int)len);
1755 1755
1756 /* Initialize retlen, in case of early exit */
1757 *retlen = 0;
1758
1759 /* Reject writes, which are not page aligned */ 1756 /* Reject writes, which are not page aligned */
1760 if (unlikely(NOTALIGNED(to) || NOTALIGNED(len))) { 1757 if (unlikely(NOTALIGNED(to) || NOTALIGNED(len))) {
1761 printk(KERN_ERR "%s: Attempt to write not page aligned data\n", 1758 printk(KERN_ERR "%s: Attempt to write not page aligned data\n",