[PATCH] mtd: nand: Add error log for marvell_nfc_end_cmd()

Wentao Liang vulab at iscas.ac.cn
Sun Apr 6 19:09:16 PDT 2025


The function marvell_nfc_hw_ecc_bch_read_chunk() calls the function
marvell_nfc_end_cmd(), but dose not check its return value. Since it
is incorrect to bail from the loop if the marvell_nfc_end_cmd() fails,
an error log is necessary to prevent silent failure.

Signed-off-by: Wentao Liang <vulab at iscas.ac.cn>
---
 drivers/mtd/nand/raw/marvell_nand.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/nand/raw/marvell_nand.c b/drivers/mtd/nand/raw/marvell_nand.c
index 303b3016a070..1069a17dae9d 100644
--- a/drivers/mtd/nand/raw/marvell_nand.c
+++ b/drivers/mtd/nand/raw/marvell_nand.c
@@ -1351,16 +1351,20 @@ static void marvell_nfc_hw_ecc_bch_read_chunk(struct nand_chip *chip, int chunk,
 	 * Length is a multiple of 32 bytes, hence it is a multiple of 8 too.
 	 */
 	for (i = 0; i < data_len; i += FIFO_DEPTH * BCH_SEQ_READS) {
-		marvell_nfc_end_cmd(chip, NDSR_RDDREQ,
-				    "RDDREQ while draining FIFO (data)");
+		err = marvell_nfc_end_cmd(chip, NDSR_RDDREQ,
+					  "RDDREQ while draining FIFO (data)");
+		if (err)
+			dev_err(nfc->dev, "Fail to confirm the NDSR.RDDREQ");
 		marvell_nfc_xfer_data_in_pio(nfc, data,
 					     FIFO_DEPTH * BCH_SEQ_READS);
 		data += FIFO_DEPTH * BCH_SEQ_READS;
 	}
 
 	for (i = 0; i < spare_len; i += FIFO_DEPTH * BCH_SEQ_READS) {
-		marvell_nfc_end_cmd(chip, NDSR_RDDREQ,
-				    "RDDREQ while draining FIFO (OOB)");
+		err = marvell_nfc_end_cmd(chip, NDSR_RDDREQ,
+					  "RDDREQ while draining FIFO (OOB)");
+		if (err)
+			dev_err(nfc->dev, "Fail to confirm the NDSR.RDDREQ");
 		marvell_nfc_xfer_data_in_pio(nfc, spare,
 					     FIFO_DEPTH * BCH_SEQ_READS);
 		spare += FIFO_DEPTH * BCH_SEQ_READS;
-- 
2.42.0.windows.2




More information about the linux-mtd mailing list