[MTD] OneNAND: Subpage write returned incorrect length written
When a write is done, the length written is returned. When a single subpage is written the length returned should be the subpage size, however the page size was being returned. Signed-off-by: Adrian Hunter <ext-adrian.hunter@nokia.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
This commit is contained in:
parent
52e4200a6d
commit
81f38e1123
1 changed files with 10 additions and 12 deletions
|
@ -1051,40 +1051,37 @@ static int onenand_write(struct mtd_info *mtd, loff_t to, size_t len,
|
||||||
}
|
}
|
||||||
|
|
||||||
column = to & (mtd->writesize - 1);
|
column = to & (mtd->writesize - 1);
|
||||||
subpage = column || (len & (mtd->writesize - 1));
|
|
||||||
|
|
||||||
/* Grab the lock and see if the device is available */
|
/* Grab the lock and see if the device is available */
|
||||||
onenand_get_device(mtd, FL_WRITING);
|
onenand_get_device(mtd, FL_WRITING);
|
||||||
|
|
||||||
/* Loop until all data write */
|
/* Loop until all data write */
|
||||||
while (written < len) {
|
while (written < len) {
|
||||||
int bytes = mtd->writesize;
|
int thislen = min_t(int, mtd->writesize - column, len - written);
|
||||||
int thislen = min_t(int, bytes, len - written);
|
|
||||||
u_char *wbuf = (u_char *) buf;
|
u_char *wbuf = (u_char *) buf;
|
||||||
|
|
||||||
cond_resched();
|
cond_resched();
|
||||||
|
|
||||||
this->command(mtd, ONENAND_CMD_BUFFERRAM, to, bytes);
|
this->command(mtd, ONENAND_CMD_BUFFERRAM, to, thislen);
|
||||||
|
|
||||||
/* Partial page write */
|
/* Partial page write */
|
||||||
|
subpage = thislen < mtd->writesize;
|
||||||
if (subpage) {
|
if (subpage) {
|
||||||
bytes = min_t(int, bytes - column, (int) len);
|
|
||||||
memset(this->page_buf, 0xff, mtd->writesize);
|
memset(this->page_buf, 0xff, mtd->writesize);
|
||||||
memcpy(this->page_buf + column, buf, bytes);
|
memcpy(this->page_buf + column, buf, thislen);
|
||||||
wbuf = this->page_buf;
|
wbuf = this->page_buf;
|
||||||
/* Even though partial write, we need page size */
|
|
||||||
thislen = mtd->writesize;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this->write_bufferram(mtd, ONENAND_DATARAM, wbuf, 0, thislen);
|
this->write_bufferram(mtd, ONENAND_DATARAM, wbuf, 0, mtd->writesize);
|
||||||
this->write_bufferram(mtd, ONENAND_SPARERAM, ffchars, 0, mtd->oobsize);
|
this->write_bufferram(mtd, ONENAND_SPARERAM, ffchars, 0, mtd->oobsize);
|
||||||
|
|
||||||
this->command(mtd, ONENAND_CMD_PROG, to, mtd->writesize);
|
this->command(mtd, ONENAND_CMD_PROG, to, mtd->writesize);
|
||||||
|
|
||||||
/* In partial page write we don't update bufferram */
|
|
||||||
onenand_update_bufferram(mtd, to, !subpage);
|
|
||||||
|
|
||||||
ret = this->wait(mtd, FL_WRITING);
|
ret = this->wait(mtd, FL_WRITING);
|
||||||
|
|
||||||
|
/* In partial page write we don't update bufferram */
|
||||||
|
onenand_update_bufferram(mtd, to, !ret && !subpage);
|
||||||
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
DEBUG(MTD_DEBUG_LEVEL0, "onenand_write: write filaed %d\n", ret);
|
DEBUG(MTD_DEBUG_LEVEL0, "onenand_write: write filaed %d\n", ret);
|
||||||
break;
|
break;
|
||||||
|
@ -1098,6 +1095,7 @@ static int onenand_write(struct mtd_info *mtd, loff_t to, size_t len,
|
||||||
}
|
}
|
||||||
|
|
||||||
written += thislen;
|
written += thislen;
|
||||||
|
|
||||||
if (written == len)
|
if (written == len)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue