linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH] mtd: nand: vf610_nfc: use nand_check_erased_ecc_chunk() helper
@ 2015-09-29 21:11 Brian Norris
  2015-09-30 16:52 ` Boris Brezillon
  0 siblings, 1 reply; 4+ messages in thread
From: Brian Norris @ 2015-09-29 21:11 UTC (permalink / raw)
  To: linux-mtd; +Cc: Bill Pringlemeir, Brian Norris, Stefan Agner, Boris Brezillon

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
---
I forgot about this feedback. How does this patch look? Just compile tested.

 drivers/mtd/nand/vf610_nfc.c | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/drivers/mtd/nand/vf610_nfc.c b/drivers/mtd/nand/vf610_nfc.c
index 42dad8e4b26f..598faf655f5b 100644
--- a/drivers/mtd/nand/vf610_nfc.c
+++ b/drivers/mtd/nand/vf610_nfc.c
@@ -560,7 +560,6 @@ static inline int vf610_nfc_correct_data(struct mtd_info *mtd, uint8_t *dat,
 	u32 ecc_status_off = NFC_MAIN_AREA(0) + ECC_SRAM_ADDR + ECC_STATUS;
 	u8 ecc_status;
 	u8 ecc_count;
-	int flips;
 	int flips_threshold = nfc->chip.ecc.strength / 2;
 
 	ecc_status = vf610_nfc_read(nfc, ecc_status_off) & 0xff;
@@ -577,16 +576,9 @@ static inline int vf610_nfc_correct_data(struct mtd_info *mtd, uint8_t *dat,
 	 * On an erased page, bit count (including OOB) should be zero or
 	 * at least less then half of the ECC strength.
 	 */
-	flips = count_written_bits(dat, nfc->chip.ecc.size, flips_threshold);
-	flips += count_written_bits(oob, mtd->oobsize, flips_threshold);
-
-	if (unlikely(flips > flips_threshold))
-		return -EINVAL;
-
-	/* Erased page. */
-	memset(dat, 0xff, nfc->chip.ecc.size);
-	memset(oob, 0xff, mtd->oobsize);
-	return flips;
+	return nand_check_erased_ecc_chunk(dat, nfc->chip.ecc.size, oob,
+					   mtd->oobsize, NULL, 0,
+					   flips_threshold);
 }
 
 static int vf610_nfc_read_page(struct mtd_info *mtd, struct nand_chip *chip,
-- 
2.6.0.rc2.230.g3dd15c0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [RFC PATCH] mtd: nand: vf610_nfc: use nand_check_erased_ecc_chunk() helper
  2015-09-29 21:11 [RFC PATCH] mtd: nand: vf610_nfc: use nand_check_erased_ecc_chunk() helper Brian Norris
@ 2015-09-30 16:52 ` Boris Brezillon
  2015-10-26 20:12   ` Brian Norris
  0 siblings, 1 reply; 4+ messages in thread
From: Boris Brezillon @ 2015-09-30 16:52 UTC (permalink / raw)
  To: Brian Norris; +Cc: linux-mtd, Bill Pringlemeir, Stefan Agner

On Tue, 29 Sep 2015 14:11:56 -0700
Brian Norris <computersforpeace@gmail.com> wrote:

> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
> ---
> I forgot about this feedback. How does this patch look? Just compile tested.

Looks good to me, but I can't test it either :-).

Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com>

> 
>  drivers/mtd/nand/vf610_nfc.c | 14 +++-----------
>  1 file changed, 3 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/mtd/nand/vf610_nfc.c b/drivers/mtd/nand/vf610_nfc.c
> index 42dad8e4b26f..598faf655f5b 100644
> --- a/drivers/mtd/nand/vf610_nfc.c
> +++ b/drivers/mtd/nand/vf610_nfc.c
> @@ -560,7 +560,6 @@ static inline int vf610_nfc_correct_data(struct mtd_info *mtd, uint8_t *dat,
>  	u32 ecc_status_off = NFC_MAIN_AREA(0) + ECC_SRAM_ADDR + ECC_STATUS;
>  	u8 ecc_status;
>  	u8 ecc_count;
> -	int flips;
>  	int flips_threshold = nfc->chip.ecc.strength / 2;
>  
>  	ecc_status = vf610_nfc_read(nfc, ecc_status_off) & 0xff;
> @@ -577,16 +576,9 @@ static inline int vf610_nfc_correct_data(struct mtd_info *mtd, uint8_t *dat,
>  	 * On an erased page, bit count (including OOB) should be zero or
>  	 * at least less then half of the ECC strength.
>  	 */
> -	flips = count_written_bits(dat, nfc->chip.ecc.size, flips_threshold);
> -	flips += count_written_bits(oob, mtd->oobsize, flips_threshold);
> -
> -	if (unlikely(flips > flips_threshold))
> -		return -EINVAL;
> -
> -	/* Erased page. */
> -	memset(dat, 0xff, nfc->chip.ecc.size);
> -	memset(oob, 0xff, mtd->oobsize);
> -	return flips;
> +	return nand_check_erased_ecc_chunk(dat, nfc->chip.ecc.size, oob,
> +					   mtd->oobsize, NULL, 0,
> +					   flips_threshold);
>  }
>  
>  static int vf610_nfc_read_page(struct mtd_info *mtd, struct nand_chip *chip,



-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFC PATCH] mtd: nand: vf610_nfc: use nand_check_erased_ecc_chunk() helper
  2015-09-30 16:52 ` Boris Brezillon
@ 2015-10-26 20:12   ` Brian Norris
  2015-10-26 20:44     ` Stefan Agner
  0 siblings, 1 reply; 4+ messages in thread
From: Brian Norris @ 2015-10-26 20:12 UTC (permalink / raw)
  To: Boris Brezillon; +Cc: linux-mtd, Bill Pringlemeir, Stefan Agner

On Wed, Sep 30, 2015 at 06:52:46PM +0200, Boris Brezillon wrote:
> On Tue, 29 Sep 2015 14:11:56 -0700
> Brian Norris <computersforpeace@gmail.com> wrote:
> 
> > Signed-off-by: Brian Norris <computersforpeace@gmail.com>
> > ---
> > I forgot about this feedback. How does this patch look? Just compile tested.
> 
> Looks good to me, but I can't test it either :-).
> 
> Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com>

Seeing as this came up during review, and I see no objections...

Applied to l2-mtd.git

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFC PATCH] mtd: nand: vf610_nfc: use nand_check_erased_ecc_chunk() helper
  2015-10-26 20:12   ` Brian Norris
@ 2015-10-26 20:44     ` Stefan Agner
  0 siblings, 0 replies; 4+ messages in thread
From: Stefan Agner @ 2015-10-26 20:44 UTC (permalink / raw)
  To: Brian Norris; +Cc: Boris Brezillon, linux-mtd, Bill Pringlemeir

On 2015-10-26 13:12, Brian Norris wrote:
> On Wed, Sep 30, 2015 at 06:52:46PM +0200, Boris Brezillon wrote:
>> On Tue, 29 Sep 2015 14:11:56 -0700
>> Brian Norris <computersforpeace@gmail.com> wrote:
>>
>> > Signed-off-by: Brian Norris <computersforpeace@gmail.com>
>> > ---
>> > I forgot about this feedback. How does this patch look? Just compile tested.
>>
>> Looks good to me, but I can't test it either :-).
>>
>> Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> 
> Seeing as this came up during review, and I see no objections...
> 
> Applied to l2-mtd.git

Hi Brian,

Yeah, sorry, I wanted test that patch but somehow slipped through.
Compiled l2-mtd master with that patch applied for my board, looks good
to me! Thx

--
Stefan

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-10-26 20:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-29 21:11 [RFC PATCH] mtd: nand: vf610_nfc: use nand_check_erased_ecc_chunk() helper Brian Norris
2015-09-30 16:52 ` Boris Brezillon
2015-10-26 20:12   ` Brian Norris
2015-10-26 20:44     ` Stefan Agner

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).