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