Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Artem Bityutskiy and committed by
David Woodhouse
834247ec 664addc2

+1 -73
-5
drivers/mtd/chips/cfi_cmdset_0001.c
··· 1334 1334 ofs = from - (chipnum << cfi->chipshift); 1335 1335 1336 1336 *virt = map->virt + cfi->chips[chipnum].start + ofs; 1337 - *retlen = 0; 1338 1337 if (phys) 1339 1338 *phys = map->phys + cfi->chips[chipnum].start + ofs; 1340 1339 ··· 1459 1460 chipnum = (from >> cfi->chipshift); 1460 1461 ofs = from - (chipnum << cfi->chipshift); 1461 1462 1462 - *retlen = 0; 1463 - 1464 1463 while (len) { 1465 1464 unsigned long thislen; 1466 1465 ··· 1566 1569 int chipnum; 1567 1570 unsigned long ofs; 1568 1571 1569 - *retlen = 0; 1570 1572 if (!len) 1571 1573 return 0; 1572 1574 ··· 1813 1817 for (i = 0; i < count; i++) 1814 1818 len += vecs[i].iov_len; 1815 1819 1816 - *retlen = 0; 1817 1820 if (!len) 1818 1821 return 0; 1819 1822
-12
drivers/mtd/chips/cfi_cmdset_0002.c
··· 1017 1017 int ret = 0; 1018 1018 1019 1019 /* ofs: offset within the first chip that the first read should start */ 1020 - 1021 1020 chipnum = (from >> cfi->chipshift); 1022 1021 ofs = from - (chipnum << cfi->chipshift); 1023 - 1024 - 1025 - *retlen = 0; 1026 1022 1027 1023 while (len) { 1028 1024 unsigned long thislen; ··· 1097 1101 int chipnum; 1098 1102 int ret = 0; 1099 1103 1100 - 1101 1104 /* ofs: offset within the first chip that the first read should start */ 1102 - 1103 1105 /* 8 secsi bytes per chip */ 1104 1106 chipnum=from>>3; 1105 1107 ofs=from & 7; 1106 - 1107 - 1108 - *retlen = 0; 1109 1108 1110 1109 while (len) { 1111 1110 unsigned long thislen; ··· 1246 1255 unsigned long ofs, chipstart; 1247 1256 DECLARE_WAITQUEUE(wait, current); 1248 1257 1249 - *retlen = 0; 1250 1258 if (!len) 1251 1259 return 0; 1252 1260 ··· 1487 1497 int chipnum; 1488 1498 unsigned long ofs; 1489 1499 1490 - *retlen = 0; 1491 1500 if (!len) 1492 1501 return 0; 1493 1502 ··· 1697 1708 int ret = 0; 1698 1709 int chipnum; 1699 1710 1700 - *retlen = 0; 1701 1711 if (!len) 1702 1712 return 0; 1703 1713
-3
drivers/mtd/chips/cfi_cmdset_0020.c
··· 394 394 chipnum = (from >> cfi->chipshift); 395 395 ofs = from - (chipnum << cfi->chipshift); 396 396 397 - *retlen = 0; 398 - 399 397 while (len) { 400 398 unsigned long thislen; 401 399 ··· 615 617 int chipnum; 616 618 unsigned long ofs; 617 619 618 - *retlen = 0; 619 620 if (!len) 620 621 return 0; 621 622
-2
drivers/mtd/chips/map_absent.c
··· 70 70 71 71 static 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 73 return -ENODEV; 75 74 } 76 75 77 76 static 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 78 return -ENODEV; 81 79 } 82 80
-5
drivers/mtd/devices/block2mtd.c
··· 104 104 int offset = from & (PAGE_SIZE-1); 105 105 int cpylen; 106 106 107 - if (retlen) 108 - *retlen = 0; 109 - 110 107 while (len) { 111 108 if ((offset + len) > PAGE_SIZE) 112 109 cpylen = PAGE_SIZE - offset; // multiple pages ··· 140 143 int offset = to & ~PAGE_MASK; // page offset 141 144 int cpylen; 142 145 143 - if (retlen) 144 - *retlen = 0; 145 146 while (len) { 146 147 if ((offset+len) > PAGE_SIZE) 147 148 cpylen = PAGE_SIZE - offset; // multiple pages
-4
drivers/mtd/devices/doc2000.c
··· 603 603 size_t left = len; 604 604 605 605 mutex_lock(&this->lock); 606 - 607 - *retlen = 0; 608 606 while (left) { 609 607 len = left; 610 608 ··· 743 745 int status; 744 746 745 747 mutex_lock(&this->lock); 746 - 747 - *retlen = 0; 748 748 while (left) { 749 749 len = left; 750 750
-1
drivers/mtd/devices/doc2001.c
··· 591 591 printk("Error programming flash\n"); 592 592 /* Error in programming 593 593 FIXME: implement Bad Block Replacement (in nftl.c ??) */ 594 - *retlen = 0; 595 594 ret = -EIO; 596 595 } 597 596 dummy = ReadDOC(docptr, LastDataRead);
-1
drivers/mtd/devices/doc2001plus.c
··· 792 792 printk("MTD: Error 0x%x programming at 0x%x\n", dummy, (int)to); 793 793 /* Error in programming 794 794 FIXME: implement Bad Block Replacement (in nftl.c ??) */ 795 - *retlen = 0; 796 795 ret = -EIO; 797 796 } 798 797 dummy = ReadDOC(docptr, Mplus_LastDataRead);
-2
drivers/mtd/devices/lart.c
··· 518 518 printk (KERN_DEBUG "%s(to = 0x%.8x, len = %d)\n", __func__, (__u32)to, len); 519 519 #endif 520 520 521 - *retlen = 0; 522 - 523 521 /* sanity checks */ 524 522 if (!len) return (0); 525 523
-7
drivers/mtd/devices/m25p80.c
··· 365 365 t[1].len = len; 366 366 spi_message_add_tail(&t[1], &m); 367 367 368 - /* Byte count starts at zero. */ 369 - *retlen = 0; 370 - 371 368 mutex_lock(&flash->lock); 372 369 373 370 /* Wait till previous write/erase is done. */ ··· 407 410 408 411 pr_debug("%s: %s to 0x%08x, len %zd\n", dev_name(&flash->spi->dev), 409 412 __func__, (u32)to, len); 410 - 411 - *retlen = 0; 412 413 413 414 /* sanity checks */ 414 415 if (!len) ··· 494 499 495 500 pr_debug("%s: %s to 0x%08x, len %zd\n", dev_name(&flash->spi->dev), 496 501 __func__, (u32)to, len); 497 - 498 - *retlen = 0; 499 502 500 503 /* sanity checks */ 501 504 if (!len)
-4
drivers/mtd/devices/mtd_dataflash.c
··· 249 249 pr_debug("%s: read 0x%x..0x%x\n", dev_name(&priv->spi->dev), 250 250 (unsigned)from, (unsigned)(from + len)); 251 251 252 - *retlen = 0; 253 - 254 252 /* Sanity checks */ 255 253 if (!len) 256 254 return 0; ··· 320 322 321 323 pr_debug("%s: write 0x%x..0x%x\n", 322 324 dev_name(&spi->dev), (unsigned)to, (unsigned)(to + len)); 323 - 324 - *retlen = 0; 325 325 326 326 /* Sanity checks */ 327 327 if (!len)
-2
drivers/mtd/devices/phram.c
··· 85 85 return 0; 86 86 } 87 87 88 - 89 - 90 88 static void unregister_devices(void) 91 89 { 92 90 struct phram_mtd_list *this, *safe;
-10
drivers/mtd/devices/spear_smi.c
··· 574 574 return -EINVAL; 575 575 } 576 576 577 - if (!retlen) 578 - return -EINVAL; 579 - else 580 - *retlen = 0; 581 - 582 577 /* select address as per bank number */ 583 578 src = flash->base_addr + from; 584 579 ··· 669 674 dev_err(&dev->pdev->dev, "Invalid Bank Num"); 670 675 return -EINVAL; 671 676 } 672 - 673 - if (!retlen) 674 - return -EINVAL; 675 - else 676 - *retlen = 0; 677 677 678 678 /* select address as per bank number */ 679 679 dest = flash->base_addr + to;
-3
drivers/mtd/devices/sst25l.c
··· 224 224 if (len == 0) 225 225 return 0; 226 226 227 - if (retlen) 228 - *retlen = 0; 229 - 230 227 spi_message_init(&message); 231 228 memset(&transfer, 0, sizeof(transfer)); 232 229
-3
drivers/mtd/lpddr/lpddr_cmds.c
··· 535 535 536 536 /* ofs: offset within the first chip that the first read should start */ 537 537 ofs = adr - (chipnum << lpddr->chipshift); 538 - 539 538 *mtdbuf = (void *)map->virt + chip->start + ofs; 540 - *retlen = 0; 541 539 542 540 while (len) { 543 541 unsigned long thislen; ··· 645 647 for (i = 0; i < count; i++) 646 648 len += vecs[i].iov_len; 647 649 648 - *retlen = 0; 649 650 if (!len) 650 651 return 0; 651 652
-6
drivers/mtd/mtdconcat.c
··· 72 72 int ret = 0, err; 73 73 int i; 74 74 75 - *retlen = 0; 76 - 77 75 for (i = 0; i < concat->num_subdev; i++) { 78 76 struct mtd_info *subdev = concat->subdev[i]; 79 77 size_t size, retsize; ··· 124 126 int err = -EINVAL; 125 127 int i; 126 128 127 - *retlen = 0; 128 - 129 129 for (i = 0; i < concat->num_subdev; i++) { 130 130 struct mtd_info *subdev = concat->subdev[i]; 131 131 size_t size, retsize; ··· 164 168 size_t total_len = 0; 165 169 int i; 166 170 int err = -EINVAL; 167 - 168 - *retlen = 0; 169 171 170 172 /* Calculate total length of data */ 171 173 for (i = 0; i < count; i++)
+1
drivers/mtd/mtdcore.c
··· 744 744 int mtd_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, 745 745 u_char *buf) 746 746 { 747 + *retlen = 0; 747 748 if (from < 0 || from > mtd->size || len > mtd->size - from) 748 749 return -EINVAL; 749 750 return mtd->_read(mtd, from, len, retlen, buf);
-3
drivers/mtd/onenand/onenand_base.c
··· 1753 1753 pr_debug("%s: to = 0x%08x, len = %i\n", __func__, (unsigned int)to, 1754 1754 (int)len); 1755 1755 1756 - /* Initialize retlen, in case of early exit */ 1757 - *retlen = 0; 1758 - 1759 1756 /* Reject writes, which are not page aligned */ 1760 1757 if (unlikely(NOTALIGNED(to) || NOTALIGNED(len))) { 1761 1758 printk(KERN_ERR "%s: Attempt to write not page aligned data\n",