diff mbox series

[1/2] mtd: nand: denali: Avoid using ecc->code_buf as a temporary buffer

Message ID 20171205110929.6820-1-boris.brezillon@free-electrons.com
State Accepted
Delegated to: Boris Brezillon
Headers show
Series [1/2] mtd: nand: denali: Avoid using ecc->code_buf as a temporary buffer | expand

Commit Message

Boris Brezillon Dec. 5, 2017, 11:09 a.m. UTC
ECC bytes are contiguous in the ->oob_poi buffer, which means we don't
have to copy them into the ->code_buf (here used as a temporary buffer)
before passing them to the nand_check_erased_ecc_chunk() function.

This change will allow us to allocate ecc->{code,calc}_buf only when
ecc->calculate() or ecc->correct() is specified.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
---
 drivers/mtd/nand/denali.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

Comments

Masahiro Yamada Dec. 5, 2017, 12:37 p.m. UTC | #1
2017-12-05 20:09 GMT+09:00 Boris Brezillon <boris.brezillon@free-electrons.com>:
> ECC bytes are contiguous in the ->oob_poi buffer, which means we don't
> have to copy them into the ->code_buf (here used as a temporary buffer)
> before passing them to the nand_check_erased_ecc_chunk() function.
>
> This change will allow us to allocate ecc->{code,calc}_buf only when
> ecc->calculate() or ecc->correct() is specified.
>
> Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>

Acked-by: Masahiro Yamada <yamada.masahiro@socionext.com>

Thanks!
Boris Brezillon Dec. 7, 2017, 8:18 p.m. UTC | #2
On Tue, 5 Dec 2017 21:37:45 +0900
Masahiro Yamada <yamada.masahiro@socionext.com> wrote:

> 2017-12-05 20:09 GMT+09:00 Boris Brezillon <boris.brezillon@free-electrons.com>:
> > ECC bytes are contiguous in the ->oob_poi buffer, which means we don't
> > have to copy them into the ->code_buf (here used as a temporary buffer)
> > before passing them to the nand_check_erased_ecc_chunk() function.
> >
> > This change will allow us to allocate ecc->{code,calc}_buf only when
> > ecc->calculate() or ecc->correct() is specified.
> >
> > Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>  
> 
> Acked-by: Masahiro Yamada <yamada.masahiro@socionext.com>

Applied those 2 patches.

Boris

> 
> Thanks!
> 
> 
> 
>
diff mbox series

Patch

diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
index 00698b33cb22..313c7f50621b 100644
--- a/drivers/mtd/nand/denali.c
+++ b/drivers/mtd/nand/denali.c
@@ -330,16 +330,12 @@  static int denali_check_erased_page(struct mtd_info *mtd,
 				    unsigned long uncor_ecc_flags,
 				    unsigned int max_bitflips)
 {
-	uint8_t *ecc_code = chip->ecc.code_buf;
+	struct denali_nand_info *denali = mtd_to_denali(mtd);
+	uint8_t *ecc_code = chip->oob_poi + denali->oob_skip_bytes;
 	int ecc_steps = chip->ecc.steps;
 	int ecc_size = chip->ecc.size;
 	int ecc_bytes = chip->ecc.bytes;
-	int i, ret, stat;
-
-	ret = mtd_ooblayout_get_eccbytes(mtd, ecc_code, chip->oob_poi, 0,
-					 chip->ecc.total);
-	if (ret)
-		return ret;
+	int i, stat;
 
 	for (i = 0; i < ecc_steps; i++) {
 		if (!(uncor_ecc_flags & BIT(i)))