mtd: fix the wrong timeo for panic_nand_wait()
Subsystems (2)
PATCH 1/1 mtd: fix the wrong timeo for panic_nand_wait()
In nand_wait(), the timeo for panic_nand_wait() is assigned with wrong value(jiffies + some delay).
This patch fixes it, and also uses the msecs_to_jiffies() to make the code more readable.
--- drivers/mtd/nand/nand_base.c | 8 ++------ 1 files changed, 2 insertions(+), 6 deletions(-)
drivers/mtd/nand/nand_base.c +2 -6
@@ -825,14 +825,9 @@ static void panic_nand_wait(struct mtd_info *mtd, struct nand_chip *chip,static int nand_wait (struct mtd_info *mtd,struct nand_chip *chip) { -unsigned long timeo = jiffies; +unsigned long timeo = (state ==FL_ERASING ) ?400 :20 ;int status, state = chip->state; -if (state ==FL_ERASING ) - timeo += (HZ *400 ) /1000 ; -else - timeo += (HZ *20 ) /1000 ; -led_trigger_event (nand_led_trigger,LED_FULL );/*
@@ -849,6 +844,7 @@ static int nand_wait(struct mtd_info *mtd, struct nand_chip *chip)if (in_interrupt () || oops_in_progress)panic_nand_wait (mtd, chip, timeo);else { + timeo = jiffies +msecs_to_jiffies (timeo);while (time_before (jiffies, timeo)) {if (chip->dev_ready) {if (chip->dev_ready (mtd))
Signature · 1 line
1.7.4.4
Could you explain why the old code was wrong ?
With HZ=100
timeo = jiffies + 2 and it should be working.
Quoted 39 lines · Huang Shijie
In
nand_wait(), the timeo forpanic_nand_wait()is assigned with wrong value(jiffies + some delay).This patch fixes it, and also uses the
msecs_to_jiffies()to make the code more readable.Signed-off-by Huang Shijie <[email protected]>--- drivers/mtd/nand/nand_base.c | 8 ++------ 1 files changed, 2 insertions(+), 6 deletions(-)drivers/mtd/nand/nand_base.c +2
-6@@ -825,14 +825,9 @@ static void panic_nand_wait(struct mtd_info *mtd, struct nand_chip *chip,static int nand_wait (struct mtd_info *mtd,struct nand_chip *chip) { -unsigned long timeo = jiffies; +unsigned long timeo = (state ==FL_ERASING ) ?400 :20 ;int status, state = chip->state; -if (state ==FL_ERASING ) - timeo += (HZ *400 ) /1000 ; -else - timeo += (HZ *20 ) /1000 ; -led_trigger_event (nand_led_trigger,LED_FULL );/* @@ -849,6 +844,7 @@ static int nand_wait(struct mtd_info *mtd, struct nand_chip *chip)if (in_interrupt () || oops_in_progress)panic_nand_wait (mtd, chip, timeo);else { + timeo = jiffies +msecs_to_jiffies (timeo);while (time_before (jiffies, timeo)) {if (chip->dev_ready) {if (chip->dev_ready (mtd))
Quoted 1 line · Matthieu CASTET
Could you explain why the old code was wrong ?
sorry. this patch has a compiler error.
Quoted 5 lines
With HZ=100
timeo = jiffies + 2 and it should be working.
In logic, timeo should only be 2, just like it does in panic_nand_write().
thanks
Huang Shijie
Quoted 41 lines
Quoted 39 lines · Huang Shijie
In
nand_wait(), the timeo forpanic_nand_wait()is assigned with wrong value(jiffies + some delay).This patch fixes it, and also uses the
msecs_to_jiffies()to make the code more readable.Signed-off-by Huang Shijie <[email protected]>--- drivers/mtd/nand/nand_base.c | 8 ++------ 1 files changed, 2 insertions(+), 6 deletions(-)drivers/mtd/nand/nand_base.c +2
-6@@ -825,14 +825,9 @@ static void panic_nand_wait(struct mtd_info *mtd, struct nand_chip *chip,static int nand_wait (struct mtd_info *mtd,struct nand_chip *chip) { -unsigned long timeo = jiffies; +unsigned long timeo = (state ==FL_ERASING ) ?400 :20 ;int status, state = chip->state; -if (state ==FL_ERASING ) - timeo += (HZ *400 ) /1000 ; -else - timeo += (HZ *20 ) /1000 ; -led_trigger_event (nand_led_trigger,LED_FULL );/* @@ -849,6 +844,7 @@ static int nand_wait(struct mtd_info *mtd, struct nand_chip *chip)if (in_interrupt () || oops_in_progress)panic_nand_wait (mtd, chip, timeo);else { + timeo = jiffies +msecs_to_jiffies (timeo);while (time_before (jiffies, timeo)) {if (chip->dev_ready) {if (chip->dev_ready (mtd))
PATCH v2 1/1 mtd: fix the wrong timeo for panic_nand_wait()
In nand_wait(), the timeo for panic_nand_wait() is assigned with wrong value(jiffies + some delay). The timeo should be set like the panic_nand_write() does.
This patch fixes it, and also uses the msecs_to_jiffies() to make the code more readable.
---
fix the compiler error in version 1, and add some commits.
--- drivers/mtd/nand/nand_base.c | 8 ++------ 1 files changed, 2 insertions(+), 6 deletions(-)
drivers/mtd/nand/nand_base.c +2 -6
@@ -825,13 +825,8 @@ static void panic_nand_wait(struct mtd_info *mtd, struct nand_chip *chip,static int nand_wait (struct mtd_info *mtd,struct nand_chip *chip) { -unsigned long timeo = jiffies;int status, state = chip->state; - -if (state ==FL_ERASING ) - timeo += (HZ *400 ) /1000 ; -else - timeo += (HZ *20 ) /1000 ; +unsigned long timeo = (state ==FL_ERASING ?400 :20 );led_trigger_event (nand_led_trigger,LED_FULL );
@@ -849,6 +844,7 @@ static int nand_wait(struct mtd_info *mtd, struct nand_chip *chip)if (in_interrupt () || oops_in_progress)panic_nand_wait (mtd, chip, timeo);else { + timeo = jiffies +msecs_to_jiffies (timeo);while (time_before (jiffies, timeo)) {if (chip->dev_ready) {if (chip->dev_ready (mtd))
Signature · 1 line
1.7.0.4
Hello Huang,
Quoted 6 lines · Huang Shijie
In
nand_wait(), the timeo forpanic_nand_wait()is assigned with wrong value(jiffies + some delay). The timeo should be set like thepanic_nand_write()does.This patch fixes it, and also uses the
msecs_to_jiffies()to make the code more readable.
You are not exactly explaining what is the issue with the current code, and how you are fixing it. If someone needs to backport this patch for whatever reason, it must be clear as to what it fixes.
Quoted 36 lines
Signed-off-by Huang Shijie <[email protected]>---
fix the compiler error in version 1, and add some commits.--- drivers/mtd/nand/nand_base.c | 8 ++------ 1 files changed, 2 insertions(+), 6 deletions(-)drivers/mtd/nand/nand_base.c +0
-0@@ -825,13 +825,8 @@ static void panic_nand_wait(struct mtd_info *mtd,struct
nand_chip*chip, static intnand_wait(struct mtd_info *mtd, struct nand_chip *chip){drivers/mtd/nand/nand_base.c +2
-6-unsigned long timeo = jiffies;int status, state = chip->state; - -if (state ==FL_ERASING ) - timeo += (HZ *400 ) /1000 ; -else - timeo += (HZ *20 ) /1000 ; +unsigned long timeo = (state ==FL_ERASING ?400 :20 );led_trigger_event (nand_led_trigger,LED_FULL );@@ -849,6 +844,7 @@ static int nand_wait(struct mtd_info *mtd, struct nand_chip *chip) if (in_interrupt() || oops_in_progress)panic_nand_wait (mtd, chip, timeo);else { + timeo = jiffies +msecs_to_jiffies (timeo);while (time_before (jiffies, timeo)) {if (chip->dev_ready) {if (chip->dev_ready (mtd))
Signature · 1 line
Florian
Quoted 7 lines · Florian Fainelli
Hello Huang,
Quoted 4 lines · Huang Shijie
In
nand_wait(), the timeo forpanic_nand_wait()is assigned with wrong value(jiffies + some delay). The timeo should be set like thepanic_nand_write()does.
Quoted 5 lines
Quoted 2 lines
This patch fixes it, and also uses the
msecs_to_jiffies()to make the code more readable.You are not exactly explaining what is the issue with the current code, and how you are fixing it. If someone needs to backport this patch for whatever reason, it must be clear as to what it fixes.
ok, i can add more comments.
thanks for your review.
Best Regards
Huang Shijie
Quoted 35 lines
Quoted 35 lines
Signed-off-by Huang Shijie<[email protected]>---
fix the compiler error in version 1, and add some commits.--- drivers/mtd/nand/nand_base.c | 8 ++------ 1 files changed, 2 insertions(+), 6 deletions(-)drivers/mtd/nand/nand_base.c +0
-0@@ -825,13 +825,8 @@ static void panic_nand_wait(struct mtd_info *mtd,struct
nand_chip*chip, static intnand_wait(struct mtd_info *mtd, struct nand_chip *chip){drivers/mtd/nand/nand_base.c +2
-6-unsigned long timeo = jiffies;int status, state = chip->state; - -if (state ==FL_ERASING ) - timeo += (HZ *400 ) /1000 ; -else - timeo += (HZ *20 ) /1000 ; +unsigned long timeo = (state ==FL_ERASING ?400 :20 );led_trigger_event (nand_led_trigger,LED_FULL );@@ -849,6 +844,7 @@ static int nand_wait(struct mtd_info *mtd, struct nand_chip *chip) if (in_interrupt() || oops_in_progress)panic_nand_wait (mtd, chip, timeo);else { + timeo = jiffies +msecs_to_jiffies (timeo);while (time_before (jiffies, timeo)) {if (chip->dev_ready) {if (chip->dev_ready (mtd))
PATCH v3 1/1 mtd: fix the wrong timeo for panic_nand_wait()
In reply to Florian FainelliThe panic_nand_wait() expects the timeo in ms and not in jiffies. But in nand_wait(), the timeo for panic_nand_wait() is assigned with wrong value(jiffies + some delay). The timeo should be set like the panic_nand_write() does.
This patch passes timeo in ms to panic_nand_wait().
And this patch also passes timeo in jiffies(converted by msecs_to_jiffies) to time_before() which makes the code more readable.
---
v1 --> v2:
fixed a compiler error.
v2 --> v3:
add more comments.
--- drivers/mtd/nand/nand_base.c | 8 ++------ 1 files changed, 2 insertions(+), 6 deletions(-)
drivers/mtd/nand/nand_base.c +2 -6
@@ -825,13 +825,8 @@ static void panic_nand_wait(struct mtd_info *mtd, struct nand_chip *chip,static int nand_wait (struct mtd_info *mtd,struct nand_chip *chip) { -unsigned long timeo = jiffies;int status, state = chip->state; - -if (state ==FL_ERASING ) - timeo += (HZ *400 ) /1000 ; -else - timeo += (HZ *20 ) /1000 ; +unsigned long timeo = (state ==FL_ERASING ?400 :20 );led_trigger_event (nand_led_trigger,LED_FULL );
@@ -849,6 +844,7 @@ static int nand_wait(struct mtd_info *mtd, struct nand_chip *chip)if (in_interrupt () || oops_in_progress)panic_nand_wait (mtd, chip, timeo);else { + timeo = jiffies +msecs_to_jiffies (timeo);while (time_before (jiffies, timeo)) {if (chip->dev_ready) {if (chip->dev_ready (mtd))
Signature · 1 line
1.7.0.4
Artem Bityutskiy
AppliedQuoted 10 lines · Huang Shijie
The
panic_nand_wait()expects the timeo in ms and not in jiffies. But innand_wait(), the timeo forpanic_nand_wait()is assigned with wrong value(jiffies + some delay). The timeo should be set like thepanic_nand_write()does.This patch passes timeo in ms to
panic_nand_wait().
And this patch also passes timeo injiffies(converted by msecs_to_jiffies)totime_before()which makes the code more readable.Signed-off-by Huang Shijie <[email protected]>
Pushed to l2-mtd.git, thanks!
Signature · 2 lines
Best Regards, Artem Bityutskiy