6522507786cbe73af184c3a72191323b914df2f0
[openwrt/staging/linusw.git] /
1 From 840b2f8dd2d0579e517140e1f9bbc482eaf4ed07 Mon Sep 17 00:00:00 2001
2 From: Miquel Raynal <miquel.raynal@bootlin.com>
3 Date: Thu, 16 Dec 2021 12:16:39 +0100
4 Subject: [PATCH 02/15] mtd: nand: Add a new helper to retrieve the ECC context
5
6 Introduce nand_to_ecc_ctx() which will allow to easily jump to the
7 private pointer of an ECC context given a NAND device. This is very
8 handy, from the prepare or finish ECC hook, to get the internal context
9 out of the NAND device object.
10
11 Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
12 Link: https://lore.kernel.org/linux-mtd/20211216111654.238086-14-miquel.raynal@bootlin.com
13 (cherry picked from commit cda32a618debd3fad8e42757b198719ae180f8f4)
14 ---
15 include/linux/mtd/nand.h | 5 +++++
16 1 file changed, 5 insertions(+)
17
18 diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
19 index 4ddd20fe9c9e..b617efa0a881 100644
20 --- a/include/linux/mtd/nand.h
21 +++ b/include/linux/mtd/nand.h
22 @@ -990,6 +990,11 @@ int nanddev_markbad(struct nand_device *nand, const struct nand_pos *pos);
23 int nanddev_ecc_engine_init(struct nand_device *nand);
24 void nanddev_ecc_engine_cleanup(struct nand_device *nand);
25
26 +static inline void *nand_to_ecc_ctx(struct nand_device *nand)
27 +{
28 + return nand->ecc.ctx.priv;
29 +}
30 +
31 /* BBT related functions */
32 enum nand_bbt_block_status {
33 NAND_BBT_BLOCK_STATUS_UNKNOWN,
34 --
35 2.35.1
36