Patchwork mtd: cafe_nand: fix an & vs | mistake

login
register
mail settings
Submitter Dan Carpenter
Date June 9, 2012, 4:08 p.m.
Message ID <20120609160825.GC6488@elgon.mountain>
Download mbox | patch
Permalink /patch/163928/
State New
Headers show

Comments

Dan Carpenter - June 9, 2012, 4:08 p.m.
The intent here was clearly to set result to true if the 0x40000000 flag
was set.  But instead there was a | vs & typo and we always set result
to true.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
I do not have the hardware to test this.  The original code is clearly
buggy, but what about if 0x40000000 is the wrong flag?
Artem Bityutskiy - June 18, 2012, 11:07 a.m.
On Sat, 2012-06-09 at 19:08 +0300, Dan Carpenter wrote:
> The intent here was clearly to set result to true if the 0x40000000 flag
> was set.  But instead there was a | vs & typo and we always set result
> to true.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> I do not have the hardware to test this.  The original code is clearly
> buggy, but what about if 0x40000000 is the wrong flag?

Looks like it is the right flag, I've checked

wiki.laptop.org/images/5/5c/88ALP01_Datasheet_July_2007.pdf

and your patch looks correct.
Artem Bityutskiy - June 18, 2012, 11:25 a.m.
Pushed this patch to l2-mtd.git and added CC to -stable. The patch seems
to be a real bug-fix. Daniel, could you please check it - it will be
shame if it hits -stable and breaks something.

Thanks!

On Sat, 2012-06-09 at 19:08 +0300, Dan Carpenter wrote:
> The intent here was clearly to set result to true if the 0x40000000 flag
> was set.  But instead there was a | vs & typo and we always set result
> to true.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> I do not have the hardware to test this.  The original code is clearly
> buggy, but what about if 0x40000000 is the wrong flag?
> 
> diff --git a/drivers/mtd/nand/cafe_nand.c b/drivers/mtd/nand/cafe_nand.c
> index f3594a6..ac0d967 100644
> --- a/drivers/mtd/nand/cafe_nand.c
> +++ b/drivers/mtd/nand/cafe_nand.c
> @@ -102,7 +102,7 @@ static const char *part_probes[] = { "cmdlinepart", "RedBoot", NULL };
>  static int cafe_device_ready(struct mtd_info *mtd)
>  {
>  	struct cafe_priv *cafe = mtd->priv;
> -	int result = !!(cafe_readl(cafe, NAND_STATUS) | 0x40000000);
> +	int result = !!(cafe_readl(cafe, NAND_STATUS) & 0x40000000);
>  	uint32_t irqs = cafe_readl(cafe, NAND_IRQ);
>  
>  	cafe_writel(cafe, irqs, NAND_IRQ);
> 
> ______________________________________________________
> Linux MTD discussion mailing list
> http://lists.infradead.org/mailman/listinfo/linux-mtd/
Daniel Drake - Aug. 17, 2012, 9:44 p.m.
On Mon, Jun 18, 2012 at 5:25 AM, Artem Bityutskiy
<artem.bityutskiy@linux.intel.com> wrote:
> Pushed this patch to l2-mtd.git and added CC to -stable. The patch seems
> to be a real bug-fix. Daniel, could you please check it - it will be
> shame if it hits -stable and breaks something.

Thanks for catching this, sorry for the delay in looking closely at
it. I double-checked the device specifications and indeed, Dan's
interpretation is correct.

I also tested the patch. System still remains functional and basic
nand performance seems to be the same.

Thanks!
Daniel

Patch

diff --git a/drivers/mtd/nand/cafe_nand.c b/drivers/mtd/nand/cafe_nand.c
index f3594a6..ac0d967 100644
--- a/drivers/mtd/nand/cafe_nand.c
+++ b/drivers/mtd/nand/cafe_nand.c
@@ -102,7 +102,7 @@  static const char *part_probes[] = { "cmdlinepart", "RedBoot", NULL };
 static int cafe_device_ready(struct mtd_info *mtd)
 {
 	struct cafe_priv *cafe = mtd->priv;
-	int result = !!(cafe_readl(cafe, NAND_STATUS) | 0x40000000);
+	int result = !!(cafe_readl(cafe, NAND_STATUS) & 0x40000000);
 	uint32_t irqs = cafe_readl(cafe, NAND_IRQ);
 
 	cafe_writel(cafe, irqs, NAND_IRQ);