[U-Boot] [RFC] ARM timing code refactoring

Wolfgang Denk wd at denx.de
Sun Jan 23 17:15:24 CET 2011


Dear Albert ARIBAUD,

In message <4D3B568D.3080903 at 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


More information about the U-Boot mailing list