diff mbox

mtd: nand: correct extemded param page error handling

Message ID 1379706242-20548-1-git-send-email-computersforpeace@gmail.com
State Accepted
Commit 4ae7d228d6048d25a16bee209ebea24c5ecde825
Headers show

Commit Message

Brian Norris Sept. 20, 2013, 7:44 p.m. UTC
If the ONFI extended parameter page gives codeword_size == 0, the
extended ECC information is corrupt and should not be used. Currently,
we (correctly) avoid using the information, but we don't report the
error to the caller, so the caller doesn't know that we didn't
initialize ecc_strength_ds and ecc_step_ds. Now the caller can warn the
user that it does not have sufficient information.

This also removes the false and useless "ONFI extended param page
detected" debug message (it was printed even on the aforementioned
corruption, and for the success case, we don't really want a print).

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Cc: Huang Shijie <b32955@freescale.com>
---
 drivers/mtd/nand/nand_base.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Comments

Huang Shijie Sept. 22, 2013, 3 a.m. UTC | #1
于 2013年09月21日 03:44, Brian Norris 写道:
> If the ONFI extended parameter page gives codeword_size == 0, the
> extended ECC information is corrupt and should not be used. Currently,
> we (correctly) avoid using the information, but we don't report the
> error to the caller, so the caller doesn't know that we didn't
> initialize ecc_strength_ds and ecc_step_ds. Now the caller can warn the
> user that it does not have sufficient information.
>
> This also removes the false and useless "ONFI extended param page
> detected" debug message (it was printed even on the aforementioned
> corruption, and for the success case, we don't really want a print).
>
> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
> Cc: Huang Shijie <b32955@freescale.com>
> ---
>  drivers/mtd/nand/nand_base.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
> index 00022b4..0b39d0c 100644
> --- a/drivers/mtd/nand/nand_base.c
> +++ b/drivers/mtd/nand/nand_base.c
> @@ -2912,12 +2912,13 @@ static int nand_flash_detect_ext_param_page(struct mtd_info *mtd,
>  	/* get the info we want. */
>  	ecc = (struct onfi_ext_ecc_info *)cursor;
>  
> -	if (ecc->codeword_size) {
> -		chip->ecc_strength_ds = ecc->ecc_bits;
> -		chip->ecc_step_ds = 1 << ecc->codeword_size;
> +	if (!ecc->codeword_size) {
> +		pr_debug("Invalid codeword size\n");
> +		goto ext_out;
>  	}
>  
> -	pr_info("ONFI extended param page detected.\n");
> +	chip->ecc_strength_ds = ecc->ecc_bits;
> +	chip->ecc_step_ds = 1 << ecc->codeword_size;
>  	ret = 0;
>  
>  ext_out:
Acked-by: Huang Shijie <b32955@freescale.com>
Brian Norris Sept. 25, 2013, 7:33 p.m. UTC | #2
On Sun, Sep 22, 2013 at 11:00:39AM +0800, Huang Shijie wrote:
> 于 2013年09月21日 03:44, Brian Norris 写道:
> > If the ONFI extended parameter page gives codeword_size == 0, the
> > extended ECC information is corrupt and should not be used. Currently,
> > we (correctly) avoid using the information, but we don't report the
> > error to the caller, so the caller doesn't know that we didn't
> > initialize ecc_strength_ds and ecc_step_ds. Now the caller can warn the
> > user that it does not have sufficient information.
> >
> > This also removes the false and useless "ONFI extended param page
> > detected" debug message (it was printed even on the aforementioned
> > corruption, and for the success case, we don't really want a print).
> >
> > Signed-off-by: Brian Norris <computersforpeace@gmail.com>
> > Cc: Huang Shijie <b32955@freescale.com>
...
> Acked-by: Huang Shijie <b32955@freescale.com>

Pushed to l2-mtd.git.

Brian
diff mbox

Patch

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 00022b4..0b39d0c 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -2912,12 +2912,13 @@  static int nand_flash_detect_ext_param_page(struct mtd_info *mtd,
 	/* get the info we want. */
 	ecc = (struct onfi_ext_ecc_info *)cursor;
 
-	if (ecc->codeword_size) {
-		chip->ecc_strength_ds = ecc->ecc_bits;
-		chip->ecc_step_ds = 1 << ecc->codeword_size;
+	if (!ecc->codeword_size) {
+		pr_debug("Invalid codeword size\n");
+		goto ext_out;
 	}
 
-	pr_info("ONFI extended param page detected.\n");
+	chip->ecc_strength_ds = ecc->ecc_bits;
+	chip->ecc_step_ds = 1 << ecc->codeword_size;
 	ret = 0;
 
 ext_out: