From: Antti Palosaari Date: Thu, 10 Jul 2014 11:17:58 +0000 (-0300) Subject: [media] m88ds3103: fix SNR reporting on 32-bit arch X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=3ae266f80cd3684cb78b59ce26af70792ad6994c;p=linux-beck.git [media] m88ds3103: fix SNR reporting on 32-bit arch There was 32-bit calculation overflow. Use div_u64. Signed-off-by: Antti Palosaari Signed-off-by: Mauro Carvalho Chehab --- diff --git a/drivers/media/dvb-frontends/m88ds3103.c b/drivers/media/dvb-frontends/m88ds3103.c index 2ef8ce13fb60..4176edf623a8 100644 --- a/drivers/media/dvb-frontends/m88ds3103.c +++ b/drivers/media/dvb-frontends/m88ds3103.c @@ -879,7 +879,7 @@ static int m88ds3103_read_snr(struct dvb_frontend *fe, u16 *snr) /* SNR(X) dB = 10 * ln(X) / ln(10) dB */ tmp = DIV_ROUND_CLOSEST(tmp, 8 * M88DS3103_SNR_ITERATIONS); if (tmp) - *snr = 100ul * intlog2(tmp) / intlog2(10); + *snr = div_u64((u64) 100 * intlog2(tmp), intlog2(10)); else *snr = 0; break; @@ -908,7 +908,7 @@ static int m88ds3103_read_snr(struct dvb_frontend *fe, u16 *snr) /* SNR(X) dB = 10 * log10(X) dB */ if (signal > noise) { tmp = signal / noise; - *snr = 100ul * intlog10(tmp) / (1 << 24); + *snr = div_u64((u64) 100 * intlog10(tmp), (1 << 24)); } else { *snr = 0; } diff --git a/drivers/media/dvb-frontends/m88ds3103_priv.h b/drivers/media/dvb-frontends/m88ds3103_priv.h index 84c3c06df622..e73db5ccdc74 100644 --- a/drivers/media/dvb-frontends/m88ds3103_priv.h +++ b/drivers/media/dvb-frontends/m88ds3103_priv.h @@ -22,6 +22,7 @@ #include "dvb_math.h" #include #include +#include #define M88DS3103_FIRMWARE "dvb-demod-m88ds3103.fw" #define M88DS3103_MCLK_KHZ 96000