From: Wolfgang Denk Date: Sun, 23 Jan 2011 17:15:24 +0100 Subject: [U-Boot] [RFC] ARM timing code refactoring In-Reply-To: <4D3B568D.3080903@free.fr> References: <4D3AAF63.1030600@free.fr> <20110122191928.49E141365DB@gemini.denx.de> <4D3B3B5C.2060205@free.fr> <20110122212601.9C8A2B187@gemini.denx.de> <4D3B568D.3080903@free.fr> Message-ID: <20110123161524.DF590B335@gemini.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 Dear Albert ARIBAUD, In message <4D3B568D.3080903@free.fr> you wrote: > > > You see the problem? > > Actually no, I don't. As a reminder, I am considering the following > definitions: > > #define time(n) (ticks-n) > #define ms_to_ticks(ms) (ms * fast_tick_rate) / CONFIG_SYS_HZ Ah, I see. Well, I have to admit that I did not see this part; but then, it is still similar to what the current get_timer(t) call is doing (at least in it's reference implementation on PowerPC, cf. arch/powerpc/lib/interrupts.c), except that no set_timer(t) is provided. In acy case - I vote to get rid of this funktion to set some "time base value", and provide a plain void call interface to get_timer() [or whatever the corresponding function would be called]. Also, I vote to always explicitly write the timeout loop as I gave in the example, because this makes the meachnism clear to the reader of the code - hiding it in macros or functions may only lead to conusions or different (and broken) implementations across architectures. > Neither of these has any side effect, so I am at loss as to why that > would break when used in nested loops; each loop has its own reference My reading was that "time(0)" would perform some reset of a variable to give a wrap-around free starting point. Sorry for not reading all of the previous context. > start time by assigning time(0) to its own variable (then and > then_nested), and each has its own elapsed time computation by passing > its own variable to time() and comparing with its own constant timeout I don't see any use of the extra argument to the time() function / macro, nor any need / use for such a function / macro at all. 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: wd at denx.de "Faith: not *wanting* to know what is true." - Friedrich Nietzsche