Patchwork [U-Boot,v7,06/19] nand: mxc: Use appropriate page number in syndrome functions

login
register
mail settings
Submitter Benoît Thébaudeau
Date Feb. 15, 2013, 8:54 p.m.
Message ID <1360961665-10693-6-git-send-email-benoit.thebaudeau@advansee.com>
Download mbox | patch
Permalink /patch/220857/
State Superseded
Delegated to: Stefano Babic
Headers show

Comments

Benoît Thébaudeau - Feb. 15, 2013, 8:54 p.m.
The syndrome functions should use the page number passed as argument instead of
the page number saved upon NAND_CMD_READ0.

This does not make any difference if the NAND_NO_AUTOINCR option is set, but
otherwise this fixes accesses to the wrong pages.

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com>
---
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4:
 - New patch.

Changes in v3: None
Changes in v2: None

 drivers/mtd/nand/mxc_nand.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
Scott Wood - Feb. 19, 2013, 12:30 a.m.
On 02/15/2013 02:54:12 PM, Benoît Thébaudeau wrote:
> The syndrome functions should use the page number passed as argument  
> instead of
> the page number saved upon NAND_CMD_READ0.
> 
> This does not make any difference if the NAND_NO_AUTOINCR option is  
> set, but
> otherwise this fixes accesses to the wrong pages.
> 
> Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com>
> ---
> Changes in v7: None
> Changes in v6: None
> Changes in v5: None
> Changes in v4:
>  - New patch.
> 
> Changes in v3: None
> Changes in v2: None
> 
>  drivers/mtd/nand/mxc_nand.c |    6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
> index 249328e..001c2c0 100644
> --- a/drivers/mtd/nand/mxc_nand.c
> +++ b/drivers/mtd/nand/mxc_nand.c
> @@ -504,7 +504,7 @@ static int mxc_nand_read_page_raw_syndrome(struct  
> mtd_info *mtd,
>  	int n;
> 
>  	_mxc_nand_enable_hwecc(mtd, 0);
> -	chip->cmdfunc(mtd, NAND_CMD_READ0, 0x00, host->page_addr);
> +	chip->cmdfunc(mtd, NAND_CMD_READ0, 0x00, page);
> 
>  	for (n = 0, steps = chip->ecc.steps; steps > 0; n++, steps--) {
>  		host->col_addr = n * eccsize;
> @@ -548,7 +548,7 @@ static int mxc_nand_read_page_syndrome(struct  
> mtd_info *mtd,
>  	uint8_t *oob = chip->oob_poi;
> 
>  	MTDDEBUG(MTD_DEBUG_LEVEL1, "Reading page %u to buf %p oob %p\n",
> -	      host->page_addr, buf, oob);
> +	      page, buf, oob);
> 
>  	/* first read the data area and the available portion of OOB */
>  	for (n = 0; eccsteps; n++, eccsteps--, p += eccsize) {
> @@ -586,7 +586,7 @@ static int mxc_nand_read_page_syndrome(struct  
> mtd_info *mtd,
> 
>  	/* Then switch ECC off and read the OOB area to get the ECC  
> code */
>  	_mxc_nand_enable_hwecc(mtd, 0);
> -	chip->cmdfunc(mtd, NAND_CMD_READOOB, mtd->writesize,  
> host->page_addr);
> +	chip->cmdfunc(mtd, NAND_CMD_READOOB, mtd->writesize, page);
>  	eccsteps = chip->ecc.steps;
>  	oob = chip->oob_poi + chip->ecc.prepad;
>  	for (n = 0; eccsteps; n++, eccsteps--, p += eccsize) {

The debug print in mxc_nand_read_oob_syndrome() also needs to be fixed.

-Scott
Benoît Thébaudeau - Feb. 19, 2013, 11:31 a.m.
Hi Scott,

On Tuesday, February 19, 2013 1:30:23 AM, Scott Wood wrote:
> On 02/15/2013 02:54:12 PM, Benoît Thébaudeau wrote:
> > The syndrome functions should use the page number passed as argument
> > instead of
> > the page number saved upon NAND_CMD_READ0.
> > 
> > This does not make any difference if the NAND_NO_AUTOINCR option is
> > set, but
> > otherwise this fixes accesses to the wrong pages.
> > 
> > Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com>
> > ---
> > Changes in v7: None
> > Changes in v6: None
> > Changes in v5: None
> > Changes in v4:
> >  - New patch.
> > 
> > Changes in v3: None
> > Changes in v2: None
> > 
> >  drivers/mtd/nand/mxc_nand.c |    6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
> > index 249328e..001c2c0 100644
> > --- a/drivers/mtd/nand/mxc_nand.c
> > +++ b/drivers/mtd/nand/mxc_nand.c
> > @@ -504,7 +504,7 @@ static int mxc_nand_read_page_raw_syndrome(struct
> > mtd_info *mtd,
> >  	int n;
> > 
> >  	_mxc_nand_enable_hwecc(mtd, 0);
> > -	chip->cmdfunc(mtd, NAND_CMD_READ0, 0x00, host->page_addr);
> > +	chip->cmdfunc(mtd, NAND_CMD_READ0, 0x00, page);
> > 
> >  	for (n = 0, steps = chip->ecc.steps; steps > 0; n++, steps--) {
> >  		host->col_addr = n * eccsize;
> > @@ -548,7 +548,7 @@ static int mxc_nand_read_page_syndrome(struct
> > mtd_info *mtd,
> >  	uint8_t *oob = chip->oob_poi;
> > 
> >  	MTDDEBUG(MTD_DEBUG_LEVEL1, "Reading page %u to buf %p oob %p\n",
> > -	      host->page_addr, buf, oob);
> > +	      page, buf, oob);
> > 
> >  	/* first read the data area and the available portion of OOB */
> >  	for (n = 0; eccsteps; n++, eccsteps--, p += eccsize) {
> > @@ -586,7 +586,7 @@ static int mxc_nand_read_page_syndrome(struct
> > mtd_info *mtd,
> > 
> >  	/* Then switch ECC off and read the OOB area to get the ECC
> > code */
> >  	_mxc_nand_enable_hwecc(mtd, 0);
> > -	chip->cmdfunc(mtd, NAND_CMD_READOOB, mtd->writesize,
> > host->page_addr);
> > +	chip->cmdfunc(mtd, NAND_CMD_READOOB, mtd->writesize, page);
> >  	eccsteps = chip->ecc.steps;
> >  	oob = chip->oob_poi + chip->ecc.prepad;
> >  	for (n = 0; eccsteps; n++, eccsteps--, p += eccsize) {
> 
> The debug print in mxc_nand_read_oob_syndrome() also needs to be fixed.

Yes, but this is done by 05/19.

Best regards,
Benoît

Patch

diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
index 249328e..001c2c0 100644
--- a/drivers/mtd/nand/mxc_nand.c
+++ b/drivers/mtd/nand/mxc_nand.c
@@ -504,7 +504,7 @@  static int mxc_nand_read_page_raw_syndrome(struct mtd_info *mtd,
 	int n;
 
 	_mxc_nand_enable_hwecc(mtd, 0);
-	chip->cmdfunc(mtd, NAND_CMD_READ0, 0x00, host->page_addr);
+	chip->cmdfunc(mtd, NAND_CMD_READ0, 0x00, page);
 
 	for (n = 0, steps = chip->ecc.steps; steps > 0; n++, steps--) {
 		host->col_addr = n * eccsize;
@@ -548,7 +548,7 @@  static int mxc_nand_read_page_syndrome(struct mtd_info *mtd,
 	uint8_t *oob = chip->oob_poi;
 
 	MTDDEBUG(MTD_DEBUG_LEVEL1, "Reading page %u to buf %p oob %p\n",
-	      host->page_addr, buf, oob);
+	      page, buf, oob);
 
 	/* first read the data area and the available portion of OOB */
 	for (n = 0; eccsteps; n++, eccsteps--, p += eccsize) {
@@ -586,7 +586,7 @@  static int mxc_nand_read_page_syndrome(struct mtd_info *mtd,
 
 	/* Then switch ECC off and read the OOB area to get the ECC code */
 	_mxc_nand_enable_hwecc(mtd, 0);
-	chip->cmdfunc(mtd, NAND_CMD_READOOB, mtd->writesize, host->page_addr);
+	chip->cmdfunc(mtd, NAND_CMD_READOOB, mtd->writesize, page);
 	eccsteps = chip->ecc.steps;
 	oob = chip->oob_poi + chip->ecc.prepad;
 	for (n = 0; eccsteps; n++, eccsteps--, p += eccsize) {