linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mtd: nand: omap: conditions with no effect
@ 2015-02-04  9:27 Nicholas Mc Guire
  2015-02-04 11:17 ` Roger Quadros
  0 siblings, 1 reply; 3+ messages in thread
From: Nicholas Mc Guire @ 2015-02-04  9:27 UTC (permalink / raw)
  To: David Woodhouse
  Cc: Brian Norris, pekon gupta, Roger Quadros, Ezequiel Garcia,
	Tony Lindgren, Rostislav Lisovy, linux-mtd, linux-kernel,
	Nicholas Mc Guire

The if and the else branch code are identical - so the condition has no
effect on the effective code - this patch removes the condition and the
duplicated code.

Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
---

The conditions in the OMAP_ECC_BCH8_CODE_HW_DETECTION_SW and
OMAP_ECC_BCH4_CODE_HW_DETECTION_SW case have no effect and can
be removed. As there are no comments it is not possible to say
if this is the correct solution or if this is actually a bug and
the two branches should be different.

This patch needs a review by someone who knows the details of the driver

Patch was only compile tested with arm-linux-gnueabi-4.7-, current
crosstool-ng did no not seem to compile omap2 properly.
Config is omap2plus_defconfig which implies CONFIG_MTD_NAND_OMAP2=y.

Patch is against 3.19.0-rc6 (localversion-next is -next-20150203)

 drivers/mtd/nand/omap2.c |   24 ++++++------------------
 1 file changed, 6 insertions(+), 18 deletions(-)

diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index 63f858e..5bcdd66 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -1071,15 +1071,9 @@ static void __maybe_unused omap_enable_hwecc_bch(struct mtd_info *mtd, int mode)
 	case OMAP_ECC_BCH4_CODE_HW_DETECTION_SW:
 		bch_type = 0;
 		nsectors = 1;
-		if (mode == NAND_ECC_READ) {
-			wr_mode	  = BCH_WRAPMODE_6;
-			ecc_size0 = BCH_ECC_SIZE0;
-			ecc_size1 = BCH_ECC_SIZE1;
-		} else {
-			wr_mode   = BCH_WRAPMODE_6;
-			ecc_size0 = BCH_ECC_SIZE0;
-			ecc_size1 = BCH_ECC_SIZE1;
-		}
+		wr_mode	  = BCH_WRAPMODE_6;
+		ecc_size0 = BCH_ECC_SIZE0;
+		ecc_size1 = BCH_ECC_SIZE1;
 		break;
 	case OMAP_ECC_BCH4_CODE_HW:
 		bch_type = 0;
@@ -1097,15 +1091,9 @@ static void __maybe_unused omap_enable_hwecc_bch(struct mtd_info *mtd, int mode)
 	case OMAP_ECC_BCH8_CODE_HW_DETECTION_SW:
 		bch_type = 1;
 		nsectors = 1;
-		if (mode == NAND_ECC_READ) {
-			wr_mode	  = BCH_WRAPMODE_6;
-			ecc_size0 = BCH_ECC_SIZE0;
-			ecc_size1 = BCH_ECC_SIZE1;
-		} else {
-			wr_mode   = BCH_WRAPMODE_6;
-			ecc_size0 = BCH_ECC_SIZE0;
-			ecc_size1 = BCH_ECC_SIZE1;
-		}
+		wr_mode	  = BCH_WRAPMODE_6;
+		ecc_size0 = BCH_ECC_SIZE0;
+		ecc_size1 = BCH_ECC_SIZE1;
 		break;
 	case OMAP_ECC_BCH8_CODE_HW:
 		bch_type = 1;
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] mtd: nand: omap: conditions with no effect
  2015-02-04  9:27 [PATCH] mtd: nand: omap: conditions with no effect Nicholas Mc Guire
@ 2015-02-04 11:17 ` Roger Quadros
  2015-02-04 11:42   ` Nicholas Mc Guire
  0 siblings, 1 reply; 3+ messages in thread
From: Roger Quadros @ 2015-02-04 11:17 UTC (permalink / raw)
  To: Nicholas Mc Guire, Brian Norris
  Cc: David Woodhouse, Ezequiel Garcia, Tony Lindgren,
	Rostislav Lisovy, linux-mtd, linux-kernel, pekon

Nicholas,

On 04/02/15 11:27, Nicholas Mc Guire wrote:
> The if and the else branch code are identical - so the condition has no
> effect on the effective code - this patch removes the condition and the
> duplicated code.
> 
> Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
> ---
> 
> The conditions in the OMAP_ECC_BCH8_CODE_HW_DETECTION_SW and
> OMAP_ECC_BCH4_CODE_HW_DETECTION_SW case have no effect and can
> be removed. As there are no comments it is not possible to say
> if this is the correct solution or if this is actually a bug and
> the two branches should be different.
> 
> This patch needs a review by someone who knows the details of the driver
> 
> Patch was only compile tested with arm-linux-gnueabi-4.7-, current
> crosstool-ng did no not seem to compile omap2 properly.
> Config is omap2plus_defconfig which implies CONFIG_MTD_NAND_OMAP2=y.
> 
> Patch is against 3.19.0-rc6 (localversion-next is -next-20150203)
> 
>  drivers/mtd/nand/omap2.c |   24 ++++++------------------
>  1 file changed, 6 insertions(+), 18 deletions(-)

Your patch is correct as far as I can tell based on commits 2ef9f3ddec55, 62116e5171e0
and 8d602cf50d3b.

The idea was to use BCH_WRAPMODE_6 for both reads and writes when we're not using the ELM
module for error correction. i.e. BCH4_SW or BCH8_SW.
This is mentioned in the header of omap_enable_hwecc_bch() but it is not very clear.
So let's fix that as well with this patch.

diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index 63f858e..a133780 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -1048,10 +1048,9 @@ static int omap_dev_ready(struct mtd_info *mtd)
  * @mtd: MTD device structure
  * @mode: Read/Write mode
  *
- * When using BCH, sector size is hardcoded to 512 bytes.
- * Using wrapping mode 6 both for reading and writing if ELM module not uses
- * for error correction.
- * On writing,
+ * When using BCH with SW correction (i.e. no ELM), sector size is set
+ * to 512 bytes and we use BCH_WRAPMODE_6 wrapping mode
+ * for both reading and writing with:
  * eccsize0 = 0  (no additional protected byte in spare area)
  * eccsize1 = 32 (skip 32 nibbles = 16 bytes per sector in spare area)
  */

Then you can also add my

Acked-by: Roger Quadros <rogerq@ti.com>

cheers,
-roger

> 
> diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
> index 63f858e..5bcdd66 100644
> --- a/drivers/mtd/nand/omap2.c
> +++ b/drivers/mtd/nand/omap2.c
> @@ -1071,15 +1071,9 @@ static void __maybe_unused omap_enable_hwecc_bch(struct mtd_info *mtd, int mode)
>  	case OMAP_ECC_BCH4_CODE_HW_DETECTION_SW:
>  		bch_type = 0;
>  		nsectors = 1;
> -		if (mode == NAND_ECC_READ) {
> -			wr_mode	  = BCH_WRAPMODE_6;
> -			ecc_size0 = BCH_ECC_SIZE0;
> -			ecc_size1 = BCH_ECC_SIZE1;
> -		} else {
> -			wr_mode   = BCH_WRAPMODE_6;
> -			ecc_size0 = BCH_ECC_SIZE0;
> -			ecc_size1 = BCH_ECC_SIZE1;
> -		}
> +		wr_mode	  = BCH_WRAPMODE_6;
> +		ecc_size0 = BCH_ECC_SIZE0;
> +		ecc_size1 = BCH_ECC_SIZE1;
>  		break;
>  	case OMAP_ECC_BCH4_CODE_HW:
>  		bch_type = 0;
> @@ -1097,15 +1091,9 @@ static void __maybe_unused omap_enable_hwecc_bch(struct mtd_info *mtd, int mode)
>  	case OMAP_ECC_BCH8_CODE_HW_DETECTION_SW:
>  		bch_type = 1;
>  		nsectors = 1;
> -		if (mode == NAND_ECC_READ) {
> -			wr_mode	  = BCH_WRAPMODE_6;
> -			ecc_size0 = BCH_ECC_SIZE0;
> -			ecc_size1 = BCH_ECC_SIZE1;
> -		} else {
> -			wr_mode   = BCH_WRAPMODE_6;
> -			ecc_size0 = BCH_ECC_SIZE0;
> -			ecc_size1 = BCH_ECC_SIZE1;
> -		}
> +		wr_mode	  = BCH_WRAPMODE_6;
> +		ecc_size0 = BCH_ECC_SIZE0;
> +		ecc_size1 = BCH_ECC_SIZE1;
>  		break;
>  	case OMAP_ECC_BCH8_CODE_HW:
>  		bch_type = 1;
> 


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] mtd: nand: omap: conditions with no effect
  2015-02-04 11:17 ` Roger Quadros
@ 2015-02-04 11:42   ` Nicholas Mc Guire
  0 siblings, 0 replies; 3+ messages in thread
From: Nicholas Mc Guire @ 2015-02-04 11:42 UTC (permalink / raw)
  To: Roger Quadros
  Cc: Nicholas Mc Guire, Brian Norris, David Woodhouse,
	Ezequiel Garcia, Tony Lindgren, Rostislav Lisovy, linux-mtd,
	linux-kernel, pekon

On Wed, 04 Feb 2015, Roger Quadros wrote:

> Nicholas,
> 
> On 04/02/15 11:27, Nicholas Mc Guire wrote:
> > The if and the else branch code are identical - so the condition has no
> > effect on the effective code - this patch removes the condition and the
> > duplicated code.
> > 
> > Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
> > ---
> > 
> > The conditions in the OMAP_ECC_BCH8_CODE_HW_DETECTION_SW and
> > OMAP_ECC_BCH4_CODE_HW_DETECTION_SW case have no effect and can
> > be removed. As there are no comments it is not possible to say
> > if this is the correct solution or if this is actually a bug and
> > the two branches should be different.
> > 
> > This patch needs a review by someone who knows the details of the driver
> > 
> > Patch was only compile tested with arm-linux-gnueabi-4.7-, current
> > crosstool-ng did no not seem to compile omap2 properly.
> > Config is omap2plus_defconfig which implies CONFIG_MTD_NAND_OMAP2=y.
> > 
> > Patch is against 3.19.0-rc6 (localversion-next is -next-20150203)
> > 
> >  drivers/mtd/nand/omap2.c |   24 ++++++------------------
> >  1 file changed, 6 insertions(+), 18 deletions(-)
> 
> Your patch is correct as far as I can tell based on commits 2ef9f3ddec55, 62116e5171e0
> and 8d602cf50d3b.
> 
> The idea was to use BCH_WRAPMODE_6 for both reads and writes when we're not using the ELM
> module for error correction. i.e. BCH4_SW or BCH8_SW.
> This is mentioned in the header of omap_enable_hwecc_bch() but it is not very clear.
> So let's fix that as well with this patch.
> 
> diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
> index 63f858e..a133780 100644
> --- a/drivers/mtd/nand/omap2.c
> +++ b/drivers/mtd/nand/omap2.c
> @@ -1048,10 +1048,9 @@ static int omap_dev_ready(struct mtd_info *mtd)
>   * @mtd: MTD device structure
>   * @mode: Read/Write mode
>   *
> - * When using BCH, sector size is hardcoded to 512 bytes.
> - * Using wrapping mode 6 both for reading and writing if ELM module not uses
> - * for error correction.
> - * On writing,
> + * When using BCH with SW correction (i.e. no ELM), sector size is set
> + * to 512 bytes and we use BCH_WRAPMODE_6 wrapping mode
> + * for both reading and writing with:
>   * eccsize0 = 0  (no additional protected byte in spare area)
>   * eccsize1 = 32 (skip 32 nibbles = 16 bytes per sector in spare area)
>   */
> 
> Then you can also add my
> 
> Acked-by: Roger Quadros <rogerq@ti.com>
>

thanks for the clarification !

will merge this and repost 

thx!
hofrat

 
> 
> > 
> > diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
> > index 63f858e..5bcdd66 100644
> > --- a/drivers/mtd/nand/omap2.c
> > +++ b/drivers/mtd/nand/omap2.c
> > @@ -1071,15 +1071,9 @@ static void __maybe_unused omap_enable_hwecc_bch(struct mtd_info *mtd, int mode)
> >  	case OMAP_ECC_BCH4_CODE_HW_DETECTION_SW:
> >  		bch_type = 0;
> >  		nsectors = 1;
> > -		if (mode == NAND_ECC_READ) {
> > -			wr_mode	  = BCH_WRAPMODE_6;
> > -			ecc_size0 = BCH_ECC_SIZE0;
> > -			ecc_size1 = BCH_ECC_SIZE1;
> > -		} else {
> > -			wr_mode   = BCH_WRAPMODE_6;
> > -			ecc_size0 = BCH_ECC_SIZE0;
> > -			ecc_size1 = BCH_ECC_SIZE1;
> > -		}
> > +		wr_mode	  = BCH_WRAPMODE_6;
> > +		ecc_size0 = BCH_ECC_SIZE0;
> > +		ecc_size1 = BCH_ECC_SIZE1;
> >  		break;
> >  	case OMAP_ECC_BCH4_CODE_HW:
> >  		bch_type = 0;
> > @@ -1097,15 +1091,9 @@ static void __maybe_unused omap_enable_hwecc_bch(struct mtd_info *mtd, int mode)
> >  	case OMAP_ECC_BCH8_CODE_HW_DETECTION_SW:
> >  		bch_type = 1;
> >  		nsectors = 1;
> > -		if (mode == NAND_ECC_READ) {
> > -			wr_mode	  = BCH_WRAPMODE_6;
> > -			ecc_size0 = BCH_ECC_SIZE0;
> > -			ecc_size1 = BCH_ECC_SIZE1;
> > -		} else {
> > -			wr_mode   = BCH_WRAPMODE_6;
> > -			ecc_size0 = BCH_ECC_SIZE0;
> > -			ecc_size1 = BCH_ECC_SIZE1;
> > -		}
> > +		wr_mode	  = BCH_WRAPMODE_6;
> > +		ecc_size0 = BCH_ECC_SIZE0;
> > +		ecc_size1 = BCH_ECC_SIZE1;
> >  		break;
> >  	case OMAP_ECC_BCH8_CODE_HW:
> >  		bch_type = 1;
> > 
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-02-04 11:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-04  9:27 [PATCH] mtd: nand: omap: conditions with no effect Nicholas Mc Guire
2015-02-04 11:17 ` Roger Quadros
2015-02-04 11:42   ` Nicholas Mc Guire

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).