From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stefan Roese Date: Tue, 25 Aug 2009 17:39:56 +0200 Subject: [U-Boot] PATCH mtd CFI flash: timeout calculation underflow if imprecise 1kHz timer: fix In-Reply-To: <4A925011.9080906@imagos.it> References: <4A925011.9080906@imagos.it> Message-ID: <200908251739.56181.sr@denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Monday 24 August 2009 10:32:17 Renato Andreola wrote: > From 21d84ab72266f118794233176bd356d8b1cfdf35 Mon Sep 17 00:00:00 2001 > From: Renato Andreola > Date: Fri, 21 Aug 2009 18:05:51 +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. > > Signed-off-by: Alessandro Rubini Renato Andreola > A few mostly formal comments about this patch: - Patch doesn't apply: [stefan at stefan-desktop u-boot-cfi-flash (master)]$ git am -s patches_misc/\[U- Boot\]\ PATCH\ mtd\ CFI\ flash\:\ timeout\ calculation\ underflow\ if\ imprecise\ 1kHz\ timer\:\ fix.mbox Applying: PATCH mtd CFI flash: timeout calculation underflow if imprecise 1kHz timer: fix /home/stefan/git/u-boot/u-boot-cfi-flash/.git/rebase-apply/patch:20: trailing whitespace. #endif error: patch failed: drivers/mtd/cfi_flash.c:660 error: drivers/mtd/cfi_flash.c: patch does not apply Please fix by using "git format-patch" and "git send-email". - Patch subject is mangled: Applying your patch (if possible) would lead to this commit text/subject: "PATCH mtd CFI flash: timeout calculation underflow if imprecise 1kHz timer: fix". This is because your email subject is incorrect (e.g. PATCH should be [PATCH]). And the subject it too long as well. Please use a shorter line here. - Minor coding style problem (see below) > --- > drivers/mtd/cfi_flash.c | 8 +++++--- > 1 files changed, 5 insertions(+), 3 deletions(-) > > diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c > index 81ac5d3..0d8fc54 100644 > --- a/drivers/mtd/cfi_flash.c > +++ b/drivers/mtd/cfi_flash.c > @@ -660,9 +660,11 @@ 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 ((ulong)CONFIG_SYS_HZ > 100000) > + tout *= (ulong)CONFIG_SYS_HZ/1000; /* for a big HZ, avoid overflow */ Please insert spaces before and after the "/" above. > + else > + tout = DIV_ROUND_UP(tout*(ulong)CONFIG_SYS_HZ, 1000); > +#endif > /* Wait for command completion */ > start = get_timer (0); > while (flash_is_busy (info, sector)) { 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