From 92fda216b439932bf7511e6381bbe1d42ba98875 Mon Sep 17 00:00:00 2001 From: David Wong Date: Thu, 3 Dec 2009 10:57:02 -0300 Subject: V4L/DVB (13541): atbm8830: replace 64-bit division and floating point usage Randy Dunlap wrote: > On Mon, 30 Nov 2009 10:07:21 -0800 Randy Dunlap wrote: > >> Stephen Rothwell wrote: >>> Hi all, >>> >>> Changes since 20091127: >>> >>> The v4l-dvb tree lost its conflict. >> >> on i386 (X86_32): >> >> a 'double' variable is used, causing: >> >> ERROR: "__floatunsidf" [drivers/media/common/tuners/max2165.ko] undefined! >> ERROR: "__adddf3" [drivers/media/common/tuners/max2165.ko] undefined! >> ERROR: "__fixunsdfsi" [drivers/media/common/tuners/max2165.ko] undefined! > > > linux-next-20091202: > > still have this one (above) and similar with > drivers/media/dvb/frontends/atbm8830.c: > > drivers/built-in.o: In function `atbm8830_init': > atbm8830.c:(.text+0x9012f9): undefined reference to `__udivdi3' > atbm8830.c:(.text+0x901384): undefined reference to `__floatunsidf' > atbm8830.c:(.text+0x901395): undefined reference to `__muldf3' > atbm8830.c:(.text+0x9013a5): undefined reference to `__floatunsidf' > atbm8830.c:(.text+0x9013b2): undefined reference to `__divdf3' > atbm8830.c:(.text+0x9013c3): undefined reference to `__muldf3' > atbm8830.c:(.text+0x9013cd): undefined reference to `__fixunsdfsi' > > --- > ~Randy > -- > To unsubscribe from this list: send the line "unsubscribe linux-media" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html This patch replace 64-bit division by do_div() macro and remove usage of floating point variable Signed-off-by: David T. L. Wong Acked-by: Randy Dunlap Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb/frontends/atbm8830.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'drivers/media/dvb/frontends/atbm8830.c') diff --git a/drivers/media/dvb/frontends/atbm8830.c b/drivers/media/dvb/frontends/atbm8830.c index d77684893d99..59881a5944eb 100644 --- a/drivers/media/dvb/frontends/atbm8830.c +++ b/drivers/media/dvb/frontends/atbm8830.c @@ -19,6 +19,7 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include #include "dvb_frontend.h" #include "atbm8830.h" @@ -102,8 +103,12 @@ static inline int atbm8830_reglatch_lock(struct atbm_state *priv, int lock) static int set_osc_freq(struct atbm_state *priv, u32 freq /*in kHz*/) { u32 val; + u64 t; - val = (u64)0x100000 * freq / 30400; + /* 0x100000 * freq / 30.4MHz */ + t = (u64)0x100000 * freq; + do_div(t, 30400); + val = t; atbm8830_write_reg(priv, REG_OSC_CLK, val); atbm8830_write_reg(priv, REG_OSC_CLK + 1, val >> 8); @@ -116,14 +121,18 @@ static int set_if_freq(struct atbm_state *priv, u32 freq /*in kHz*/) { u32 fs = priv->config->osc_clk_freq; - double t; + u64 t; u32 val; u8 dat; - t = 2 * 3.141593 * (freq - fs) / fs * (1 << 22); - val = t; - if (freq != 0) { + /* 2 * PI * (freq - fs) / fs * (2 ^ 22) */ + t = (u64) 2 * 31416 * (freq - fs); + t <<= 22; + do_div(t, fs); + do_div(t, 1000); + val = t; + atbm8830_write_reg(priv, REG_TUNER_BASEBAND, 1); atbm8830_write_reg(priv, REG_IF_FREQ, val); atbm8830_write_reg(priv, REG_IF_FREQ+1, val >> 8); -- cgit v1.2.3