public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v2] cfi_flash: precision and underflow problem in tout calculation
@ 2010-03-24  0:55 Thomas Chou
  2010-03-24 13:46 ` Stefan Roese
  2010-03-24 15:00 ` [U-Boot] [PATCH v3] " Thomas Chou
  0 siblings, 2 replies; 5+ messages in thread
From: Thomas Chou @ 2010-03-24  0:55 UTC (permalink / raw)
  To: u-boot

From: Renato Andreola <renato.andreola@imagos.it>

With old configuration it could happen tout=0 if CONFIG_SYS_HZ<1000.

Signed-off-by: Alessandro Rubini <rubini@gnudd.com>
Signed-off-by: Renato Andreola <renato.andreola@imagos.it>
---
 drivers/mtd/cfi_flash.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c
index fdba297..cd1a86e 100644
--- a/drivers/mtd/cfi_flash.c
+++ b/drivers/mtd/cfi_flash.c
@@ -537,7 +537,10 @@ static int flash_status_check (flash_info_t * info, flash_sect_t sector,
 	ulong start;
 
 #if CONFIG_SYS_HZ != 1000
-	tout *= CONFIG_SYS_HZ/1000;
+	if ((ulong)CONFIG_SYS_HZ > 100000)
+		tout *= (ulong)CONFIG_SYS_HZ / 1000;  /* for a big HZ, avoid overflow */
+	else
+		tout = DIV_ROUND_UP(tout * (ulong)CONFIG_SYS_HZ, 1000);
 #endif
 
 	/* Wait for command completion */
-- 
1.6.6.1

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

* [U-Boot] [PATCH v2] cfi_flash: precision and underflow problem in tout calculation
  2010-03-24  0:55 [U-Boot] [PATCH v2] cfi_flash: precision and underflow problem in tout calculation Thomas Chou
@ 2010-03-24 13:46 ` Stefan Roese
  2010-03-24 15:02   ` Thomas Chou
  2010-03-24 15:00 ` [U-Boot] [PATCH v3] " Thomas Chou
  1 sibling, 1 reply; 5+ messages in thread
From: Stefan Roese @ 2010-03-24 13:46 UTC (permalink / raw)
  To: u-boot

Hi Thomas,

On Wednesday 24 March 2010 01:55:28 Thomas Chou wrote:
> From: Renato Andreola <renato.andreola@imagos.it>
> 
> With old configuration it could happen tout=0 if CONFIG_SYS_HZ<1000.
> 
> Signed-off-by: Alessandro Rubini <rubini@gnudd.com>
> Signed-off-by: Renato Andreola <renato.andreola@imagos.it>

Sorry for nitpicking again, but you need to add your S-o-b line as well? The 
order should be

Signed-off-by: Renato Andreola <renato.andreola@imagos.it>
Signed-off-by: Alessandro Rubini <rubini@gnudd.com>
Signed-off-by: Thomas Chou <thomas@wytron.com.tw>

since Renato is the original author.

Thanks.

Cheers,
Stefan

--
DENX Software Engineering GmbH,      MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich,  Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-0 Fax: (+49)-8142-66989-80 Email: office at denx.de

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

* [U-Boot] [PATCH v3] cfi_flash: precision and underflow problem in tout calculation
  2010-03-24  0:55 [U-Boot] [PATCH v2] cfi_flash: precision and underflow problem in tout calculation Thomas Chou
  2010-03-24 13:46 ` Stefan Roese
@ 2010-03-24 15:00 ` Thomas Chou
  2010-03-25  8:46   ` Stefan Roese
  1 sibling, 1 reply; 5+ messages in thread
From: Thomas Chou @ 2010-03-24 15:00 UTC (permalink / raw)
  To: u-boot

From: Renato Andreola <renato.andreola@imagos.it>

With old configuration it could happen tout=0 if CONFIG_SYS_HZ<1000.

Signed-off-by: Renato Andreola <renato.andreola@imagos.it>
Signed-off-by: Alessandro Rubini <rubini@gnudd.com>
Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
---
 drivers/mtd/cfi_flash.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c
index fdba297..cd1a86e 100644
--- a/drivers/mtd/cfi_flash.c
+++ b/drivers/mtd/cfi_flash.c
@@ -537,7 +537,10 @@ static int flash_status_check (flash_info_t * info, flash_sect_t sector,
 	ulong start;
 
 #if CONFIG_SYS_HZ != 1000
-	tout *= CONFIG_SYS_HZ/1000;
+	if ((ulong)CONFIG_SYS_HZ > 100000)
+		tout *= (ulong)CONFIG_SYS_HZ / 1000;  /* for a big HZ, avoid overflow */
+	else
+		tout = DIV_ROUND_UP(tout * (ulong)CONFIG_SYS_HZ, 1000);
 #endif
 
 	/* Wait for command completion */
-- 
1.6.6.1

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

* [U-Boot] [PATCH v2] cfi_flash: precision and underflow problem in tout calculation
  2010-03-24 13:46 ` Stefan Roese
@ 2010-03-24 15:02   ` Thomas Chou
  0 siblings, 0 replies; 5+ messages in thread
From: Thomas Chou @ 2010-03-24 15:02 UTC (permalink / raw)
  To: u-boot

On 03/24/2010 09:46 PM, Stefan Roese wrote:
> Hi Thomas,
>
> On Wednesday 24 March 2010 01:55:28 Thomas Chou wrote:
>    
>> From: Renato Andreola<renato.andreola@imagos.it>
>>
>> With old configuration it could happen tout=0 if CONFIG_SYS_HZ<1000.
>>
>> Signed-off-by: Alessandro Rubini<rubini@gnudd.com>
>> Signed-off-by: Renato Andreola<renato.andreola@imagos.it>
>>      
> Sorry for nitpicking again, but you need to add your S-o-b line as well? The
> order should be
>
> Signed-off-by: Renato Andreola<renato.andreola@imagos.it>
> Signed-off-by: Alessandro Rubini<rubini@gnudd.com>
> Signed-off-by: Thomas Chou<thomas@wytron.com.tw>
>
> since Renato is the original author.
>    
Hi Stefan,

No problem. Please review again.

Best regards,
Thomas

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

* [U-Boot] [PATCH v3] cfi_flash: precision and underflow problem in tout calculation
  2010-03-24 15:00 ` [U-Boot] [PATCH v3] " Thomas Chou
@ 2010-03-25  8:46   ` Stefan Roese
  0 siblings, 0 replies; 5+ messages in thread
From: Stefan Roese @ 2010-03-25  8:46 UTC (permalink / raw)
  To: u-boot

On Wednesday 24 March 2010 16:00:47 Thomas Chou wrote:
> From: Renato Andreola <renato.andreola@imagos.it>
> 
> With old configuration it could happen tout=0 if CONFIG_SYS_HZ<1000.

Applied to u-boot-cfi-flash/master. Thanks.
 
Cheers,
Stefan

--
DENX Software Engineering GmbH,      MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich,  Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-0 Fax: (+49)-8142-66989-80 Email: office@denx.de

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

end of thread, other threads:[~2010-03-25  8:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-24  0:55 [U-Boot] [PATCH v2] cfi_flash: precision and underflow problem in tout calculation Thomas Chou
2010-03-24 13:46 ` Stefan Roese
2010-03-24 15:02   ` Thomas Chou
2010-03-24 15:00 ` [U-Boot] [PATCH v3] " Thomas Chou
2010-03-25  8:46   ` Stefan Roese

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox