Commit 1385858e authored by Roel Kluin's avatar Roel Kluin Committed by David Woodhouse

mtd: nand_bcm: fix hot spin and code duplication

In the branch where pagesize equalled NAND_DATA_ACCESS_SIZE, NumToRead
wasn't decremented in the `while (numToRead > 11)' loop.
Also the first and last while loops were duplicated in both branches.
Signed-off-by: default avatarRoel Kluin <roel.kluin@gmail.com>
Acked-by: default avatarLeo Chen <leochen@broadcom.com>
Signed-off-by: default avatarDavid Woodhouse <David.Woodhouse@intel.com>
parent c3341d0c
...@@ -167,8 +167,16 @@ static inline void nand_bcm_umi_bch_read_oobEcc(uint32_t pageSize, ...@@ -167,8 +167,16 @@ static inline void nand_bcm_umi_bch_read_oobEcc(uint32_t pageSize,
int numToRead = 16; /* There are 16 bytes per sector in the OOB */ int numToRead = 16; /* There are 16 bytes per sector in the OOB */
/* ECC is already paused when this function is called */ /* ECC is already paused when this function is called */
if (pageSize != NAND_DATA_ACCESS_SIZE) {
/* skip BI */
#if defined(__KERNEL__) && !defined(STANDALONE)
*oobp++ = REG_NAND_DATA8;
#else
REG_NAND_DATA8;
#endif
numToRead--;
}
if (pageSize == NAND_DATA_ACCESS_SIZE) {
while (numToRead > numEccBytes) { while (numToRead > numEccBytes) {
/* skip free oob region */ /* skip free oob region */
#if defined(__KERNEL__) && !defined(STANDALONE) #if defined(__KERNEL__) && !defined(STANDALONE)
...@@ -179,6 +187,7 @@ static inline void nand_bcm_umi_bch_read_oobEcc(uint32_t pageSize, ...@@ -179,6 +187,7 @@ static inline void nand_bcm_umi_bch_read_oobEcc(uint32_t pageSize,
numToRead--; numToRead--;
} }
if (pageSize == NAND_DATA_ACCESS_SIZE) {
/* read ECC bytes before BI */ /* read ECC bytes before BI */
nand_bcm_umi_bch_resume_read_ecc_calc(); nand_bcm_umi_bch_resume_read_ecc_calc();
...@@ -190,6 +199,7 @@ static inline void nand_bcm_umi_bch_read_oobEcc(uint32_t pageSize, ...@@ -190,6 +199,7 @@ static inline void nand_bcm_umi_bch_read_oobEcc(uint32_t pageSize,
#else #else
eccCalc[eccPos++] = REG_NAND_DATA8; eccCalc[eccPos++] = REG_NAND_DATA8;
#endif #endif
numToRead--;
} }
nand_bcm_umi_bch_pause_read_ecc_calc(); nand_bcm_umi_bch_pause_read_ecc_calc();
...@@ -204,37 +214,7 @@ static inline void nand_bcm_umi_bch_read_oobEcc(uint32_t pageSize, ...@@ -204,37 +214,7 @@ static inline void nand_bcm_umi_bch_read_oobEcc(uint32_t pageSize,
numToRead--; numToRead--;
} }
/* read ECC bytes */
nand_bcm_umi_bch_resume_read_ecc_calc();
while (numToRead) {
#if defined(__KERNEL__) && !defined(STANDALONE)
*oobp = REG_NAND_DATA8;
eccCalc[eccPos++] = *oobp;
oobp++;
#else
eccCalc[eccPos++] = REG_NAND_DATA8;
#endif
numToRead--;
}
} else {
/* skip BI */
#if defined(__KERNEL__) && !defined(STANDALONE)
*oobp++ = REG_NAND_DATA8;
#else
REG_NAND_DATA8;
#endif
numToRead--;
while (numToRead > numEccBytes) {
/* skip free oob region */
#if defined(__KERNEL__) && !defined(STANDALONE)
*oobp++ = REG_NAND_DATA8;
#else
REG_NAND_DATA8;
#endif
numToRead--;
} }
/* read ECC bytes */ /* read ECC bytes */
nand_bcm_umi_bch_resume_read_ecc_calc(); nand_bcm_umi_bch_resume_read_ecc_calc();
while (numToRead) { while (numToRead) {
...@@ -247,7 +227,6 @@ static inline void nand_bcm_umi_bch_read_oobEcc(uint32_t pageSize, ...@@ -247,7 +227,6 @@ static inline void nand_bcm_umi_bch_read_oobEcc(uint32_t pageSize,
#endif #endif
numToRead--; numToRead--;
} }
}
} }
/* Helper function to write ECC */ /* Helper function to write ECC */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment