From: Miroslav Sustek Date: Mon, 6 Apr 2009 23:07:04 +0000 (-0300) Subject: V4L/DVB (11441): cx88-dsp: fixing 64bit math X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=7561300a7cea56b61fa28b36d40cdfab22af38bd;p=linux-beck.git V4L/DVB (11441): cx88-dsp: fixing 64bit math cx88-dsp: fixing 64bit math on 32bit kernels Some gcc versions report the missing of __divdi3 [mchehab.redhat.com: CodingStyle fixes] Signed-off-by: Miroslav Sustek Signed-off-by: Mauro Carvalho Chehab --- diff --git a/drivers/media/video/cx88/cx88-dsp.c b/drivers/media/video/cx88/cx88-dsp.c index a78286e853c3..3e5eaf3fe2a6 100644 --- a/drivers/media/video/cx88/cx88-dsp.c +++ b/drivers/media/video/cx88/cx88-dsp.c @@ -22,6 +22,7 @@ #include #include #include +#include #include "cx88.h" #include "cx88-reg.h" @@ -100,13 +101,25 @@ static u32 int_goertzel(s16 x[], u32 N, u32 freq) s32 s_prev2 = 0; s32 coeff = 2*int_cos(freq); u32 i; + + u64 tmp; + u32 divisor; + for (i = 0; i < N; i++) { s32 s = x[i] + ((s64)coeff*s_prev/32768) - s_prev2; s_prev2 = s_prev; s_prev = s; } - return (u32)(((s64)s_prev2*s_prev2 + (s64)s_prev*s_prev - - (s64)coeff*s_prev2*s_prev/32768)/N/N); + + tmp = (s64)s_prev2 * s_prev2 + (s64)s_prev * s_prev - + (s64)coeff * s_prev2 * s_prev / 32768; + + /* XXX: N must be low enough so that N*N fits in s32. + * Else we need two divisions. */ + divisor = N * N; + do_div(tmp, divisor); + + return (u32) tmp; } static u32 freq_magnitude(s16 x[], u32 N, u32 freq)