]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
spi: spi-qpic-snand: simplify bad block marker duplication
authorGabor Juhos <j4g8y7@gmail.com>
Fri, 11 Jul 2025 16:32:52 +0000 (18:32 +0200)
committerMark Brown <broonie@kernel.org>
Wed, 23 Jul 2025 12:04:08 +0000 (13:04 +0100)
Due to the expectations of the SPINAND code, the driver duplicates
the bad block markers during raw OOB reads.

It has been implemented by using two if statements, and due to the
opposite conditions one of conditional codepaths always runs. Since
the effect of both codepaths is the same, remove the if statements
and use a single line solution instead.

Also add a note about why the duplication is required.

No functional changes intended.

Signed-off-by: Gabor Juhos <j4g8y7@gmail.com>
Link: https://patch.msgid.link/20250711-qpic-snand-simplify-bbm-copy-v1-1-dd2608325f72@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-qpic-snand.c

index c49bf7079808a1933c8a630e0b07b5fd54dfddb6..0cfa0d960fd3c245c2bbf4f5e02d0fc0b13e7696 100644 (file)
@@ -613,10 +613,16 @@ static int qcom_spi_read_last_cw(struct qcom_nand_controller *snandc,
 
        bbpos = mtd->writesize - ecc_cfg->cw_size * (num_cw - 1);
 
-       if (snandc->data_buffer[bbpos] == 0xff)
-               snandc->data_buffer[bbpos + 1] = 0xff;
-       if (snandc->data_buffer[bbpos] != 0xff)
-               snandc->data_buffer[bbpos + 1] = snandc->data_buffer[bbpos];
+       /*
+        * TODO: The SPINAND code expects two bad block marker bytes
+        * at the beginning of the OOB area, but the OOB layout used by
+        * the driver has only one. Duplicate that for now in order to
+        * avoid certain blocks to be marked as bad.
+        *
+        * This can be removed once single-byte bad block marker support
+        * gets implemented in the SPINAND code.
+        */
+       snandc->data_buffer[bbpos + 1] = snandc->data_buffer[bbpos];
 
        memcpy(op->data.buf.in, snandc->data_buffer + bbpos, op->data.nbytes);