]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commitdiff
[media] m88ds3103: fix SNR reporting on 32-bit arch
authorAntti Palosaari <crope@iki.fi>
Thu, 10 Jul 2014 11:17:58 +0000 (08:17 -0300)
committerMauro Carvalho Chehab <m.chehab@samsung.com>
Wed, 23 Jul 2014 00:28:26 +0000 (21:28 -0300)
There was 32-bit calculation overflow. Use div_u64.

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
drivers/media/dvb-frontends/m88ds3103.c
drivers/media/dvb-frontends/m88ds3103_priv.h

index 2ef8ce13fb602a984063a0845f9d1ce362935231..4176edf623a87b8d0949e452984da3473cc21f4e 100644 (file)
@@ -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;
                }
index 84c3c06df622b072c2185cab0cbab1d7268b7483..e73db5ccdc7473bc4264f11fdf61cb85f559e45a 100644 (file)
@@ -22,6 +22,7 @@
 #include "dvb_math.h"
 #include <linux/firmware.h>
 #include <linux/i2c-mux.h>
+#include <linux/math64.h>
 
 #define M88DS3103_FIRMWARE "dvb-demod-m88ds3103.fw"
 #define M88DS3103_MCLK_KHZ 96000