[PATCH v2 2/2] spi: spi-qpic-snand: drop the redundant ECC context handling

From: Johan Alvarado

Date: Fri Sep 11 2026 - 14:51:32 EST


qcom_spi_ecc_init_ctx_pipelined() now publishes the ECC context to
snandc->qspi->ecc, so the assignment in
qcom_spi_ecc_prepare_io_req_pipelined() repeats what the pointer already
holds, and the zeroed struct qpic_ecc that qcom_spi_probe() allocates is
never read.

The pointer is non-NULL only between context creation and destruction,
and every reader runs inside that window. The ooblayout callbacks are
installed by init_ctx. The page read, write and program helpers run only
when prepare_io_req has set page_rw or oob_rw. qcom_spi_block_erase()
runs only while the mtd is registered, which happens after init_ctx and
ends before cleanup_ctx. The controller drives a single chip select, so
the per-controller pointer and the per-chip context cannot disagree.

Remove both. No functional change.

Suggested-by: Gabor Juhos <j4g8y7@xxxxxxxxx>
Signed-off-by: Johan Alvarado <contact@xxxxxxxx>
---
Tested on a Mercusys MR80X (IPQ5018, ESMT F50D1G41LB) with both patches
backported to 6.18.44. Five boots, rootfs mounted every time, mtd
reported 0 ECC failures and 0 corrected bits, and a 4 MiB file on the
UBIFS overlay kept its sha256 across the reboots. Overlay churn raised
the UBI maximum erase counter from 13 to 15, so qcom_spi_block_erase()
ran repeatedly. Build-tested on this base with W=1 and sparse, no
warnings, patch 1 alone and both patches applied.

drivers/spi/spi-qpic-snand.c | 8 --------
1 file changed, 8 deletions(-)

diff --git a/drivers/spi/spi-qpic-snand.c b/drivers/spi/spi-qpic-snand.c
index 20045d4a46fa..760ee1c29402 100644
--- a/drivers/spi/spi-qpic-snand.c
+++ b/drivers/spi/spi-qpic-snand.c
@@ -437,9 +437,7 @@ static int qcom_spi_ecc_prepare_io_req_pipelined(struct nand_device *nand,
struct nand_page_io_req *req)
{
struct qcom_nand_controller *snandc = nand_to_qcom_snand(nand);
- struct qpic_ecc *ecc_cfg = nand_to_ecc_ctx(nand);

- snandc->qspi->ecc = ecc_cfg;
snandc->qspi->raw_rw = false;
snandc->qspi->oob_rw = false;
snandc->qspi->page_rw = false;
@@ -1586,14 +1584,9 @@ static int qcom_spi_probe(struct platform_device *pdev)
struct spi_controller *ctlr;
struct qcom_nand_controller *snandc;
struct qpic_spi_nand *qspi;
- struct qpic_ecc *ecc;
struct resource *res;
int ret;

- ecc = devm_kzalloc(dev, sizeof(*ecc), GFP_KERNEL);
- if (!ecc)
- return -ENOMEM;
-
qspi = devm_kzalloc(dev, sizeof(*qspi), GFP_KERNEL);
if (!qspi)
return -ENOMEM;
@@ -1613,7 +1606,6 @@ static int qcom_spi_probe(struct platform_device *pdev)
snandc->dev = dev;
snandc->qspi = qspi;
snandc->qspi->ctlr = ctlr;
- snandc->qspi->ecc = ecc;

snandc->props = of_device_get_match_data(dev);
if (!snandc->props) {
--
2.55.0