[U-Boot-Users] [PATCH] 85xx: Round up frequency calculations to get reasonable output
Wolfgang Denk
wd at denx.de
Mon Apr 21 01:28:00 CEST 2008
In message <Pine.LNX.4.64.0804181156410.4255 at blarg.am.freescale.net> you wrote:
> eg. because of rounding error we can get 799Mhz instead of 800Mhz.
>
> Signed-off-by: Dejan Minic <minic at freescale.com>
> Signed-off-by: Srikanth Srinivasan <srikanth.srinivasan at freescale.com>
> Signed-off-by: Kumar Gala <galak at kernel.crashing.org>
> ---
> cpu/mpc85xx/cpu.c | 18 +++++++++++-------
> 1 files changed, 11 insertions(+), 7 deletions(-)
>
> diff --git a/cpu/mpc85xx/cpu.c b/cpu/mpc85xx/cpu.c
> index dcd8817..6972bb1 100644
> --- a/cpu/mpc85xx/cpu.c
> +++ b/cpu/mpc85xx/cpu.c
> @@ -65,6 +65,11 @@ struct cpu_type cpu_type_list [] = {
> CPU_TYPE_ENTRY(8572_E),
> };
>
> +static inline unsigned long integer_round (unsigned long val, unsigned long div)
> +{
> + return ((val + (div/2)) / div);
> +}
> +
As already mentioned, "integer_round" is not a good name for this.
Also, it seems this should not live in cpu/mpc85xx/cpu.c but in a
more central place and be used by lots of other code as well.
Actually you might want to make it a macro to allow for different
data types as well.
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
When properly administered, vacations do not diminish productivity:
for every week you're away and get nothing done, there's another when
your boss is away and you get twice as much done. -- Daniel B. Luten
More information about the U-Boot
mailing list