[U-Boot] [RFC] ARM timing code refactoring
Wolfgang Denk
wd at denx.de
Mon Jan 24 13:59:01 CET 2011
Dear Reinhard Meyer,
In message <4D3D2F34.6020903 at emk-elektronik.de> you wrote:
> Dear all,
>
> its quite funny to see how we go around in circles here, this proposal of Albert
> now is quite close to my original proposal. Only that I factored the ms_to_ticks
> AND the comparison into the timer calls:
>
> u64 timer_setup(u32 timeout_in_ms)
> {
> return get_ticks() + ms_to_ticks(timeout_in_ms);
> }
No. I said this severaltimes before, and I repeat it here one other
time: I do not want to see such a function. There nothing to be done
to "set up a timer".
> /*
> * convert the unsigned difference to signed, to easyly
> * check for "carry". In assembly we could just do a BCC
> * after the subtraction to see whether get_ticks()
> * has passed ahead of endtime.
> */
> return (signed)(endtime - get_ticks()) < 0;
Are you sure this is really working? Why do you insist on this
approach instead of using the proven to be correct way to write this?
> > u32 start = get_timer(); /* start time, in ticks */
No. I do not see any reason to change existing interfaces.
If ticks are wanted, then use get_ticks(). And deal with the overhead
or 64 bit arithmetics.
But in general code I prefer get_timer() - milliseconds, u32.
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
Substitute "damn" every time you're inclined to write "very"; your
editor will delete it and the writing will be just as it should be.
- Mark Twain
More information about the U-Boot
mailing list