aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd
diff options
context:
space:
mode:
authorArtem Bityutskiy <artem.bityutskiy@linux.intel.com>2011-12-23 10:35:41 -0500
committerDavid Woodhouse <David.Woodhouse@intel.com>2012-01-09 13:25:20 -0500
commiteda95cbf75193808f62948fb0142ba0901d8bee2 (patch)
tree047bcfa05bc118b1d34327b3e62fa1d10d4bcb43 /drivers/mtd
parent329ad399a9b3adf52c90637b21ca029fcf7f8795 (diff)
mtd: introduce mtd_write interface
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers/mtd')
-rw-r--r--drivers/mtd/chips/cfi_cmdset_0020.c8
-rw-r--r--drivers/mtd/ftl.c35
-rw-r--r--drivers/mtd/mtdblock.c4
-rw-r--r--drivers/mtd/mtdblock_ro.c2
-rw-r--r--drivers/mtd/mtdchar.c2
-rw-r--r--drivers/mtd/mtdconcat.c2
-rw-r--r--drivers/mtd/mtdcore.c3
-rw-r--r--drivers/mtd/mtdoops.c4
-rw-r--r--drivers/mtd/mtdpart.c3
-rw-r--r--drivers/mtd/mtdswap.c2
-rw-r--r--drivers/mtd/rfd_ftl.c17
-rw-r--r--drivers/mtd/tests/mtd_pagetest.c8
-rw-r--r--drivers/mtd/tests/mtd_speedtest.c8
-rw-r--r--drivers/mtd/tests/mtd_stresstest.c2
-rw-r--r--drivers/mtd/tests/mtd_subpagetest.c6
-rw-r--r--drivers/mtd/tests/mtd_torturetest.c2
-rw-r--r--drivers/mtd/ubi/io.c7
17 files changed, 58 insertions, 57 deletions
diff --git a/drivers/mtd/chips/cfi_cmdset_0020.c b/drivers/mtd/chips/cfi_cmdset_0020.c
index 666c52f8bf8d..85e80180b65b 100644
--- a/drivers/mtd/chips/cfi_cmdset_0020.c
+++ b/drivers/mtd/chips/cfi_cmdset_0020.c
@@ -699,7 +699,8 @@ cfi_staa_writev(struct mtd_info *mtd, const struct kvec *vecs,
699 continue; 699 continue;
700 } 700 }
701 memcpy(buffer+buflen, elem_base, ECCBUF_SIZE-buflen); 701 memcpy(buffer+buflen, elem_base, ECCBUF_SIZE-buflen);
702 ret = mtd->write(mtd, to, ECCBUF_SIZE, &thislen, buffer); 702 ret = mtd_write(mtd, to, ECCBUF_SIZE, &thislen,
703 buffer);
703 totlen += thislen; 704 totlen += thislen;
704 if (ret || thislen != ECCBUF_SIZE) 705 if (ret || thislen != ECCBUF_SIZE)
705 goto write_error; 706 goto write_error;
@@ -708,7 +709,8 @@ cfi_staa_writev(struct mtd_info *mtd, const struct kvec *vecs,
708 to += ECCBUF_SIZE; 709 to += ECCBUF_SIZE;
709 } 710 }
710 if (ECCBUF_DIV(elem_len)) { /* write clean aligned data */ 711 if (ECCBUF_DIV(elem_len)) { /* write clean aligned data */
711 ret = mtd->write(mtd, to, ECCBUF_DIV(elem_len), &thislen, elem_base); 712 ret = mtd_write(mtd, to, ECCBUF_DIV(elem_len),
713 &thislen, elem_base);
712 totlen += thislen; 714 totlen += thislen;
713 if (ret || thislen != ECCBUF_DIV(elem_len)) 715 if (ret || thislen != ECCBUF_DIV(elem_len))
714 goto write_error; 716 goto write_error;
@@ -722,7 +724,7 @@ cfi_staa_writev(struct mtd_info *mtd, const struct kvec *vecs,
722 } 724 }
723 if (buflen) { /* flush last page, even if not full */ 725 if (buflen) { /* flush last page, even if not full */
724 /* This is sometimes intended behaviour, really */ 726 /* This is sometimes intended behaviour, really */
725 ret = mtd->write(mtd, to, buflen, &thislen, buffer); 727 ret = mtd_write(mtd, to, buflen, &thislen, buffer);
726 totlen += thislen; 728 totlen += thislen;
727 if (ret || thislen != ECCBUF_SIZE) 729 if (ret || thislen != ECCBUF_SIZE)
728 goto write_error; 730 goto write_error;
diff --git a/drivers/mtd/ftl.c b/drivers/mtd/ftl.c
index 12fd7ebd3fd8..d591b1d0a6c1 100644
--- a/drivers/mtd/ftl.c
+++ b/drivers/mtd/ftl.c
@@ -422,8 +422,8 @@ static int prepare_xfer(partition_t *part, int i)
422 header.LogicalEUN = cpu_to_le16(0xffff); 422 header.LogicalEUN = cpu_to_le16(0xffff);
423 header.EraseCount = cpu_to_le32(xfer->EraseCount); 423 header.EraseCount = cpu_to_le32(xfer->EraseCount);
424 424
425 ret = part->mbd.mtd->write(part->mbd.mtd, xfer->Offset, sizeof(header), 425 ret = mtd_write(part->mbd.mtd, xfer->Offset, sizeof(header), &retlen,
426 &retlen, (u_char *)&header); 426 (u_char *)&header);
427 427
428 if (ret) { 428 if (ret) {
429 return ret; 429 return ret;
@@ -438,8 +438,8 @@ static int prepare_xfer(partition_t *part, int i)
438 438
439 for (i = 0; i < nbam; i++, offset += sizeof(uint32_t)) { 439 for (i = 0; i < nbam; i++, offset += sizeof(uint32_t)) {
440 440
441 ret = part->mbd.mtd->write(part->mbd.mtd, offset, sizeof(uint32_t), 441 ret = mtd_write(part->mbd.mtd, offset, sizeof(uint32_t), &retlen,
442 &retlen, (u_char *)&ctl); 442 (u_char *)&ctl);
443 443
444 if (ret) 444 if (ret)
445 return ret; 445 return ret;
@@ -503,8 +503,8 @@ static int copy_erase_unit(partition_t *part, uint16_t srcunit,
503 offset = xfer->Offset + 20; /* Bad! */ 503 offset = xfer->Offset + 20; /* Bad! */
504 unit = cpu_to_le16(0x7fff); 504 unit = cpu_to_le16(0x7fff);
505 505
506 ret = part->mbd.mtd->write(part->mbd.mtd, offset, sizeof(uint16_t), 506 ret = mtd_write(part->mbd.mtd, offset, sizeof(uint16_t), &retlen,
507 &retlen, (u_char *) &unit); 507 (u_char *)&unit);
508 508
509 if (ret) { 509 if (ret) {
510 printk( KERN_WARNING "ftl: Failed to write back to BAM cache in copy_erase_unit()!\n"); 510 printk( KERN_WARNING "ftl: Failed to write back to BAM cache in copy_erase_unit()!\n");
@@ -531,8 +531,8 @@ static int copy_erase_unit(partition_t *part, uint16_t srcunit,
531 } 531 }
532 532
533 533
534 ret = part->mbd.mtd->write(part->mbd.mtd, dest, SECTOR_SIZE, 534 ret = mtd_write(part->mbd.mtd, dest, SECTOR_SIZE, &retlen,
535 &retlen, (u_char *) buf); 535 (u_char *)buf);
536 if (ret) { 536 if (ret) {
537 printk(KERN_WARNING "ftl: Error writing new xfer unit in copy_erase_unit\n"); 537 printk(KERN_WARNING "ftl: Error writing new xfer unit in copy_erase_unit\n");
538 return ret; 538 return ret;
@@ -550,9 +550,11 @@ static int copy_erase_unit(partition_t *part, uint16_t srcunit,
550 } 550 }
551 551
552 /* Write the BAM to the transfer unit */ 552 /* Write the BAM to the transfer unit */
553 ret = part->mbd.mtd->write(part->mbd.mtd, xfer->Offset + le32_to_cpu(part->header.BAMOffset), 553 ret = mtd_write(part->mbd.mtd,
554 part->BlocksPerUnit * sizeof(int32_t), &retlen, 554 xfer->Offset + le32_to_cpu(part->header.BAMOffset),
555 (u_char *)part->bam_cache); 555 part->BlocksPerUnit * sizeof(int32_t),
556 &retlen,
557 (u_char *)part->bam_cache);
556 if (ret) { 558 if (ret) {
557 printk( KERN_WARNING "ftl: Error writing BAM in copy_erase_unit\n"); 559 printk( KERN_WARNING "ftl: Error writing BAM in copy_erase_unit\n");
558 return ret; 560 return ret;
@@ -560,8 +562,8 @@ static int copy_erase_unit(partition_t *part, uint16_t srcunit,
560 562
561 563
562 /* All clear? Then update the LogicalEUN again */ 564 /* All clear? Then update the LogicalEUN again */
563 ret = part->mbd.mtd->write(part->mbd.mtd, xfer->Offset + 20, sizeof(uint16_t), 565 ret = mtd_write(part->mbd.mtd, xfer->Offset + 20, sizeof(uint16_t),
564 &retlen, (u_char *)&srcunitswap); 566 &retlen, (u_char *)&srcunitswap);
565 567
566 if (ret) { 568 if (ret) {
567 printk(KERN_WARNING "ftl: Error writing new LogicalEUN in copy_erase_unit\n"); 569 printk(KERN_WARNING "ftl: Error writing new LogicalEUN in copy_erase_unit\n");
@@ -887,8 +889,8 @@ static int set_bam_entry(partition_t *part, uint32_t log_addr,
887#endif 889#endif
888 part->bam_cache[blk] = le_virt_addr; 890 part->bam_cache[blk] = le_virt_addr;
889 } 891 }
890 ret = part->mbd.mtd->write(part->mbd.mtd, offset, sizeof(uint32_t), 892 ret = mtd_write(part->mbd.mtd, offset, sizeof(uint32_t), &retlen,
891 &retlen, (u_char *)&le_virt_addr); 893 (u_char *)&le_virt_addr);
892 894
893 if (ret) { 895 if (ret) {
894 printk(KERN_NOTICE "ftl_cs: set_bam_entry() failed!\n"); 896 printk(KERN_NOTICE "ftl_cs: set_bam_entry() failed!\n");
@@ -947,8 +949,7 @@ static int ftl_write(partition_t *part, caddr_t buffer,
947 part->EUNInfo[part->bam_index].Deleted++; 949 part->EUNInfo[part->bam_index].Deleted++;
948 offset = (part->EUNInfo[part->bam_index].Offset + 950 offset = (part->EUNInfo[part->bam_index].Offset +
949 blk * SECTOR_SIZE); 951 blk * SECTOR_SIZE);
950 ret = part->mbd.mtd->write(part->mbd.mtd, offset, SECTOR_SIZE, &retlen, 952 ret = mtd_write(part->mbd.mtd, offset, SECTOR_SIZE, &retlen, buffer);
951 buffer);
952 953
953 if (ret) { 954 if (ret) {
954 printk(KERN_NOTICE "ftl_cs: block write failed!\n"); 955 printk(KERN_NOTICE "ftl_cs: block write failed!\n");
diff --git a/drivers/mtd/mtdblock.c b/drivers/mtd/mtdblock.c
index b0644d2d2a6e..ac7f1f1faa2d 100644
--- a/drivers/mtd/mtdblock.c
+++ b/drivers/mtd/mtdblock.c
@@ -102,7 +102,7 @@ static int erase_write (struct mtd_info *mtd, unsigned long pos,
102 * Next, write the data to flash. 102 * Next, write the data to flash.
103 */ 103 */
104 104
105 ret = mtd->write(mtd, pos, len, &retlen, buf); 105 ret = mtd_write(mtd, pos, len, &retlen, buf);
106 if (ret) 106 if (ret)
107 return ret; 107 return ret;
108 if (retlen != len) 108 if (retlen != len)
@@ -152,7 +152,7 @@ static int do_cached_write (struct mtdblk_dev *mtdblk, unsigned long pos,
152 mtd->name, pos, len); 152 mtd->name, pos, len);
153 153
154 if (!sect_size) 154 if (!sect_size)
155 return mtd->write(mtd, pos, len, &retlen, buf); 155 return mtd_write(mtd, pos, len, &retlen, buf);
156 156
157 while (len > 0) { 157 while (len > 0) {
158 unsigned long sect_start = (pos/sect_size)*sect_size; 158 unsigned long sect_start = (pos/sect_size)*sect_size;
diff --git a/drivers/mtd/mtdblock_ro.c b/drivers/mtd/mtdblock_ro.c
index f5737b1153fa..92759a9d2985 100644
--- a/drivers/mtd/mtdblock_ro.c
+++ b/drivers/mtd/mtdblock_ro.c
@@ -40,7 +40,7 @@ static int mtdblock_writesect(struct mtd_blktrans_dev *dev,
40{ 40{
41 size_t retlen; 41 size_t retlen;
42 42
43 if (dev->mtd->write(dev->mtd, (block * 512), 512, &retlen, buf)) 43 if (mtd_write(dev->mtd, (block * 512), 512, &retlen, buf))
44 return 1; 44 return 1;
45 return 0; 45 return 0;
46} 46}
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
index c7f484687fa3..922da31d2c6b 100644
--- a/drivers/mtd/mtdchar.c
+++ b/drivers/mtd/mtdchar.c
@@ -331,7 +331,7 @@ static ssize_t mtdchar_write(struct file *file, const char __user *buf, size_t c
331 } 331 }
332 332
333 default: 333 default:
334 ret = (*(mtd->write))(mtd, *ppos, len, &retlen, kbuf); 334 ret = mtd_write(mtd, *ppos, len, &retlen, kbuf);
335 } 335 }
336 if (!ret) { 336 if (!ret) {
337 *ppos += retlen; 337 *ppos += retlen;
diff --git a/drivers/mtd/mtdconcat.c b/drivers/mtd/mtdconcat.c
index 45460349fd12..45215501c4c7 100644
--- a/drivers/mtd/mtdconcat.c
+++ b/drivers/mtd/mtdconcat.c
@@ -148,7 +148,7 @@ concat_write(struct mtd_info *mtd, loff_t to, size_t len,
148 if (!(subdev->flags & MTD_WRITEABLE)) 148 if (!(subdev->flags & MTD_WRITEABLE))
149 err = -EROFS; 149 err = -EROFS;
150 else 150 else
151 err = subdev->write(subdev, to, size, &retsize, buf); 151 err = mtd_write(subdev, to, size, &retsize, buf);
152 152
153 if (err) 153 if (err)
154 break; 154 break;
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index b01993ea260e..e36191ab47c3 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -699,7 +699,8 @@ int default_mtd_writev(struct mtd_info *mtd, const struct kvec *vecs,
699 for (i=0; i<count; i++) { 699 for (i=0; i<count; i++) {
700 if (!vecs[i].iov_len) 700 if (!vecs[i].iov_len)
701 continue; 701 continue;
702 ret = mtd->write(mtd, to, vecs[i].iov_len, &thislen, vecs[i].iov_base); 702 ret = mtd_write(mtd, to, vecs[i].iov_len, &thislen,
703 vecs[i].iov_base);
703 totlen += thislen; 704 totlen += thislen;
704 if (ret || thislen != vecs[i].iov_len) 705 if (ret || thislen != vecs[i].iov_len)
705 break; 706 break;
diff --git a/drivers/mtd/mtdoops.c b/drivers/mtd/mtdoops.c
index 23629ad08507..9c9d58617c98 100644
--- a/drivers/mtd/mtdoops.c
+++ b/drivers/mtd/mtdoops.c
@@ -225,8 +225,8 @@ static void mtdoops_write(struct mtdoops_context *cxt, int panic)
225 ret = mtd->panic_write(mtd, cxt->nextpage * record_size, 225 ret = mtd->panic_write(mtd, cxt->nextpage * record_size,
226 record_size, &retlen, cxt->oops_buf); 226 record_size, &retlen, cxt->oops_buf);
227 else 227 else
228 ret = mtd->write(mtd, cxt->nextpage * record_size, 228 ret = mtd_write(mtd, cxt->nextpage * record_size,
229 record_size, &retlen, cxt->oops_buf); 229 record_size, &retlen, cxt->oops_buf);
230 230
231 if (retlen != record_size || ret < 0) 231 if (retlen != record_size || ret < 0)
232 printk(KERN_ERR "mtdoops: write failure at %ld (%td of %ld written), error %d\n", 232 printk(KERN_ERR "mtdoops: write failure at %ld (%td of %ld written), error %d\n",
diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
index 59cd7974bc50..96574a036567 100644
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
@@ -188,8 +188,7 @@ static int part_write(struct mtd_info *mtd, loff_t to, size_t len,
188 len = 0; 188 len = 0;
189 else if (to + len > mtd->size) 189 else if (to + len > mtd->size)
190 len = mtd->size - to; 190 len = mtd->size - to;
191 return part->master->write(part->master, to + part->offset, 191 return mtd_write(part->master, to + part->offset, len, retlen, buf);
192 len, retlen, buf);
193} 192}
194 193
195static int part_panic_write(struct mtd_info *mtd, loff_t to, size_t len, 194static int part_panic_write(struct mtd_info *mtd, loff_t to, size_t len,
diff --git a/drivers/mtd/mtdswap.c b/drivers/mtd/mtdswap.c
index b3282d2aa8f8..6ff823e29c0c 100644
--- a/drivers/mtd/mtdswap.c
+++ b/drivers/mtd/mtdswap.c
@@ -689,7 +689,7 @@ retry:
689 return ret; 689 return ret;
690 690
691 writepos = (loff_t)*bp << PAGE_SHIFT; 691 writepos = (loff_t)*bp << PAGE_SHIFT;
692 ret = mtd->write(mtd, writepos, PAGE_SIZE, &retlen, buf); 692 ret = mtd_write(mtd, writepos, PAGE_SIZE, &retlen, buf);
693 if (ret == -EIO || mtd_is_eccerr(ret)) { 693 if (ret == -EIO || mtd_is_eccerr(ret)) {
694 d->curr_write_pos--; 694 d->curr_write_pos--;
695 eb->active_count--; 695 eb->active_count--;
diff --git a/drivers/mtd/rfd_ftl.c b/drivers/mtd/rfd_ftl.c
index d9fe2d0533d9..c594bb7abfa3 100644
--- a/drivers/mtd/rfd_ftl.c
+++ b/drivers/mtd/rfd_ftl.c
@@ -304,9 +304,8 @@ static void erase_callback(struct erase_info *erase)
304 part->blocks[i].used_sectors = 0; 304 part->blocks[i].used_sectors = 0;
305 part->blocks[i].erases++; 305 part->blocks[i].erases++;
306 306
307 rc = part->mbd.mtd->write(part->mbd.mtd, 307 rc = mtd_write(part->mbd.mtd, part->blocks[i].offset, sizeof(magic),
308 part->blocks[i].offset, sizeof(magic), &retlen, 308 &retlen, (u_char *)&magic);
309 (u_char*)&magic);
310 309
311 if (!rc && retlen != sizeof(magic)) 310 if (!rc && retlen != sizeof(magic))
312 rc = -EIO; 311 rc = -EIO;
@@ -595,8 +594,8 @@ static int mark_sector_deleted(struct partition *part, u_long old_addr)
595 594
596 addr = part->blocks[block].offset + 595 addr = part->blocks[block].offset +
597 (HEADER_MAP_OFFSET + offset) * sizeof(u16); 596 (HEADER_MAP_OFFSET + offset) * sizeof(u16);
598 rc = part->mbd.mtd->write(part->mbd.mtd, addr, 597 rc = mtd_write(part->mbd.mtd, addr, sizeof(del), &retlen,
599 sizeof(del), &retlen, (u_char*)&del); 598 (u_char *)&del);
600 599
601 if (!rc && retlen != sizeof(del)) 600 if (!rc && retlen != sizeof(del))
602 rc = -EIO; 601 rc = -EIO;
@@ -668,8 +667,8 @@ static int do_writesect(struct mtd_blktrans_dev *dev, u_long sector, char *buf,
668 667
669 addr = (i + part->header_sectors_per_block) * SECTOR_SIZE + 668 addr = (i + part->header_sectors_per_block) * SECTOR_SIZE +
670 block->offset; 669 block->offset;
671 rc = part->mbd.mtd->write(part->mbd.mtd, 670 rc = mtd_write(part->mbd.mtd, addr, SECTOR_SIZE, &retlen,
672 addr, SECTOR_SIZE, &retlen, (u_char*)buf); 671 (u_char *)buf);
673 672
674 if (!rc && retlen != SECTOR_SIZE) 673 if (!rc && retlen != SECTOR_SIZE)
675 rc = -EIO; 674 rc = -EIO;
@@ -688,8 +687,8 @@ static int do_writesect(struct mtd_blktrans_dev *dev, u_long sector, char *buf,
688 part->header_cache[i + HEADER_MAP_OFFSET] = entry; 687 part->header_cache[i + HEADER_MAP_OFFSET] = entry;
689 688
690 addr = block->offset + (HEADER_MAP_OFFSET + i) * sizeof(u16); 689 addr = block->offset + (HEADER_MAP_OFFSET + i) * sizeof(u16);
691 rc = part->mbd.mtd->write(part->mbd.mtd, addr, 690 rc = mtd_write(part->mbd.mtd, addr, sizeof(entry), &retlen,
692 sizeof(entry), &retlen, (u_char*)&entry); 691 (u_char *)&entry);
693 692
694 if (!rc && retlen != sizeof(entry)) 693 if (!rc && retlen != sizeof(entry))
695 rc = -EIO; 694 rc = -EIO;
diff --git a/drivers/mtd/tests/mtd_pagetest.c b/drivers/mtd/tests/mtd_pagetest.c
index 6d62e24a03ed..83da97e54f97 100644
--- a/drivers/mtd/tests/mtd_pagetest.c
+++ b/drivers/mtd/tests/mtd_pagetest.c
@@ -100,7 +100,7 @@ static int write_eraseblock(int ebnum)
100 100
101 set_random_data(writebuf, mtd->erasesize); 101 set_random_data(writebuf, mtd->erasesize);
102 cond_resched(); 102 cond_resched();
103 err = mtd->write(mtd, addr, mtd->erasesize, &written, writebuf); 103 err = mtd_write(mtd, addr, mtd->erasesize, &written, writebuf);
104 if (err || written != mtd->erasesize) 104 if (err || written != mtd->erasesize)
105 printk(PRINT_PREF "error: write failed at %#llx\n", 105 printk(PRINT_PREF "error: write failed at %#llx\n",
106 (long long)addr); 106 (long long)addr);
@@ -335,7 +335,7 @@ static int erasecrosstest(void)
335 printk(PRINT_PREF "writing 1st page of block %d\n", ebnum); 335 printk(PRINT_PREF "writing 1st page of block %d\n", ebnum);
336 set_random_data(writebuf, pgsize); 336 set_random_data(writebuf, pgsize);
337 strcpy(writebuf, "There is no data like this!"); 337 strcpy(writebuf, "There is no data like this!");
338 err = mtd->write(mtd, addr0, pgsize, &written, writebuf); 338 err = mtd_write(mtd, addr0, pgsize, &written, writebuf);
339 if (err || written != pgsize) { 339 if (err || written != pgsize) {
340 printk(PRINT_PREF "error: write failed at %#llx\n", 340 printk(PRINT_PREF "error: write failed at %#llx\n",
341 (long long)addr0); 341 (long long)addr0);
@@ -368,7 +368,7 @@ static int erasecrosstest(void)
368 printk(PRINT_PREF "writing 1st page of block %d\n", ebnum); 368 printk(PRINT_PREF "writing 1st page of block %d\n", ebnum);
369 set_random_data(writebuf, pgsize); 369 set_random_data(writebuf, pgsize);
370 strcpy(writebuf, "There is no data like this!"); 370 strcpy(writebuf, "There is no data like this!");
371 err = mtd->write(mtd, addr0, pgsize, &written, writebuf); 371 err = mtd_write(mtd, addr0, pgsize, &written, writebuf);
372 if (err || written != pgsize) { 372 if (err || written != pgsize) {
373 printk(PRINT_PREF "error: write failed at %#llx\n", 373 printk(PRINT_PREF "error: write failed at %#llx\n",
374 (long long)addr0); 374 (long long)addr0);
@@ -425,7 +425,7 @@ static int erasetest(void)
425 425
426 printk(PRINT_PREF "writing 1st page of block %d\n", ebnum); 426 printk(PRINT_PREF "writing 1st page of block %d\n", ebnum);
427 set_random_data(writebuf, pgsize); 427 set_random_data(writebuf, pgsize);
428 err = mtd->write(mtd, addr0, pgsize, &written, writebuf); 428 err = mtd_write(mtd, addr0, pgsize, &written, writebuf);
429 if (err || written != pgsize) { 429 if (err || written != pgsize) {
430 printk(PRINT_PREF "error: write failed at %#llx\n", 430 printk(PRINT_PREF "error: write failed at %#llx\n",
431 (long long)addr0); 431 (long long)addr0);
diff --git a/drivers/mtd/tests/mtd_speedtest.c b/drivers/mtd/tests/mtd_speedtest.c
index 3c9529bd0a62..c7b18e189082 100644
--- a/drivers/mtd/tests/mtd_speedtest.c
+++ b/drivers/mtd/tests/mtd_speedtest.c
@@ -143,7 +143,7 @@ static int write_eraseblock(int ebnum)
143 int err = 0; 143 int err = 0;
144 loff_t addr = ebnum * mtd->erasesize; 144 loff_t addr = ebnum * mtd->erasesize;
145 145
146 err = mtd->write(mtd, addr, mtd->erasesize, &written, iobuf); 146 err = mtd_write(mtd, addr, mtd->erasesize, &written, iobuf);
147 if (err || written != mtd->erasesize) { 147 if (err || written != mtd->erasesize) {
148 printk(PRINT_PREF "error: write failed at %#llx\n", addr); 148 printk(PRINT_PREF "error: write failed at %#llx\n", addr);
149 if (!err) 149 if (!err)
@@ -161,7 +161,7 @@ static int write_eraseblock_by_page(int ebnum)
161 void *buf = iobuf; 161 void *buf = iobuf;
162 162
163 for (i = 0; i < pgcnt; i++) { 163 for (i = 0; i < pgcnt; i++) {
164 err = mtd->write(mtd, addr, pgsize, &written, buf); 164 err = mtd_write(mtd, addr, pgsize, &written, buf);
165 if (err || written != pgsize) { 165 if (err || written != pgsize) {
166 printk(PRINT_PREF "error: write failed at %#llx\n", 166 printk(PRINT_PREF "error: write failed at %#llx\n",
167 addr); 167 addr);
@@ -184,7 +184,7 @@ static int write_eraseblock_by_2pages(int ebnum)
184 void *buf = iobuf; 184 void *buf = iobuf;
185 185
186 for (i = 0; i < n; i++) { 186 for (i = 0; i < n; i++) {
187 err = mtd->write(mtd, addr, sz, &written, buf); 187 err = mtd_write(mtd, addr, sz, &written, buf);
188 if (err || written != sz) { 188 if (err || written != sz) {
189 printk(PRINT_PREF "error: write failed at %#llx\n", 189 printk(PRINT_PREF "error: write failed at %#llx\n",
190 addr); 190 addr);
@@ -196,7 +196,7 @@ static int write_eraseblock_by_2pages(int ebnum)
196 buf += sz; 196 buf += sz;
197 } 197 }
198 if (pgcnt % 2) { 198 if (pgcnt % 2) {
199 err = mtd->write(mtd, addr, pgsize, &written, buf); 199 err = mtd_write(mtd, addr, pgsize, &written, buf);
200 if (err || written != pgsize) { 200 if (err || written != pgsize) {
201 printk(PRINT_PREF "error: write failed at %#llx\n", 201 printk(PRINT_PREF "error: write failed at %#llx\n",
202 addr); 202 addr);
diff --git a/drivers/mtd/tests/mtd_stresstest.c b/drivers/mtd/tests/mtd_stresstest.c
index 83a843723880..f8aac4b7e59a 100644
--- a/drivers/mtd/tests/mtd_stresstest.c
+++ b/drivers/mtd/tests/mtd_stresstest.c
@@ -192,7 +192,7 @@ static int do_write(void)
192 } 192 }
193 } 193 }
194 addr = eb * mtd->erasesize + offs; 194 addr = eb * mtd->erasesize + offs;
195 err = mtd->write(mtd, addr, len, &written, writebuf); 195 err = mtd_write(mtd, addr, len, &written, writebuf);
196 if (unlikely(err || written != len)) { 196 if (unlikely(err || written != len)) {
197 printk(PRINT_PREF "error: write failed at 0x%llx\n", 197 printk(PRINT_PREF "error: write failed at 0x%llx\n",
198 (long long)addr); 198 (long long)addr);
diff --git a/drivers/mtd/tests/mtd_subpagetest.c b/drivers/mtd/tests/mtd_subpagetest.c
index d81f89a19daa..b90c01036b49 100644
--- a/drivers/mtd/tests/mtd_subpagetest.c
+++ b/drivers/mtd/tests/mtd_subpagetest.c
@@ -120,7 +120,7 @@ static int write_eraseblock(int ebnum)
120 loff_t addr = ebnum * mtd->erasesize; 120 loff_t addr = ebnum * mtd->erasesize;
121 121
122 set_random_data(writebuf, subpgsize); 122 set_random_data(writebuf, subpgsize);
123 err = mtd->write(mtd, addr, subpgsize, &written, writebuf); 123 err = mtd_write(mtd, addr, subpgsize, &written, writebuf);
124 if (unlikely(err || written != subpgsize)) { 124 if (unlikely(err || written != subpgsize)) {
125 printk(PRINT_PREF "error: write failed at %#llx\n", 125 printk(PRINT_PREF "error: write failed at %#llx\n",
126 (long long)addr); 126 (long long)addr);
@@ -134,7 +134,7 @@ static int write_eraseblock(int ebnum)
134 addr += subpgsize; 134 addr += subpgsize;
135 135
136 set_random_data(writebuf, subpgsize); 136 set_random_data(writebuf, subpgsize);
137 err = mtd->write(mtd, addr, subpgsize, &written, writebuf); 137 err = mtd_write(mtd, addr, subpgsize, &written, writebuf);
138 if (unlikely(err || written != subpgsize)) { 138 if (unlikely(err || written != subpgsize)) {
139 printk(PRINT_PREF "error: write failed at %#llx\n", 139 printk(PRINT_PREF "error: write failed at %#llx\n",
140 (long long)addr); 140 (long long)addr);
@@ -158,7 +158,7 @@ static int write_eraseblock2(int ebnum)
158 if (addr + (subpgsize * k) > (ebnum + 1) * mtd->erasesize) 158 if (addr + (subpgsize * k) > (ebnum + 1) * mtd->erasesize)
159 break; 159 break;
160 set_random_data(writebuf, subpgsize * k); 160 set_random_data(writebuf, subpgsize * k);
161 err = mtd->write(mtd, addr, subpgsize * k, &written, writebuf); 161 err = mtd_write(mtd, addr, subpgsize * k, &written, writebuf);
162 if (unlikely(err || written != subpgsize * k)) { 162 if (unlikely(err || written != subpgsize * k)) {
163 printk(PRINT_PREF "error: write failed at %#llx\n", 163 printk(PRINT_PREF "error: write failed at %#llx\n",
164 (long long)addr); 164 (long long)addr);
diff --git a/drivers/mtd/tests/mtd_torturetest.c b/drivers/mtd/tests/mtd_torturetest.c
index ecc68bf3f3f2..dd34a519fa7a 100644
--- a/drivers/mtd/tests/mtd_torturetest.c
+++ b/drivers/mtd/tests/mtd_torturetest.c
@@ -189,7 +189,7 @@ static inline int write_pattern(int ebnum, void *buf)
189 addr = (ebnum + 1) * mtd->erasesize - pgcnt * pgsize; 189 addr = (ebnum + 1) * mtd->erasesize - pgcnt * pgsize;
190 len = pgcnt * pgsize; 190 len = pgcnt * pgsize;
191 } 191 }
192 err = mtd->write(mtd, addr, len, &written, buf); 192 err = mtd_write(mtd, addr, len, &written, buf);
193 if (err) { 193 if (err) {
194 printk(PRINT_PREF "error %d while writing EB %d, written %zd" 194 printk(PRINT_PREF "error %d while writing EB %d, written %zd"
195 " bytes\n", err, ebnum, written); 195 " bytes\n", err, ebnum, written);
diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c
index 433382951d3d..8d832fc9e9e4 100644
--- a/drivers/mtd/ubi/io.c
+++ b/drivers/mtd/ubi/io.c
@@ -289,7 +289,7 @@ int ubi_io_write(struct ubi_device *ubi, const void *buf, int pnum, int offset,
289 } 289 }
290 290
291 addr = (loff_t)pnum * ubi->peb_size + offset; 291 addr = (loff_t)pnum * ubi->peb_size + offset;
292 err = ubi->mtd->write(ubi->mtd, addr, len, &written, buf); 292 err = mtd_write(ubi->mtd, addr, len, &written, buf);
293 if (err) { 293 if (err) {
294 ubi_err("error %d while writing %d bytes to PEB %d:%d, written " 294 ubi_err("error %d while writing %d bytes to PEB %d:%d, written "
295 "%zd bytes", err, len, pnum, offset, written); 295 "%zd bytes", err, len, pnum, offset, written);
@@ -525,11 +525,10 @@ static int nor_erase_prepare(struct ubi_device *ubi, int pnum)
525 * the header comment in scan.c for more information). 525 * the header comment in scan.c for more information).
526 */ 526 */
527 addr = (loff_t)pnum * ubi->peb_size; 527 addr = (loff_t)pnum * ubi->peb_size;
528 err = ubi->mtd->write(ubi->mtd, addr, 4, &written, (void *)&data); 528 err = mtd_write(ubi->mtd, addr, 4, &written, (void *)&data);
529 if (!err) { 529 if (!err) {
530 addr += ubi->vid_hdr_aloffset; 530 addr += ubi->vid_hdr_aloffset;
531 err = ubi->mtd->write(ubi->mtd, addr, 4, &written, 531 err = mtd_write(ubi->mtd, addr, 4, &written, (void *)&data);
532 (void *)&data);
533 if (!err) 532 if (!err)
534 return 0; 533 return 0;
535 } 534 }