Merge tag 'mtd/for-6.7' of git://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux
[linux-2.6-microblaze.git] / drivers / mtd / nand / raw / marvell_nand.c
index 2e23e21..a466987 100644 (file)
@@ -1165,6 +1165,7 @@ static int marvell_nfc_hw_ecc_hmg_do_write_page(struct nand_chip *chip,
                .ndcb[2] = NDCB2_ADDR5_PAGE(page),
        };
        unsigned int oob_bytes = lt->spare_bytes + (raw ? lt->ecc_bytes : 0);
+       u8 status;
        int ret;
 
        /* NFCv2 needs more information about the operation being executed */
@@ -1198,7 +1199,18 @@ static int marvell_nfc_hw_ecc_hmg_do_write_page(struct nand_chip *chip,
 
        ret = marvell_nfc_wait_op(chip,
                                  PSEC_TO_MSEC(sdr->tPROG_max));
-       return ret;
+       if (ret)
+               return ret;
+
+       /* Check write status on the chip side */
+       ret = nand_status_op(chip, &status);
+       if (ret)
+               return ret;
+
+       if (status & NAND_STATUS_FAIL)
+               return -EIO;
+
+       return 0;
 }
 
 static int marvell_nfc_hw_ecc_hmg_write_page_raw(struct nand_chip *chip,
@@ -1627,6 +1639,7 @@ static int marvell_nfc_hw_ecc_bch_write_page(struct nand_chip *chip,
        int data_len = lt->data_bytes;
        int spare_len = lt->spare_bytes;
        int chunk, ret;
+       u8 status;
 
        marvell_nfc_select_target(chip, chip->cur_cs);
 
@@ -1663,6 +1676,14 @@ static int marvell_nfc_hw_ecc_bch_write_page(struct nand_chip *chip,
        if (ret)
                return ret;
 
+       /* Check write status on the chip side */
+       ret = nand_status_op(chip, &status);
+       if (ret)
+               return ret;
+
+       if (status & NAND_STATUS_FAIL)
+               return -EIO;
+
        return 0;
 }