@ -269,14 +269,9 @@ static int is_blank(struct mtd_info *mtd, struct fsl_ifc_ctrl *ctrl,
/* returns nonzero if entire page is blank */
/* returns nonzero if entire page is blank */
static int check_read_ecc ( struct mtd_info * mtd , struct fsl_ifc_ctrl * ctrl ,
static int check_read_ecc ( struct mtd_info * mtd , struct fsl_ifc_ctrl * ctrl ,
u32 * eccstat , unsigned int bufnum )
u32 eccstat , unsigned int bufnum )
{
{
u32 reg = eccstat [ bufnum / 4 ] ;
return ( eccstat > > ( ( 3 - bufnum % 4 ) * 8 ) ) & 15 ;
int errors ;
errors = ( reg > > ( ( 3 - bufnum % 4 ) * 8 ) ) & 15 ;
return errors ;
}
}
/*
/*
@ -290,7 +285,7 @@ static int fsl_ifc_run_command(struct mtd_info *mtd)
struct fsl_ifc_runtime * ifc = ctrl - > regs . rregs ;
struct fsl_ifc_runtime * ifc = ctrl - > regs . rregs ;
u32 timeo = ( CONFIG_SYS_HZ * 10 ) / 1000 ;
u32 timeo = ( CONFIG_SYS_HZ * 10 ) / 1000 ;
u32 time_start ;
u32 time_start ;
u32 eccstat [ 8 ] = { 0 } ;
u32 eccstat ;
int i ;
int i ;
/* set the chip select for NAND Transaction */
/* set the chip select for NAND Transaction */
@ -320,20 +315,17 @@ static int fsl_ifc_run_command(struct mtd_info *mtd)
if ( ctrl - > eccread ) {
if ( ctrl - > eccread ) {
int errors ;
int errors ;
int bufnum = ctrl - > page & priv - > bufnum_mask ;
int bufnum = ctrl - > page & priv - > bufnum_mask ;
int sector = bufnum * chip - > ecc . steps ;
int sector_start = bufnum * chip - > ecc . steps ;
int sector_end = sector + chip - > ecc . steps - 1 ;
int sector_end = sector_start + chip - > ecc . steps - 1 ;
u32 * eccstat_regs ;
for ( i = sector / 4 ; i < = sector_end / 4 ; i + + ) {
if ( i > = ARRAY_SIZE ( eccstat ) ) {
printf ( " %s: eccstat too small for %d \n " ,
__func__ , i ) ;
return - EIO ;
}
eccstat [ i ] = ifc_in32 ( & ifc - > ifc_nand . nand_eccstat [ i ] ) ;
eccstat_regs = ifc - > ifc_nand . nand_eccstat ;
}
eccstat = ifc_in32 ( & eccstat_regs [ sector_start / 4 ] ) ;
for ( i = sector_start ; i < = sector_end ; i + + ) {
if ( ( i ! = sector_start ) & & ! ( i % 4 ) )
eccstat = ifc_in32 ( & eccstat_regs [ i / 4 ] ) ;
for ( i = sector ; i < = sector_end ; i + + ) {
errors = check_read_ecc ( mtd , ctrl , eccstat , i ) ;
errors = check_read_ecc ( mtd , ctrl , eccstat , i ) ;
if ( errors = = 15 ) {
if ( errors = = 15 ) {