Skip to contentSkip to conversation

m88ts2022: fix 32bit overflow on filter calc

PATCH Nibble Max 1 participant 1 message Aug 22, 2014 Media (V4L/DVB)

lore
Share & tools
lore

Nibble Max

author Tested-by
#0 lore raw

It works with the high symbol rate transponders.

Quoted 31 lines

Maximum satellite symbol rate used is 45000000Sps which overflows when multiplied by 135. As final calculation result is fraction, we could use mult_frac macro in order to keep calculation inside 32 bit number limits and prevent overflow.

Original bug and fix was provided by Nibble Max. I decided to implement it differently as it is now.

---
drivers/media/tuners/m88ts2022.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/tuners/m88ts2022.c +1 -1
index 40c42de..7a62097 100644
@@ -314,7 +314,7 @@ static int m88ts2022_set_params(struct dvb_frontend *fe)
 	div_min = gdiv28 * 78 / 100;
 	div_max = clamp_val(div_max, 0U, 63U);
 
-	f_3db_hz = c->symbol_rate * 135UL / 200UL;
+	f_3db_hz = mult_frac(c->symbol_rate, 135, 200);
 	f_3db_hz +=  2000000U + (frequency_offset_khz * 1000U);
 	f_3db_hz = clamp(f_3db_hz, 7000000U, 40000000U);
 
Signature · 1 line
http://palosaari.fi/

BEGIN:VCARD
VERSION:2.1
N:nibble.max;
FN:nibble.max
EMAIL;PREF;INTERNET:[email protected]
REV:20140822T103216Z
END:VCARD