From: Stefan Riedmueller <s.riedmueller@phytec.de>
To: barebox@lists.infradead.org
Subject: [PATCH 3/4] mtd: nand_msx: Implement ooblayout ops
Date: Tue, 30 Mar 2021 08:50:39 +0200 [thread overview]
Message-ID: <20210330065040.5030-3-s.riedmueller@phytec.de> (raw)
In-Reply-To: <20210330065040.5030-1-s.riedmueller@phytec.de>
The default ooblayout ops do not work on nand_mxs devices and can lead
to an unresponsible system when doing a 'nand -i' on that device.
Thus implement the ooblayout ops for the nand_mxs driver separately.
Since writing the oob area is not supported simply return the whole oob
area as ecc.
Signed-off-by: Stefan Riedmueller <s.riedmueller@phytec.de>
---
drivers/mtd/nand/nand_mxs.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/drivers/mtd/nand/nand_mxs.c b/drivers/mtd/nand/nand_mxs.c
index 96ae71364efb..285ae3c121b6 100644
--- a/drivers/mtd/nand/nand_mxs.c
+++ b/drivers/mtd/nand/nand_mxs.c
@@ -269,6 +269,33 @@ static void mxs_nand_return_dma_descs(struct mxs_nand_info *info)
info->desc_index = 0;
}
+/*
+ * We don't support writing the oob area so simply return the whole oob
+ * as ECC.
+ */
+static int mxs_nand_ooblayout_ecc(struct mtd_info *mtd, int section,
+ struct mtd_oob_region *oobregion)
+{
+ if (section)
+ return -ERANGE;
+
+ oobregion->offset = 0;
+ oobregion->length = mtd->oobsize;
+
+ return 0;
+}
+
+static int mxs_nand_ooblayout_free(struct mtd_info *mtd, int section,
+ struct mtd_oob_region *oobregion)
+{
+ return -ERANGE;
+}
+
+static const struct mtd_ooblayout_ops mxs_nand_ooblayout_ops = {
+ .ecc = mxs_nand_ooblayout_ecc,
+ .free = mxs_nand_ooblayout_free,
+};
+
static uint32_t mxs_nand_ecc_chunk_cnt(uint32_t page_data_size)
{
return page_data_size / MXS_NAND_CHUNK_DATA_CHUNK_SIZE;
@@ -2218,6 +2245,8 @@ static int mxs_nand_probe(struct device_d *dev)
if (err)
goto err2;
+ mtd_set_ooblayout(mtd, &mxs_nand_ooblayout_ops);
+
mxs_nand_scan_bbt(chip);
err = add_mtd_nand_device(mtd, "nand");
--
2.25.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2021-03-30 6:51 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-30 6:50 [PATCH 1/4] commands: Kconfig: Remove HW ECC dependency from nandtest Stefan Riedmueller
2021-03-30 6:50 ` [PATCH 2/4] nandtest: Fix status print for NAND which size exceeds 4 GB Stefan Riedmueller
2021-03-30 6:50 ` Stefan Riedmueller [this message]
2021-03-30 6:50 ` [PATCH 4/4] imx-bbu-nand-fcb: Inform user if the barebox partition is too small Stefan Riedmueller
2021-04-01 8:26 ` [PATCH 1/4] commands: Kconfig: Remove HW ECC dependency from nandtest Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210330065040.5030-3-s.riedmueller@phytec.de \
--to=s.riedmueller@phytec.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox