linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH] mtd: fix the wrong timeo for panic_nand_wait()
  2013-01-22  3:11 [PATCH] mtd: fix the wrong timeo for panic_nand_wait() Huang Shijie
@ 2013-01-21 14:27 ` Matthieu CASTET
  2013-01-21 14:54   ` Huang Shijie
  0 siblings, 1 reply; 8+ messages in thread
From: Matthieu CASTET @ 2013-01-21 14:27 UTC (permalink / raw)
  To: Huang Shijie; +Cc: dwmw2, linux-mtd, linux-kernel, dedekind1

Could you explain why the old code was wrong ?

With HZ=100

timeo = jiffies + 2 and it should be working.


Huang Shijie a écrit :
> 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.
> 
> Signed-off-by: Huang Shijie <shijie8@gmail.com>
> ---
>  drivers/mtd/nand/nand_base.c |    8 ++------
>  1 files changed, 2 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
> index 8323ac9..acdd508 100644
> --- a/drivers/mtd/nand/nand_base.c
> +++ b/drivers/mtd/nand/nand_base.c
> @@ -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))

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

* Re: [PATCH] mtd: fix the wrong timeo for panic_nand_wait()
  2013-01-21 14:27 ` Matthieu CASTET
@ 2013-01-21 14:54   ` Huang Shijie
  2013-01-22  1:30     ` [PATCH v2] " Huang Shijie
  0 siblings, 1 reply; 8+ messages in thread
From: Huang Shijie @ 2013-01-21 14:54 UTC (permalink / raw)
  To: Matthieu CASTET; +Cc: dwmw2, linux-mtd, linux-kernel, dedekind1

On Mon, Jan 21, 2013 at 10:27 PM, Matthieu CASTET
<matthieu.castet@parrot.com> wrote:
> Could you explain why the old code was wrong ?


sorry. this patch has a compiler error.


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

>
> Huang Shijie a écrit :
>> 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.
>>
>> Signed-off-by: Huang Shijie <shijie8@gmail.com>
>> ---
>>  drivers/mtd/nand/nand_base.c |    8 ++------
>>  1 files changed, 2 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
>> index 8323ac9..acdd508 100644
>> --- a/drivers/mtd/nand/nand_base.c
>> +++ b/drivers/mtd/nand/nand_base.c
>> @@ -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))

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

* [PATCH v2] mtd: fix the wrong timeo for panic_nand_wait()
  2013-01-21 14:54   ` Huang Shijie
@ 2013-01-22  1:30     ` Huang Shijie
  2013-01-29 21:00       ` Florian Fainelli
  0 siblings, 1 reply; 8+ messages in thread
From: Huang Shijie @ 2013-01-22  1:30 UTC (permalink / raw)
  To: dwmw2; +Cc: dedekind1, matthieu.castet, linux-mtd, linux-kernel, Huang Shijie

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.

Signed-off-by: Huang Shijie <b32955@freescale.com>
---
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(-)

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 8323ac9..a8c1fb4 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -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))
-- 
1.7.0.4



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

* [PATCH] mtd: fix the wrong timeo for panic_nand_wait()
@ 2013-01-22  3:11 Huang Shijie
  2013-01-21 14:27 ` Matthieu CASTET
  0 siblings, 1 reply; 8+ messages in thread
From: Huang Shijie @ 2013-01-22  3:11 UTC (permalink / raw)
  To: dwmw2; +Cc: dedekind1, linux-mtd, linux-kernel, Huang Shijie

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.

Signed-off-by: Huang Shijie <shijie8@gmail.com>
---
 drivers/mtd/nand/nand_base.c |    8 ++------
 1 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 8323ac9..acdd508 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -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))
-- 
1.7.4.4


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

* Re: [PATCH v2] mtd: fix the wrong timeo for panic_nand_wait()
  2013-01-22  1:30     ` [PATCH v2] " Huang Shijie
@ 2013-01-29 21:00       ` Florian Fainelli
  2013-01-30  2:03         ` [PATCH v3] " Huang Shijie
  2013-01-30  2:31         ` [PATCH v2] " Huang Shijie
  0 siblings, 2 replies; 8+ messages in thread
From: Florian Fainelli @ 2013-01-29 21:00 UTC (permalink / raw)
  To: Huang Shijie; +Cc: dwmw2, dedekind1, matthieu.castet, linux-mtd, linux-kernel

Hello Huang,

Le mardi 22 janvier 2013 02:30:30, Huang Shijie a écrit :
> 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.

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.

> 
> Signed-off-by: Huang Shijie <b32955@freescale.com>
> ---
> 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(-)
> 
> diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
> index 8323ac9..a8c1fb4 100644
> --- a/drivers/mtd/nand/nand_base.c
> +++ b/drivers/mtd/nand/nand_base.c
> @@ -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))

-- 
Florian

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

* [PATCH v3] mtd: fix the wrong timeo for panic_nand_wait()
  2013-01-29 21:00       ` Florian Fainelli
@ 2013-01-30  2:03         ` Huang Shijie
  2013-02-04  7:37           ` Artem Bityutskiy
  2013-01-30  2:31         ` [PATCH v2] " Huang Shijie
  1 sibling, 1 reply; 8+ messages in thread
From: Huang Shijie @ 2013-01-30  2:03 UTC (permalink / raw)
  To: dwmw2
  Cc: dedekind1, matthieu.castet, ffainelli, gabriel.matni, linux-mtd,
	linux-kernel, Huang Shijie

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

Signed-off-by: Huang Shijie <b32955@freescale.com>
---
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(-)

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 8323ac9..a8c1fb4 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -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))
-- 
1.7.0.4



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

* Re: [PATCH v2] mtd: fix the wrong timeo for panic_nand_wait()
  2013-01-29 21:00       ` Florian Fainelli
  2013-01-30  2:03         ` [PATCH v3] " Huang Shijie
@ 2013-01-30  2:31         ` Huang Shijie
  1 sibling, 0 replies; 8+ messages in thread
From: Huang Shijie @ 2013-01-30  2:31 UTC (permalink / raw)
  To: Florian Fainelli
  Cc: dwmw2, dedekind1, matthieu.castet, linux-mtd, linux-kernel

于 2013年01月30日 05:00, Florian Fainelli 写道:
> Hello Huang,
>
> Le mardi 22 janvier 2013 02:30:30, Huang Shijie a écrit :
>> 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.
> 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

>> Signed-off-by: Huang Shijie<b32955@freescale.com>
>> ---
>> 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(-)
>>
>> diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
>> index 8323ac9..a8c1fb4 100644
>> --- a/drivers/mtd/nand/nand_base.c
>> +++ b/drivers/mtd/nand/nand_base.c
>> @@ -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))



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

* Re: [PATCH v3] mtd: fix the wrong timeo for panic_nand_wait()
  2013-01-30  2:03         ` [PATCH v3] " Huang Shijie
@ 2013-02-04  7:37           ` Artem Bityutskiy
  0 siblings, 0 replies; 8+ messages in thread
From: Artem Bityutskiy @ 2013-02-04  7:37 UTC (permalink / raw)
  To: Huang Shijie
  Cc: dwmw2, matthieu.castet, ffainelli, gabriel.matni, linux-mtd,
	linux-kernel

[-- Attachment #1: Type: text/plain, Size: 620 bytes --]

On Wed, 2013-01-30 at 10:03 +0800, Huang Shijie wrote:
> The 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.
> 
> Signed-off-by: Huang Shijie <b32955@freescale.com>

Pushed to l2-mtd.git, thanks!

-- 
Best Regards,
Artem Bityutskiy

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

end of thread, other threads:[~2013-02-04  7:36 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-22  3:11 [PATCH] mtd: fix the wrong timeo for panic_nand_wait() Huang Shijie
2013-01-21 14:27 ` Matthieu CASTET
2013-01-21 14:54   ` Huang Shijie
2013-01-22  1:30     ` [PATCH v2] " Huang Shijie
2013-01-29 21:00       ` Florian Fainelli
2013-01-30  2:03         ` [PATCH v3] " Huang Shijie
2013-02-04  7:37           ` Artem Bityutskiy
2013-01-30  2:31         ` [PATCH v2] " Huang Shijie

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