[MTD] OneNAND: fix onenand_wait bug

Fix onenand_wait error reporting

Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>

authored by Kyungmin Park and committed by Artem Bityutskiy f6272487 85de3d9b

+17 -24
+15 -23
drivers/mtd/onenand/onenand_base.c
··· 318 318 ctrl = this->read_word(this->base + ONENAND_REG_CTRL_STATUS); 319 319 320 320 if (ctrl & ONENAND_CTRL_ERROR) { 321 - /* It maybe occur at initial bad block */ 322 321 DEBUG(MTD_DEBUG_LEVEL0, "onenand_wait: controller error = 0x%04x\n", ctrl); 323 - /* Clear other interrupt bits for preventing ECC error */ 324 - interrupt &= ONENAND_INT_MASTER; 325 - } 326 - 327 - if (ctrl & ONENAND_CTRL_LOCK) { 328 - DEBUG(MTD_DEBUG_LEVEL0, "onenand_wait: it's locked error = 0x%04x\n", ctrl); 329 - return -EACCES; 322 + if (ctrl & ONENAND_CTRL_LOCK) 323 + DEBUG(MTD_DEBUG_LEVEL0, "onenand_wait: it's locked error.\n"); 324 + return ctrl; 330 325 } 331 326 332 327 if (interrupt & ONENAND_INT_READ) { ··· 745 750 746 751 ret = this->wait(mtd, FL_READING); 747 752 /* First copy data and check return value for ECC handling */ 748 - onenand_update_bufferram(mtd, from, 1); 753 + onenand_update_bufferram(mtd, from, !ret); 749 754 } 750 755 751 756 this->read_bufferram(mtd, ONENAND_DATARAM, buf, column, thislen); 752 - 753 - read += thislen; 754 - 755 - if (read == len) 756 - break; 757 757 758 758 if (ret) { 759 759 DEBUG(MTD_DEBUG_LEVEL0, "onenand_read: read failed = %d\n", ret); 760 760 goto out; 761 761 } 762 + 763 + read += thislen; 764 + 765 + if (read == len) 766 + break; 762 767 763 768 from += thislen; 764 769 buf += thislen; ··· 827 832 828 833 this->read_bufferram(mtd, ONENAND_SPARERAM, buf, column, thislen); 829 834 835 + if (ret) { 836 + DEBUG(MTD_DEBUG_LEVEL0, "onenand_read_oob: read failed = 0x%x\n", ret); 837 + goto out; 838 + } 839 + 830 840 read += thislen; 831 841 832 842 if (read == len) 833 843 break; 834 - 835 - if (ret) { 836 - DEBUG(MTD_DEBUG_LEVEL0, "onenand_read_oob: read failed = %d\n", ret); 837 - goto out; 838 - } 839 844 840 845 buf += thislen; 841 846 ··· 1194 1199 ret = this->wait(mtd, FL_ERASING); 1195 1200 /* Check, if it is write protected */ 1196 1201 if (ret) { 1197 - if (ret == -EPERM) 1198 - DEBUG(MTD_DEBUG_LEVEL0, "onenand_erase: Device is write protected!!!\n"); 1199 - else 1200 - DEBUG(MTD_DEBUG_LEVEL0, "onenand_erase: Failed erase, block %d\n", (unsigned) (addr >> this->erase_shift)); 1202 + DEBUG(MTD_DEBUG_LEVEL0, "onenand_erase: Failed erase, block %d\n", (unsigned) (addr >> this->erase_shift)); 1201 1203 instr->state = MTD_ERASE_FAILED; 1202 1204 instr->fail_addr = addr; 1203 1205 goto erase_exit;
+2 -1
drivers/mtd/onenand/onenand_bbt.c
··· 93 93 ret = onenand_do_read_oob(mtd, from + j * mtd->writesize + bd->offs, 94 94 readlen, &retlen, &buf[0]); 95 95 96 - if (ret) 96 + /* If it is a initial bad block, just ignore it */ 97 + if (ret && !(ret & ONENAND_CTRL_LOAD)) 97 98 return ret; 98 99 99 100 if (check_short_pattern(&buf[j * scanlen], scanlen, mtd->writesize, bd)) {