Dear Renato Andreola, In message <4a7ad624.9030...@imagos.it> you wrote: > From 3723c8437d8c3d2e04bc3bc1de9c21b33072ab08 Mon Sep 17 00:00:00 2001 > From: Renato Andreola <renato.andre...@imagos.it> > Date: Thu, 6 Aug 2009 14:49:59 +0200 > Subject: [PATCH] drivers/mtd/cfi_flash: precision and underflow problem > in tout calculation > > With old configuration it could happen tout=0 if CONFIG_SYS_HZ<1000 > solved avoiding the preprocessor conditional and introducing a compile > time branch between a high freq case and a slow freq case. > > Signed-off-by: Renato Andreola renato.andre...@imagos.it > --- > drivers/mtd/cfi_flash.c | 7 ++++--- > 1 files changed, 4 insertions(+), 3 deletions(-) > > diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c > index 81ac5d3..b118f71 100644 > --- a/drivers/mtd/cfi_flash.c > +++ b/drivers/mtd/cfi_flash.c > @@ -659,9 +659,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; > -#endif > + if (CONFIG_SYS_HZ > 10000) > + tout *= CONFIG_SYS_HZ/1000; /* for a big HZ, avoid > overflow */ > + else > + tout = tout * CONFIG_SYS_HZ / 1000 + 1;
NAK, for several reasons: 1) The patch is line wrapped and thus unusable. 2) There should be a Signed-off-by: from Alessandro, too. 3) Please use TAB only for indentation. 4) Please use parens to show what you are relying on, i. e. tout = (tout * CONFIG_SYS_HZ) / 1000; 5) Omit the "+1". It seems bogus to me. Best regards, Wolfgang Denk -- DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de Digital computers are themselves more complex than most things people build: They have very large numbers of states. This makes conceiving, describing, and testing them hard. Software systems have orders-of- magnitude more states than computers do. - Fred Brooks, Jr. _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot