From: Boris Brezillon <boris.brezillon@collabora.com>
To: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: Vignesh Raghavendra <vigneshr@ti.com>,
Tudor Ambarus <Tudor.Ambarus@microchip.com>,
Richard Weinberger <richard@nod.at>,
ladis@triops.cz, linux-mtd@lists.infradead.org,
Adam Ford <aford173@gmail.com>
Subject: Re: [PATCH v2 1/2] mtd: nand: Add a helper to retrieve the number of ECC steps
Date: Wed, 20 Jan 2021 11:30:09 +0100 [thread overview]
Message-ID: <20210120113009.7687efde@collabora.com> (raw)
In-Reply-To: <20210120101750.1163-2-miquel.raynal@bootlin.com>
On Wed, 20 Jan 2021 11:17:49 +0100
Miquel Raynal <miquel.raynal@bootlin.com> wrote:
> This operation is very common and deserves a helper. It of course only
> works after the ECC engine initialization.
>
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
> ---
> include/linux/mtd/nand.h | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
> index 414f8a4d2853..27e87c02971c 100644
> --- a/include/linux/mtd/nand.h
> +++ b/include/linux/mtd/nand.h
> @@ -585,6 +585,18 @@ nanddev_get_ecc_conf(struct nand_device *nand)
> return &nand->ecc.ctx.conf;
> }
>
> +/**
> + * nanddev_get_ecc_nsteps() - Extract the actual number of ECC steps
> + * @nand: NAND device
> + */
> +static inline unsigned int
> +nanddev_get_ecc_nsteps(struct nand_device *nand)
> +{
> + const struct nand_ecc_props *conf = nanddev_get_ecc_conf(nand);
> +
> + return nanddev_page_size(nand) / conf->step_size;
Some ECC engines might cover OOB bytes too, so you can't really guess
the number of steps with a simple page_size / step_size division. I
think it's safer to store the number of steps and step_size directly in
the conf and let the engine fill those.
> +}
> +
> /**
> * nanddev_get_ecc_requirements() - Extract the ECC requirements from a NAND
> * device
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
next prev parent reply other threads:[~2021-01-20 10:31 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-20 10:17 [PATCH v2 0/2] Fix OMAP2 ECC/OOB layout logic Miquel Raynal
2021-01-20 10:17 ` [PATCH v2 1/2] mtd: nand: Add a helper to retrieve the number of ECC steps Miquel Raynal
2021-01-20 10:30 ` Boris Brezillon [this message]
2021-01-20 10:17 ` [PATCH v2 2/2] mtd: rawnand: omap: Use ECC information from the generic structures Miquel Raynal
2021-01-20 10:36 ` Boris Brezillon
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=20210120113009.7687efde@collabora.com \
--to=boris.brezillon@collabora.com \
--cc=Tudor.Ambarus@microchip.com \
--cc=aford173@gmail.com \
--cc=ladis@triops.cz \
--cc=linux-mtd@lists.infradead.org \
--cc=miquel.raynal@bootlin.com \
--cc=richard@nod.at \
--cc=vigneshr@ti.com \
/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;
as well as URLs for NNTP newsgroup(s).