* [PATCH] mtd: hot spin and code duplication in nand_bcm_umi_bch_read_oobEcc()
@ 2010-01-22 21:22 Roel Kluin
2010-01-22 22:04 ` Leo (Hao) Chen
2010-02-03 16:22 ` Artem Bityutskiy
0 siblings, 2 replies; 3+ messages in thread
From: Roel Kluin @ 2010-01-22 21:22 UTC (permalink / raw)
To: Leo Chen, Scott Branden, linux-mtd, Andrew Morton, LKML
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: Roel Kluin <roel.kluin@gmail.com>
---
drivers/mtd/nand/nand_bcm_umi.h | 71 ++++++++++++++-------------------------
1 files changed, 25 insertions(+), 46 deletions(-)
diff --git a/drivers/mtd/nand/nand_bcm_umi.h b/drivers/mtd/nand/nand_bcm_umi.h
index 7cec2cd..198b304 100644
--- a/drivers/mtd/nand/nand_bcm_umi.h
+++ b/drivers/mtd/nand/nand_bcm_umi.h
@@ -167,18 +167,27 @@ static inline void nand_bcm_umi_bch_read_oobEcc(uint32_t pageSize,
int numToRead = 16; /* There are 16 bytes per sector in the OOB */
/* 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) {
- /* skip free oob region */
+ while (numToRead > numEccBytes) {
+ /* skip free oob region */
#if defined(__KERNEL__) && !defined(STANDALONE)
- *oobp++ = REG_NAND_DATA8;
+ *oobp++ = REG_NAND_DATA8;
#else
- REG_NAND_DATA8;
+ REG_NAND_DATA8;
#endif
- numToRead--;
- }
+ numToRead--;
+ }
+ if (pageSize == NAND_DATA_ACCESS_SIZE) {
/* read ECC bytes before BI */
nand_bcm_umi_bch_resume_read_ecc_calc();
@@ -190,6 +199,7 @@ static inline void nand_bcm_umi_bch_read_oobEcc(uint32_t pageSize,
#else
eccCalc[eccPos++] = REG_NAND_DATA8;
#endif
+ numToRead--;
}
nand_bcm_umi_bch_pause_read_ecc_calc();
@@ -204,49 +214,18 @@ static inline void nand_bcm_umi_bch_read_oobEcc(uint32_t pageSize,
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 */
+ }
+ /* read ECC bytes */
+ nand_bcm_umi_bch_resume_read_ecc_calc();
+ while (numToRead) {
#if defined(__KERNEL__) && !defined(STANDALONE)
- *oobp++ = REG_NAND_DATA8;
+ *oobp = REG_NAND_DATA8;
+ eccCalc[eccPos++] = *oobp;
+ oobp++;
#else
- REG_NAND_DATA8;
+ eccCalc[eccPos++] = 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 */
- 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--;
- }
}
}
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] mtd: hot spin and code duplication in nand_bcm_umi_bch_read_oobEcc()
2010-01-22 21:22 [PATCH] mtd: hot spin and code duplication in nand_bcm_umi_bch_read_oobEcc() Roel Kluin
@ 2010-01-22 22:04 ` Leo (Hao) Chen
2010-02-03 16:22 ` Artem Bityutskiy
1 sibling, 0 replies; 3+ messages in thread
From: Leo (Hao) Chen @ 2010-01-22 22:04 UTC (permalink / raw)
To: Roel Kluin; +Cc: Andrew Morton, linux-mtd@lists.infradead.org, LKML
Thanks for identifying the NumToRead bug.
Tested on board. Works.
Acked-by: Leo Chen <leochen@broadcom.com>
On Fri, Jan 22, 2010 at 01:22:52PM -0800, Roel Kluin wrote:
> 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: Roel Kluin <roel.kluin@gmail.com>
> ---
> drivers/mtd/nand/nand_bcm_umi.h | 71 ++++++++++++++-------------------------
> 1 files changed, 25 insertions(+), 46 deletions(-)
>
> diff --git a/drivers/mtd/nand/nand_bcm_umi.h b/drivers/mtd/nand/nand_bcm_umi.h
> index 7cec2cd..198b304 100644
> --- a/drivers/mtd/nand/nand_bcm_umi.h
> +++ b/drivers/mtd/nand/nand_bcm_umi.h
> @@ -167,18 +167,27 @@ static inline void nand_bcm_umi_bch_read_oobEcc(uint32_t pageSize,
> int numToRead = 16; /* There are 16 bytes per sector in the OOB */
>
> /* 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) {
> - /* skip free oob region */
> + while (numToRead > numEccBytes) {
> + /* skip free oob region */
> #if defined(__KERNEL__) && !defined(STANDALONE)
> - *oobp++ = REG_NAND_DATA8;
> + *oobp++ = REG_NAND_DATA8;
> #else
> - REG_NAND_DATA8;
> + REG_NAND_DATA8;
> #endif
> - numToRead--;
> - }
> + numToRead--;
> + }
>
> + if (pageSize == NAND_DATA_ACCESS_SIZE) {
> /* read ECC bytes before BI */
> nand_bcm_umi_bch_resume_read_ecc_calc();
>
> @@ -190,6 +199,7 @@ static inline void nand_bcm_umi_bch_read_oobEcc(uint32_t pageSize,
> #else
> eccCalc[eccPos++] = REG_NAND_DATA8;
> #endif
> + numToRead--;
> }
>
> nand_bcm_umi_bch_pause_read_ecc_calc();
> @@ -204,49 +214,18 @@ static inline void nand_bcm_umi_bch_read_oobEcc(uint32_t pageSize,
> 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 */
> + }
> + /* read ECC bytes */
> + nand_bcm_umi_bch_resume_read_ecc_calc();
> + while (numToRead) {
> #if defined(__KERNEL__) && !defined(STANDALONE)
> - *oobp++ = REG_NAND_DATA8;
> + *oobp = REG_NAND_DATA8;
> + eccCalc[eccPos++] = *oobp;
> + oobp++;
> #else
> - REG_NAND_DATA8;
> + eccCalc[eccPos++] = 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 */
> - 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--;
> - }
> }
> }
>
>
--
Leo Hao Chen
------------------------
Life is short, run long.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] mtd: hot spin and code duplication in nand_bcm_umi_bch_read_oobEcc()
2010-01-22 21:22 [PATCH] mtd: hot spin and code duplication in nand_bcm_umi_bch_read_oobEcc() Roel Kluin
2010-01-22 22:04 ` Leo (Hao) Chen
@ 2010-02-03 16:22 ` Artem Bityutskiy
1 sibling, 0 replies; 3+ messages in thread
From: Artem Bityutskiy @ 2010-02-03 16:22 UTC (permalink / raw)
To: Roel Kluin; +Cc: Andrew Morton, linux-mtd, Leo Chen, LKML
On Fri, 2010-01-22 at 22:22 +0100, Roel Kluin wrote:
> 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: Roel Kluin <roel.kluin@gmail.com>
> ---
> drivers/mtd/nand/nand_bcm_umi.h | 71 ++++++++++++++-------------------------
> 1 files changed, 25 insertions(+), 46 deletions(-)
Taken to l2-mtd-2.6.git / dunno
--
Best Regards,
Artem Bityutskiy (Артём Битюцкий)
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-02-03 16:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-22 21:22 [PATCH] mtd: hot spin and code duplication in nand_bcm_umi_bch_read_oobEcc() Roel Kluin
2010-01-22 22:04 ` Leo (Hao) Chen
2010-02-03 16:22 ` Artem Bityutskiy
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).