Commit 3ae266f8 authored by Antti Palosaari's avatar Antti Palosaari Committed by Mauro Carvalho Chehab

[media] m88ds3103: fix SNR reporting on 32-bit arch

There was 32-bit calculation overflow. Use div_u64.
Signed-off-by: default avatarAntti Palosaari <crope@iki.fi>
Signed-off-by: default avatarMauro Carvalho Chehab <m.chehab@samsung.com>
parent 5cb4e227
...@@ -879,7 +879,7 @@ static int m88ds3103_read_snr(struct dvb_frontend *fe, u16 *snr) ...@@ -879,7 +879,7 @@ static int m88ds3103_read_snr(struct dvb_frontend *fe, u16 *snr)
/* SNR(X) dB = 10 * ln(X) / ln(10) dB */ /* SNR(X) dB = 10 * ln(X) / ln(10) dB */
tmp = DIV_ROUND_CLOSEST(tmp, 8 * M88DS3103_SNR_ITERATIONS); tmp = DIV_ROUND_CLOSEST(tmp, 8 * M88DS3103_SNR_ITERATIONS);
if (tmp) if (tmp)
*snr = 100ul * intlog2(tmp) / intlog2(10); *snr = div_u64((u64) 100 * intlog2(tmp), intlog2(10));
else else
*snr = 0; *snr = 0;
break; break;
...@@ -908,7 +908,7 @@ static int m88ds3103_read_snr(struct dvb_frontend *fe, u16 *snr) ...@@ -908,7 +908,7 @@ static int m88ds3103_read_snr(struct dvb_frontend *fe, u16 *snr)
/* SNR(X) dB = 10 * log10(X) dB */ /* SNR(X) dB = 10 * log10(X) dB */
if (signal > noise) { if (signal > noise) {
tmp = signal / noise; tmp = signal / noise;
*snr = 100ul * intlog10(tmp) / (1 << 24); *snr = div_u64((u64) 100 * intlog10(tmp), (1 << 24));
} else { } else {
*snr = 0; *snr = 0;
} }
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "dvb_math.h" #include "dvb_math.h"
#include <linux/firmware.h> #include <linux/firmware.h>
#include <linux/i2c-mux.h> #include <linux/i2c-mux.h>
#include <linux/math64.h>
#define M88DS3103_FIRMWARE "dvb-demod-m88ds3103.fw" #define M88DS3103_FIRMWARE "dvb-demod-m88ds3103.fw"
#define M88DS3103_MCLK_KHZ 96000 #define M88DS3103_MCLK_KHZ 96000
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment