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

[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>

authored by

Adrian Hunter and committed by
Kyungmin Park
81f38e11 52e4200a

+10 -12
+10 -12
drivers/mtd/onenand/onenand_base.c
··· 1051 1051 } 1052 1052 1053 1053 column = to & (mtd->writesize - 1); 1054 - subpage = column || (len & (mtd->writesize - 1)); 1055 1054 1056 1055 /* Grab the lock and see if the device is available */ 1057 1056 onenand_get_device(mtd, FL_WRITING); 1058 1057 1059 1058 /* Loop until all data write */ 1060 1059 while (written < len) { 1061 - int bytes = mtd->writesize; 1062 - int thislen = min_t(int, bytes, len - written); 1060 + int thislen = min_t(int, mtd->writesize - column, len - written); 1063 1061 u_char *wbuf = (u_char *) buf; 1064 1062 1065 1063 cond_resched(); 1066 1064 1067 - this->command(mtd, ONENAND_CMD_BUFFERRAM, to, bytes); 1065 + this->command(mtd, ONENAND_CMD_BUFFERRAM, to, thislen); 1068 1066 1069 1067 /* Partial page write */ 1068 + subpage = thislen < mtd->writesize; 1070 1069 if (subpage) { 1071 - bytes = min_t(int, bytes - column, (int) len); 1072 1070 memset(this->page_buf, 0xff, mtd->writesize); 1073 - memcpy(this->page_buf + column, buf, bytes); 1071 + memcpy(this->page_buf + column, buf, thislen); 1074 1072 wbuf = this->page_buf; 1075 - /* Even though partial write, we need page size */ 1076 - thislen = mtd->writesize; 1077 1073 } 1078 1074 1079 - this->write_bufferram(mtd, ONENAND_DATARAM, wbuf, 0, thislen); 1075 + this->write_bufferram(mtd, ONENAND_DATARAM, wbuf, 0, mtd->writesize); 1080 1076 this->write_bufferram(mtd, ONENAND_SPARERAM, ffchars, 0, mtd->oobsize); 1081 1077 1082 1078 this->command(mtd, ONENAND_CMD_PROG, to, mtd->writesize); 1083 1079 1084 - /* In partial page write we don't update bufferram */ 1085 - onenand_update_bufferram(mtd, to, !subpage); 1086 - 1087 1080 ret = this->wait(mtd, FL_WRITING); 1081 + 1082 + /* In partial page write we don't update bufferram */ 1083 + onenand_update_bufferram(mtd, to, !ret && !subpage); 1084 + 1088 1085 if (ret) { 1089 1086 DEBUG(MTD_DEBUG_LEVEL0, "onenand_write: write filaed %d\n", ret); 1090 1087 break; ··· 1095 1098 } 1096 1099 1097 1100 written += thislen; 1101 + 1098 1102 if (written == len) 1099 1103 break; 1100 1104