[U-Boot] Illegal use of FP ops in clock_ti814x.c
Måns Rullgård
mans at mansr.com
Tue Oct 29 00:19:53 CET 2013
Wolfgang Denk <wd at denx.de> writes:
> Dear Matt,
>
> I hope you are the right person to address this to - if not, please
> help to redirect to the current responsible developer.
>
> Function pll_sigma_delta_val() in arch/arm/cpu/armv7/am33xx/clock_ti814x.c
> incorrectly uses "float" data, which results in FP operations which
> are not permitted in U-Boot.
>
> The actual computation appears simple enough so a rewrite of the code
> without using any floating point operations should be fairly easy, but
> I don't understand the actual logic of this code, so I'd rather leave
> this to someone who does.
>
> Could you please help and clean up these three lines of code?
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.
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;
return sig_val;
--
Måns Rullgård
mans at mansr.com
More information about the U-Boot
mailing list