[U-Boot] Illegal use of FP ops in clock_ti814x.c

Wolfgang Denk wd at denx.de
Tue Oct 29 00:56:19 CET 2013


Dear Måns Rullgård,

In message <yw1xd2mp0yqu.fsf at unicorn.mansr.com> you wrote:
> 
> Something like this should be equivalent.  That said, it looks
> suspiciously like it's meant to simply do a division and round up.  If
> that is the case, +225 should be +249.  It probably makes no difference
> for the values actually encountered.

Umm... this is the part which I do not understand.

The original code adds 90%; you add 90%, too.  However, to round up,
one usually adds only 50% ?

> diff --git a/arch/arm/cpu/armv7/am33xx/clock_ti814x.c b/arch/arm/cpu/armv7/am33xx/clock_ti814x.c
> index ef14f47..9b5a47b 100644
> --- a/arch/arm/cpu/armv7/am33xx/clock_ti814x.c
> +++ b/arch/arm/cpu/armv7/am33xx/clock_ti814x.c
> @@ -211,11 +211,8 @@ static u32 pll_dco_freq_sel(u32 clkout_dco)
>  static u32 pll_sigma_delta_val(u32 clkout_dco)
>  {
>         u32 sig_val = 0;
> -       float frac_div;
>  
> -       frac_div = (float) clkout_dco / 250;
> -       frac_div = frac_div + 0.90;
> -       sig_val = (int)frac_div;
> +       sig_val = (clkout_dco + 225) / 250;
>         sig_val = sig_val << 24;

Where are these 90% coming from? Are they in any way meaningful, or
even critical?

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
I still miss my ex-wife, but my aim is getting better.


More information about the U-Boot mailing list