: fix omap2.c compile failure and warning
Subsystems (2)
PATCH 1/1 : fix omap2.c compile failure and warning
From: Ming Lei <[email protected]>
drivers/mtd/nand/omap2.c: In function 'omap_wait':drivers/mtd/nand/omap2.c:543: error: 'jiffies' undeclared (first use in this function) drivers/mtd/nand/omap2.c:543: error: (Each undeclared identifier is reported only once drivers/mtd/nand/omap2.c:543: error: for each function it appears in.) drivers/mtd/nand/omap2.c:557: error: implicit declaration of function 'time_before'
......
drivers/mtd/nand/omap2.c: In function 'omap_wait':drivers/mtd/nand/omap2.c:545: warning: 'status' may be used uninitialized in this function
--- drivers/mtd/nand/omap2.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
drivers/mtd/nand/omap2.c +3 -1
@@ -15,6 +15,7 @@#include <linux/mtd/nand.h> #include <linux/mtd/partitions.h> #include <linux/io.h> +#include <linux/jiffies.h> #include <asm/dma.h>
@@ -541,7 +542,8 @@ static int omap_wait(struct mtd_info *mtd, struct nand_chip *chip) struct omap_nand_info *info = container_of(mtd, struct omap_nand_info, mtd);unsigned long timeo = jiffies; -int status, state = this->state; +int state = this->state; +int status =0 ;if (state ==FL_ERASING ) timeo += (HZ *400 ) /1000 ;
Signature · 1 line
1.6.0.GIT
Quoted 7 lines · On Fri, 2009-06-26 at 21:21 +0800, [email protected] wrote:
From: Ming Lei <[email protected]>
drivers/mtd/nand/omap2.c: In function 'omap_wait':drivers/mtd/nand/omap2.c:543: error: 'jiffies' undeclared (first use in this function)drivers/mtd/nand/omap2.c:543: error: (Each undeclared identifier is reported only oncedrivers/mtd/nand/omap2.c:543: error: for each function it appears in.)drivers/mtd/nand/omap2.c:557: error: implicit declaration of function 'time_before'
OK.
Quoted 4 lines
......
drivers/mtd/nand/omap2.c: In function 'omap_wait':drivers/mtd/nand/omap2.c:545: warning: 'status' may be used uninitialized in this function
Hm, why do you set it to zero? In the (fairly unlikely) case where you never go through the loop at all, because you're preempted until the timeout has completed, what value do you want it to return?
Don't just make changes by bashing on the keyboard until the compiler shuts up; please apply brain.
That way, I think you'll notice that the return value from this function is completely screwed anyway.... Vimal? Shouldn't it be returning NAND_STATUS_FAIL in the failure case, not a value read directly from the hardware register? And shouldn't there be a cpu_relax() (or even schedule) in there too?
Quoted 27 lines
Signed-off-by Ming Lei <[email protected]>--- drivers/mtd/nand/omap2.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)drivers/mtd/nand/omap2.c +3
-1@@ -15,6 +15,7 @@#include <linux/mtd/nand.h> #include <linux/mtd/partitions.h> #include <linux/io.h> +#include <linux/jiffies.h> #include <asm/dma.h> @@ -541,7 +542,8 @@ static int omap_wait(struct mtd_info *mtd, struct nand_chip *chip) struct omap_nand_info *info = container_of(mtd, struct omap_nand_info, mtd);unsigned long timeo = jiffies; -int status, state = this->state; +int state = this->state; +int status =0 ;if (state ==FL_ERASING ) timeo += (HZ *400 ) /1000 ;
Signature · 2 lines
David Woodhouse Open Source Technology Centre [email protected] Intel Corporation
Quoted 20 lines · David Woodhouse
Quoted 7 lines · On Fri, 2009-06-26 at 21:21 +0800, [email protected] wrote:
From: Ming Lei <[email protected]>
drivers/mtd/nand/omap2.c: In function 'omap_wait':drivers/mtd/nand/omap2.c:543: error: 'jiffies' undeclared (first use in this function)drivers/mtd/nand/omap2.c:543: error: (Each undeclared identifier is reported only oncedrivers/mtd/nand/omap2.c:543: error: for each function it appears in.)drivers/mtd/nand/omap2.c:557: error: implicit declaration of function 'time_before'OK.
Quoted 4 lines
......
drivers/mtd/nand/omap2.c: In function 'omap_wait':drivers/mtd/nand/omap2.c:545: warning: 'status' may be used uninitialized in this functionHm, why do you set it to zero? In the (fairly unlikely) case where you never go through the loop at all, because you're preempted until the timeout has completed, what value do you want it to return?
Quoted 8 lines
Don't just make changes by bashing on the keyboard until the compiler shuts up; please apply brain.
That way, I think you'll notice that the return value from this function is completely screwed anyway.... Vimal? Shouldn't it be returning
NAND_STATUS_FAILin the failure case, not a value read directly from the hardware register? And shouldn't there be acpu_relax()(or even schedule) in there too?
That's correct David. I think 'cond_resched()' would be fine here.
Quoted 32 lines
Quoted 19 lines
Signed-off-by Ming Lei <[email protected]>--- drivers/mtd/nand/omap2.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)drivers/mtd/nand/omap2.c +1
-0@@ -15,6 +15,7 @@#include <linux/mtd/nand.h> #include <linux/mtd/partitions.h> #include <linux/io.h> +#include <linux/jiffies.h> #include <asm/dma.h> drivers/mtd/nand/omap2.c static int omap_wait(struct mtd_info *mtd, struct nand_chip *chip) · line 549
Quoted 9 lines
drivers/mtd/nand/omap2.c +2
-1@@ -541,7 +542,8 @@ static int omap_wait(struct mtd_info *mtd, struct nand_chip *chip) struct omap_nand_info *info = container_of(mtd, struct omap_nand_info, mtd);unsigned long timeo = jiffies; -int status, state = this->state; +int state = this->state; +int status =0 ;if (state ==FL_ERASING ) timeo += (HZ *400 ) /1000 ;--
David Woodhouse Open Source Technology Centre
[email protected] Intel Corporation
Quoted 5 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
---
Vimal
Quoted 2 lines · Vimal
That's correct David. I think '
cond_resched()' would be fine here.
Got a patch? I have you down as the person responsible for this driver, given that [email protected] is bouncing...
Signature · 2 lines
David Woodhouse Open Source Technology Centre [email protected] Intel Corporation