Commit eda95cbf authored by Artem Bityutskiy's avatar Artem Bityutskiy Committed by David Woodhouse

mtd: introduce mtd_write interface

Signed-off-by: default avatarArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: default avatarDavid Woodhouse <David.Woodhouse@intel.com>
parent 329ad399
...@@ -699,7 +699,8 @@ cfi_staa_writev(struct mtd_info *mtd, const struct kvec *vecs, ...@@ -699,7 +699,8 @@ cfi_staa_writev(struct mtd_info *mtd, const struct kvec *vecs,
continue; continue;
} }
memcpy(buffer+buflen, elem_base, ECCBUF_SIZE-buflen); memcpy(buffer+buflen, elem_base, ECCBUF_SIZE-buflen);
ret = mtd->write(mtd, to, ECCBUF_SIZE, &thislen, buffer); ret = mtd_write(mtd, to, ECCBUF_SIZE, &thislen,
buffer);
totlen += thislen; totlen += thislen;
if (ret || thislen != ECCBUF_SIZE) if (ret || thislen != ECCBUF_SIZE)
goto write_error; goto write_error;
...@@ -708,7 +709,8 @@ cfi_staa_writev(struct mtd_info *mtd, const struct kvec *vecs, ...@@ -708,7 +709,8 @@ cfi_staa_writev(struct mtd_info *mtd, const struct kvec *vecs,
to += ECCBUF_SIZE; to += ECCBUF_SIZE;
} }
if (ECCBUF_DIV(elem_len)) { /* write clean aligned data */ if (ECCBUF_DIV(elem_len)) { /* write clean aligned data */
ret = mtd->write(mtd, to, ECCBUF_DIV(elem_len), &thislen, elem_base); ret = mtd_write(mtd, to, ECCBUF_DIV(elem_len),
&thislen, elem_base);
totlen += thislen; totlen += thislen;
if (ret || thislen != ECCBUF_DIV(elem_len)) if (ret || thislen != ECCBUF_DIV(elem_len))
goto write_error; goto write_error;
...@@ -722,7 +724,7 @@ cfi_staa_writev(struct mtd_info *mtd, const struct kvec *vecs, ...@@ -722,7 +724,7 @@ cfi_staa_writev(struct mtd_info *mtd, const struct kvec *vecs,
} }
if (buflen) { /* flush last page, even if not full */ if (buflen) { /* flush last page, even if not full */
/* This is sometimes intended behaviour, really */ /* This is sometimes intended behaviour, really */
ret = mtd->write(mtd, to, buflen, &thislen, buffer); ret = mtd_write(mtd, to, buflen, &thislen, buffer);
totlen += thislen; totlen += thislen;
if (ret || thislen != ECCBUF_SIZE) if (ret || thislen != ECCBUF_SIZE)
goto write_error; goto write_error;
......
...@@ -422,8 +422,8 @@ static int prepare_xfer(partition_t *part, int i) ...@@ -422,8 +422,8 @@ static int prepare_xfer(partition_t *part, int i)
header.LogicalEUN = cpu_to_le16(0xffff); header.LogicalEUN = cpu_to_le16(0xffff);
header.EraseCount = cpu_to_le32(xfer->EraseCount); header.EraseCount = cpu_to_le32(xfer->EraseCount);
ret = part->mbd.mtd->write(part->mbd.mtd, xfer->Offset, sizeof(header), ret = mtd_write(part->mbd.mtd, xfer->Offset, sizeof(header), &retlen,
&retlen, (u_char *)&header); (u_char *)&header);
if (ret) { if (ret) {
return ret; return ret;
...@@ -438,8 +438,8 @@ static int prepare_xfer(partition_t *part, int i) ...@@ -438,8 +438,8 @@ static int prepare_xfer(partition_t *part, int i)
for (i = 0; i < nbam; i++, offset += sizeof(uint32_t)) { for (i = 0; i < nbam; i++, offset += sizeof(uint32_t)) {
ret = part->mbd.mtd->write(part->mbd.mtd, offset, sizeof(uint32_t), ret = mtd_write(part->mbd.mtd, offset, sizeof(uint32_t), &retlen,
&retlen, (u_char *)&ctl); (u_char *)&ctl);
if (ret) if (ret)
return ret; return ret;
...@@ -503,8 +503,8 @@ static int copy_erase_unit(partition_t *part, uint16_t srcunit, ...@@ -503,8 +503,8 @@ static int copy_erase_unit(partition_t *part, uint16_t srcunit,
offset = xfer->Offset + 20; /* Bad! */ offset = xfer->Offset + 20; /* Bad! */
unit = cpu_to_le16(0x7fff); unit = cpu_to_le16(0x7fff);
ret = part->mbd.mtd->write(part->mbd.mtd, offset, sizeof(uint16_t), ret = mtd_write(part->mbd.mtd, offset, sizeof(uint16_t), &retlen,
&retlen, (u_char *) &unit); (u_char *)&unit);
if (ret) { if (ret) {
printk( KERN_WARNING "ftl: Failed to write back to BAM cache in copy_erase_unit()!\n"); 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,8 +531,8 @@ static int copy_erase_unit(partition_t *part, uint16_t srcunit,
} }
ret = part->mbd.mtd->write(part->mbd.mtd, dest, SECTOR_SIZE, ret = mtd_write(part->mbd.mtd, dest, SECTOR_SIZE, &retlen,
&retlen, (u_char *) buf); (u_char *)buf);
if (ret) { if (ret) {
printk(KERN_WARNING "ftl: Error writing new xfer unit in copy_erase_unit\n"); printk(KERN_WARNING "ftl: Error writing new xfer unit in copy_erase_unit\n");
return ret; return ret;
...@@ -550,9 +550,11 @@ static int copy_erase_unit(partition_t *part, uint16_t srcunit, ...@@ -550,9 +550,11 @@ static int copy_erase_unit(partition_t *part, uint16_t srcunit,
} }
/* Write the BAM to the transfer unit */ /* Write the BAM to the transfer unit */
ret = part->mbd.mtd->write(part->mbd.mtd, xfer->Offset + le32_to_cpu(part->header.BAMOffset), ret = mtd_write(part->mbd.mtd,
part->BlocksPerUnit * sizeof(int32_t), &retlen, xfer->Offset + le32_to_cpu(part->header.BAMOffset),
(u_char *)part->bam_cache); part->BlocksPerUnit * sizeof(int32_t),
&retlen,
(u_char *)part->bam_cache);
if (ret) { if (ret) {
printk( KERN_WARNING "ftl: Error writing BAM in copy_erase_unit\n"); printk( KERN_WARNING "ftl: Error writing BAM in copy_erase_unit\n");
return ret; return ret;
...@@ -560,8 +562,8 @@ static int copy_erase_unit(partition_t *part, uint16_t srcunit, ...@@ -560,8 +562,8 @@ static int copy_erase_unit(partition_t *part, uint16_t srcunit,
/* All clear? Then update the LogicalEUN again */ /* All clear? Then update the LogicalEUN again */
ret = part->mbd.mtd->write(part->mbd.mtd, xfer->Offset + 20, sizeof(uint16_t), ret = mtd_write(part->mbd.mtd, xfer->Offset + 20, sizeof(uint16_t),
&retlen, (u_char *)&srcunitswap); &retlen, (u_char *)&srcunitswap);
if (ret) { if (ret) {
printk(KERN_WARNING "ftl: Error writing new LogicalEUN in copy_erase_unit\n"); 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,8 +889,8 @@ static int set_bam_entry(partition_t *part, uint32_t log_addr,
#endif #endif
part->bam_cache[blk] = le_virt_addr; part->bam_cache[blk] = le_virt_addr;
} }
ret = part->mbd.mtd->write(part->mbd.mtd, offset, sizeof(uint32_t), ret = mtd_write(part->mbd.mtd, offset, sizeof(uint32_t), &retlen,
&retlen, (u_char *)&le_virt_addr); (u_char *)&le_virt_addr);
if (ret) { if (ret) {
printk(KERN_NOTICE "ftl_cs: set_bam_entry() failed!\n"); 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,8 +949,7 @@ static int ftl_write(partition_t *part, caddr_t buffer,
part->EUNInfo[part->bam_index].Deleted++; part->EUNInfo[part->bam_index].Deleted++;
offset = (part->EUNInfo[part->bam_index].Offset + offset = (part->EUNInfo[part->bam_index].Offset +
blk * SECTOR_SIZE); blk * SECTOR_SIZE);
ret = part->mbd.mtd->write(part->mbd.mtd, offset, SECTOR_SIZE, &retlen, ret = mtd_write(part->mbd.mtd, offset, SECTOR_SIZE, &retlen, buffer);
buffer);
if (ret) { if (ret) {
printk(KERN_NOTICE "ftl_cs: block write failed!\n"); printk(KERN_NOTICE "ftl_cs: block write failed!\n");
......
...@@ -102,7 +102,7 @@ static int erase_write (struct mtd_info *mtd, unsigned long pos, ...@@ -102,7 +102,7 @@ static int erase_write (struct mtd_info *mtd, unsigned long pos,
* Next, write the data to flash. * Next, write the data to flash.
*/ */
ret = mtd->write(mtd, pos, len, &retlen, buf); ret = mtd_write(mtd, pos, len, &retlen, buf);
if (ret) if (ret)
return ret; return ret;
if (retlen != len) if (retlen != len)
...@@ -152,7 +152,7 @@ static int do_cached_write (struct mtdblk_dev *mtdblk, unsigned long pos, ...@@ -152,7 +152,7 @@ static int do_cached_write (struct mtdblk_dev *mtdblk, unsigned long pos,
mtd->name, pos, len); mtd->name, pos, len);
if (!sect_size) if (!sect_size)
return mtd->write(mtd, pos, len, &retlen, buf); return mtd_write(mtd, pos, len, &retlen, buf);
while (len > 0) { while (len > 0) {
unsigned long sect_start = (pos/sect_size)*sect_size; unsigned long sect_start = (pos/sect_size)*sect_size;
......
...@@ -40,7 +40,7 @@ static int mtdblock_writesect(struct mtd_blktrans_dev *dev, ...@@ -40,7 +40,7 @@ static int mtdblock_writesect(struct mtd_blktrans_dev *dev,
{ {
size_t retlen; size_t retlen;
if (dev->mtd->write(dev->mtd, (block * 512), 512, &retlen, buf)) if (mtd_write(dev->mtd, (block * 512), 512, &retlen, buf))
return 1; return 1;
return 0; return 0;
} }
......
...@@ -331,7 +331,7 @@ static ssize_t mtdchar_write(struct file *file, const char __user *buf, size_t c ...@@ -331,7 +331,7 @@ static ssize_t mtdchar_write(struct file *file, const char __user *buf, size_t c
} }
default: default:
ret = (*(mtd->write))(mtd, *ppos, len, &retlen, kbuf); ret = mtd_write(mtd, *ppos, len, &retlen, kbuf);
} }
if (!ret) { if (!ret) {
*ppos += retlen; *ppos += retlen;
......
...@@ -148,7 +148,7 @@ concat_write(struct mtd_info *mtd, loff_t to, size_t len, ...@@ -148,7 +148,7 @@ concat_write(struct mtd_info *mtd, loff_t to, size_t len,
if (!(subdev->flags & MTD_WRITEABLE)) if (!(subdev->flags & MTD_WRITEABLE))
err = -EROFS; err = -EROFS;
else else
err = subdev->write(subdev, to, size, &retsize, buf); err = mtd_write(subdev, to, size, &retsize, buf);
if (err) if (err)
break; break;
......
...@@ -699,7 +699,8 @@ int default_mtd_writev(struct mtd_info *mtd, const struct kvec *vecs, ...@@ -699,7 +699,8 @@ int default_mtd_writev(struct mtd_info *mtd, const struct kvec *vecs,
for (i=0; i<count; i++) { for (i=0; i<count; i++) {
if (!vecs[i].iov_len) if (!vecs[i].iov_len)
continue; continue;
ret = mtd->write(mtd, to, vecs[i].iov_len, &thislen, vecs[i].iov_base); ret = mtd_write(mtd, to, vecs[i].iov_len, &thislen,
vecs[i].iov_base);
totlen += thislen; totlen += thislen;
if (ret || thislen != vecs[i].iov_len) if (ret || thislen != vecs[i].iov_len)
break; break;
......
...@@ -225,8 +225,8 @@ static void mtdoops_write(struct mtdoops_context *cxt, int panic) ...@@ -225,8 +225,8 @@ static void mtdoops_write(struct mtdoops_context *cxt, int panic)
ret = mtd->panic_write(mtd, cxt->nextpage * record_size, ret = mtd->panic_write(mtd, cxt->nextpage * record_size,
record_size, &retlen, cxt->oops_buf); record_size, &retlen, cxt->oops_buf);
else else
ret = mtd->write(mtd, cxt->nextpage * record_size, ret = mtd_write(mtd, cxt->nextpage * record_size,
record_size, &retlen, cxt->oops_buf); record_size, &retlen, cxt->oops_buf);
if (retlen != record_size || ret < 0) if (retlen != record_size || ret < 0)
printk(KERN_ERR "mtdoops: write failure at %ld (%td of %ld written), error %d\n", printk(KERN_ERR "mtdoops: write failure at %ld (%td of %ld written), error %d\n",
......
...@@ -188,8 +188,7 @@ static int part_write(struct mtd_info *mtd, loff_t to, size_t len, ...@@ -188,8 +188,7 @@ static int part_write(struct mtd_info *mtd, loff_t to, size_t len,
len = 0; len = 0;
else if (to + len > mtd->size) else if (to + len > mtd->size)
len = mtd->size - to; len = mtd->size - to;
return part->master->write(part->master, to + part->offset, return mtd_write(part->master, to + part->offset, len, retlen, buf);
len, retlen, buf);
} }
static int part_panic_write(struct mtd_info *mtd, loff_t to, size_t len, static int part_panic_write(struct mtd_info *mtd, loff_t to, size_t len,
......
...@@ -689,7 +689,7 @@ retry: ...@@ -689,7 +689,7 @@ retry:
return ret; return ret;
writepos = (loff_t)*bp << PAGE_SHIFT; writepos = (loff_t)*bp << PAGE_SHIFT;
ret = mtd->write(mtd, writepos, PAGE_SIZE, &retlen, buf); ret = mtd_write(mtd, writepos, PAGE_SIZE, &retlen, buf);
if (ret == -EIO || mtd_is_eccerr(ret)) { if (ret == -EIO || mtd_is_eccerr(ret)) {
d->curr_write_pos--; d->curr_write_pos--;
eb->active_count--; eb->active_count--;
......
...@@ -304,9 +304,8 @@ static void erase_callback(struct erase_info *erase) ...@@ -304,9 +304,8 @@ static void erase_callback(struct erase_info *erase)
part->blocks[i].used_sectors = 0; part->blocks[i].used_sectors = 0;
part->blocks[i].erases++; part->blocks[i].erases++;
rc = part->mbd.mtd->write(part->mbd.mtd, rc = mtd_write(part->mbd.mtd, part->blocks[i].offset, sizeof(magic),
part->blocks[i].offset, sizeof(magic), &retlen, &retlen, (u_char *)&magic);
(u_char*)&magic);
if (!rc && retlen != sizeof(magic)) if (!rc && retlen != sizeof(magic))
rc = -EIO; rc = -EIO;
...@@ -595,8 +594,8 @@ static int mark_sector_deleted(struct partition *part, u_long old_addr) ...@@ -595,8 +594,8 @@ static int mark_sector_deleted(struct partition *part, u_long old_addr)
addr = part->blocks[block].offset + addr = part->blocks[block].offset +
(HEADER_MAP_OFFSET + offset) * sizeof(u16); (HEADER_MAP_OFFSET + offset) * sizeof(u16);
rc = part->mbd.mtd->write(part->mbd.mtd, addr, rc = mtd_write(part->mbd.mtd, addr, sizeof(del), &retlen,
sizeof(del), &retlen, (u_char*)&del); (u_char *)&del);
if (!rc && retlen != sizeof(del)) if (!rc && retlen != sizeof(del))
rc = -EIO; rc = -EIO;
...@@ -668,8 +667,8 @@ static int do_writesect(struct mtd_blktrans_dev *dev, u_long sector, char *buf, ...@@ -668,8 +667,8 @@ static int do_writesect(struct mtd_blktrans_dev *dev, u_long sector, char *buf,
addr = (i + part->header_sectors_per_block) * SECTOR_SIZE + addr = (i + part->header_sectors_per_block) * SECTOR_SIZE +
block->offset; block->offset;
rc = part->mbd.mtd->write(part->mbd.mtd, rc = mtd_write(part->mbd.mtd, addr, SECTOR_SIZE, &retlen,
addr, SECTOR_SIZE, &retlen, (u_char*)buf); (u_char *)buf);
if (!rc && retlen != SECTOR_SIZE) if (!rc && retlen != SECTOR_SIZE)
rc = -EIO; rc = -EIO;
...@@ -688,8 +687,8 @@ static int do_writesect(struct mtd_blktrans_dev *dev, u_long sector, char *buf, ...@@ -688,8 +687,8 @@ static int do_writesect(struct mtd_blktrans_dev *dev, u_long sector, char *buf,
part->header_cache[i + HEADER_MAP_OFFSET] = entry; part->header_cache[i + HEADER_MAP_OFFSET] = entry;
addr = block->offset + (HEADER_MAP_OFFSET + i) * sizeof(u16); addr = block->offset + (HEADER_MAP_OFFSET + i) * sizeof(u16);
rc = part->mbd.mtd->write(part->mbd.mtd, addr, rc = mtd_write(part->mbd.mtd, addr, sizeof(entry), &retlen,
sizeof(entry), &retlen, (u_char*)&entry); (u_char *)&entry);
if (!rc && retlen != sizeof(entry)) if (!rc && retlen != sizeof(entry))
rc = -EIO; rc = -EIO;
......
...@@ -100,7 +100,7 @@ static int write_eraseblock(int ebnum) ...@@ -100,7 +100,7 @@ static int write_eraseblock(int ebnum)
set_random_data(writebuf, mtd->erasesize); set_random_data(writebuf, mtd->erasesize);
cond_resched(); cond_resched();
err = mtd->write(mtd, addr, mtd->erasesize, &written, writebuf); err = mtd_write(mtd, addr, mtd->erasesize, &written, writebuf);
if (err || written != mtd->erasesize) if (err || written != mtd->erasesize)
printk(PRINT_PREF "error: write failed at %#llx\n", printk(PRINT_PREF "error: write failed at %#llx\n",
(long long)addr); (long long)addr);
...@@ -335,7 +335,7 @@ static int erasecrosstest(void) ...@@ -335,7 +335,7 @@ static int erasecrosstest(void)
printk(PRINT_PREF "writing 1st page of block %d\n", ebnum); printk(PRINT_PREF "writing 1st page of block %d\n", ebnum);
set_random_data(writebuf, pgsize); set_random_data(writebuf, pgsize);
strcpy(writebuf, "There is no data like this!"); strcpy(writebuf, "There is no data like this!");
err = mtd->write(mtd, addr0, pgsize, &written, writebuf); err = mtd_write(mtd, addr0, pgsize, &written, writebuf);
if (err || written != pgsize) { if (err || written != pgsize) {
printk(PRINT_PREF "error: write failed at %#llx\n", printk(PRINT_PREF "error: write failed at %#llx\n",
(long long)addr0); (long long)addr0);
...@@ -368,7 +368,7 @@ static int erasecrosstest(void) ...@@ -368,7 +368,7 @@ static int erasecrosstest(void)
printk(PRINT_PREF "writing 1st page of block %d\n", ebnum); printk(PRINT_PREF "writing 1st page of block %d\n", ebnum);
set_random_data(writebuf, pgsize); set_random_data(writebuf, pgsize);
strcpy(writebuf, "There is no data like this!"); strcpy(writebuf, "There is no data like this!");
err = mtd->write(mtd, addr0, pgsize, &written, writebuf); err = mtd_write(mtd, addr0, pgsize, &written, writebuf);
if (err || written != pgsize) { if (err || written != pgsize) {
printk(PRINT_PREF "error: write failed at %#llx\n", printk(PRINT_PREF "error: write failed at %#llx\n",
(long long)addr0); (long long)addr0);
...@@ -425,7 +425,7 @@ static int erasetest(void) ...@@ -425,7 +425,7 @@ static int erasetest(void)
printk(PRINT_PREF "writing 1st page of block %d\n", ebnum); printk(PRINT_PREF "writing 1st page of block %d\n", ebnum);
set_random_data(writebuf, pgsize); set_random_data(writebuf, pgsize);
err = mtd->write(mtd, addr0, pgsize, &written, writebuf); err = mtd_write(mtd, addr0, pgsize, &written, writebuf);
if (err || written != pgsize) { if (err || written != pgsize) {
printk(PRINT_PREF "error: write failed at %#llx\n", printk(PRINT_PREF "error: write failed at %#llx\n",
(long long)addr0); (long long)addr0);
......
...@@ -143,7 +143,7 @@ static int write_eraseblock(int ebnum) ...@@ -143,7 +143,7 @@ static int write_eraseblock(int ebnum)
int err = 0; int err = 0;
loff_t addr = ebnum * mtd->erasesize; loff_t addr = ebnum * mtd->erasesize;
err = mtd->write(mtd, addr, mtd->erasesize, &written, iobuf); err = mtd_write(mtd, addr, mtd->erasesize, &written, iobuf);
if (err || written != mtd->erasesize) { if (err || written != mtd->erasesize) {
printk(PRINT_PREF "error: write failed at %#llx\n", addr); printk(PRINT_PREF "error: write failed at %#llx\n", addr);
if (!err) if (!err)
...@@ -161,7 +161,7 @@ static int write_eraseblock_by_page(int ebnum) ...@@ -161,7 +161,7 @@ static int write_eraseblock_by_page(int ebnum)
void *buf = iobuf; void *buf = iobuf;
for (i = 0; i < pgcnt; i++) { for (i = 0; i < pgcnt; i++) {
err = mtd->write(mtd, addr, pgsize, &written, buf); err = mtd_write(mtd, addr, pgsize, &written, buf);
if (err || written != pgsize) { if (err || written != pgsize) {
printk(PRINT_PREF "error: write failed at %#llx\n", printk(PRINT_PREF "error: write failed at %#llx\n",
addr); addr);
...@@ -184,7 +184,7 @@ static int write_eraseblock_by_2pages(int ebnum) ...@@ -184,7 +184,7 @@ static int write_eraseblock_by_2pages(int ebnum)
void *buf = iobuf; void *buf = iobuf;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
err = mtd->write(mtd, addr, sz, &written, buf); err = mtd_write(mtd, addr, sz, &written, buf);
if (err || written != sz) { if (err || written != sz) {
printk(PRINT_PREF "error: write failed at %#llx\n", printk(PRINT_PREF "error: write failed at %#llx\n",
addr); addr);
...@@ -196,7 +196,7 @@ static int write_eraseblock_by_2pages(int ebnum) ...@@ -196,7 +196,7 @@ static int write_eraseblock_by_2pages(int ebnum)
buf += sz; buf += sz;
} }
if (pgcnt % 2) { if (pgcnt % 2) {
err = mtd->write(mtd, addr, pgsize, &written, buf); err = mtd_write(mtd, addr, pgsize, &written, buf);
if (err || written != pgsize) { if (err || written != pgsize) {
printk(PRINT_PREF "error: write failed at %#llx\n", printk(PRINT_PREF "error: write failed at %#llx\n",
addr); addr);
......
...@@ -192,7 +192,7 @@ static int do_write(void) ...@@ -192,7 +192,7 @@ static int do_write(void)
} }
} }
addr = eb * mtd->erasesize + offs; addr = eb * mtd->erasesize + offs;
err = mtd->write(mtd, addr, len, &written, writebuf); err = mtd_write(mtd, addr, len, &written, writebuf);
if (unlikely(err || written != len)) { if (unlikely(err || written != len)) {
printk(PRINT_PREF "error: write failed at 0x%llx\n", printk(PRINT_PREF "error: write failed at 0x%llx\n",
(long long)addr); (long long)addr);
......
...@@ -120,7 +120,7 @@ static int write_eraseblock(int ebnum) ...@@ -120,7 +120,7 @@ static int write_eraseblock(int ebnum)
loff_t addr = ebnum * mtd->erasesize; loff_t addr = ebnum * mtd->erasesize;
set_random_data(writebuf, subpgsize); set_random_data(writebuf, subpgsize);
err = mtd->write(mtd, addr, subpgsize, &written, writebuf); err = mtd_write(mtd, addr, subpgsize, &written, writebuf);
if (unlikely(err || written != subpgsize)) { if (unlikely(err || written != subpgsize)) {
printk(PRINT_PREF "error: write failed at %#llx\n", printk(PRINT_PREF "error: write failed at %#llx\n",
(long long)addr); (long long)addr);
...@@ -134,7 +134,7 @@ static int write_eraseblock(int ebnum) ...@@ -134,7 +134,7 @@ static int write_eraseblock(int ebnum)
addr += subpgsize; addr += subpgsize;
set_random_data(writebuf, subpgsize); set_random_data(writebuf, subpgsize);
err = mtd->write(mtd, addr, subpgsize, &written, writebuf); err = mtd_write(mtd, addr, subpgsize, &written, writebuf);
if (unlikely(err || written != subpgsize)) { if (unlikely(err || written != subpgsize)) {
printk(PRINT_PREF "error: write failed at %#llx\n", printk(PRINT_PREF "error: write failed at %#llx\n",
(long long)addr); (long long)addr);
...@@ -158,7 +158,7 @@ static int write_eraseblock2(int ebnum) ...@@ -158,7 +158,7 @@ static int write_eraseblock2(int ebnum)
if (addr + (subpgsize * k) > (ebnum + 1) * mtd->erasesize) if (addr + (subpgsize * k) > (ebnum + 1) * mtd->erasesize)
break; break;
set_random_data(writebuf, subpgsize * k); set_random_data(writebuf, subpgsize * k);
err = mtd->write(mtd, addr, subpgsize * k, &written, writebuf); err = mtd_write(mtd, addr, subpgsize * k, &written, writebuf);
if (unlikely(err || written != subpgsize * k)) { if (unlikely(err || written != subpgsize * k)) {
printk(PRINT_PREF "error: write failed at %#llx\n", printk(PRINT_PREF "error: write failed at %#llx\n",
(long long)addr); (long long)addr);
......
...@@ -189,7 +189,7 @@ static inline int write_pattern(int ebnum, void *buf) ...@@ -189,7 +189,7 @@ static inline int write_pattern(int ebnum, void *buf)
addr = (ebnum + 1) * mtd->erasesize - pgcnt * pgsize; addr = (ebnum + 1) * mtd->erasesize - pgcnt * pgsize;
len = pgcnt * pgsize; len = pgcnt * pgsize;
} }
err = mtd->write(mtd, addr, len, &written, buf); err = mtd_write(mtd, addr, len, &written, buf);
if (err) { if (err) {
printk(PRINT_PREF "error %d while writing EB %d, written %zd" printk(PRINT_PREF "error %d while writing EB %d, written %zd"
" bytes\n", err, ebnum, written); " bytes\n", err, ebnum, written);
......
...@@ -289,7 +289,7 @@ int ubi_io_write(struct ubi_device *ubi, const void *buf, int pnum, int offset, ...@@ -289,7 +289,7 @@ int ubi_io_write(struct ubi_device *ubi, const void *buf, int pnum, int offset,
} }
addr = (loff_t)pnum * ubi->peb_size + offset; addr = (loff_t)pnum * ubi->peb_size + offset;
err = ubi->mtd->write(ubi->mtd, addr, len, &written, buf); err = mtd_write(ubi->mtd, addr, len, &written, buf);
if (err) { if (err) {
ubi_err("error %d while writing %d bytes to PEB %d:%d, written " ubi_err("error %d while writing %d bytes to PEB %d:%d, written "
"%zd bytes", err, len, pnum, offset, written); "%zd bytes", err, len, pnum, offset, written);
...@@ -525,11 +525,10 @@ static int nor_erase_prepare(struct ubi_device *ubi, int pnum) ...@@ -525,11 +525,10 @@ static int nor_erase_prepare(struct ubi_device *ubi, int pnum)
* the header comment in scan.c for more information). * the header comment in scan.c for more information).
*/ */
addr = (loff_t)pnum * ubi->peb_size; addr = (loff_t)pnum * ubi->peb_size;
err = ubi->mtd->write(ubi->mtd, addr, 4, &written, (void *)&data); err = mtd_write(ubi->mtd, addr, 4, &written, (void *)&data);
if (!err) { if (!err) {
addr += ubi->vid_hdr_aloffset; addr += ubi->vid_hdr_aloffset;
err = ubi->mtd->write(ubi->mtd, addr, 4, &written, err = mtd_write(ubi->mtd, addr, 4, &written, (void *)&data);
(void *)&data);
if (!err) if (!err)
return 0; return 0;
} }
......
...@@ -233,9 +233,11 @@ u16 mtd_Write_Page_Main(u8 *write_data, u32 Block, ...@@ -233,9 +233,11 @@ u16 mtd_Write_Page_Main(u8 *write_data, u32 Block,