All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH] m88ts2022: fix 32bit overflow on filter calc
@ 2014-08-22  2:32 Nibble Max
  0 siblings, 0 replies; 2+ messages in thread
From: Nibble Max @ 2014-08-22  2:32 UTC (permalink / raw)
  To: Antti Palosaari; +Cc: linux-media

[-- Attachment #1: Type: text/plain, Size: 1250 bytes --]

It works with the high symbol rate transponders.

Tested-by: Nibble Max <nibble.max@gmail.com>

>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.
>
>Reported-by: Nibble Max <nibble.max@gmail.com>
>Cc: <stable@kernel.org>
>Signed-off-by: Antti Palosaari <crope@iki.fi>
>---
> drivers/media/tuners/m88ts2022.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/drivers/media/tuners/m88ts2022.c b/drivers/media/tuners/m88ts2022.c
>index 40c42de..7a62097 100644
>--- a/drivers/media/tuners/m88ts2022.c
>+++ b/drivers/media/tuners/m88ts2022.c
>@@ -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);
> 
>-- 
>http://palosaari.fi/
>

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: nibble.max(1).vcf --]
[-- Type: text/x-vcard; name="nibble.max(1).vcf", Size: 131 bytes --]

BEGIN:VCARD
VERSION:2.1
N:nibble.max;
FN:nibble.max
EMAIL;PREF;INTERNET:nibble.max@gmail.com
REV:20140822T103216Z
END:VCARD

^ permalink raw reply	[flat|nested] 2+ messages in thread
* [PATCH] m88ts2022: fix 32bit overflow on filter calc
@ 2014-08-21 17:16 Antti Palosaari
  0 siblings, 0 replies; 2+ messages in thread
From: Antti Palosaari @ 2014-08-21 17:16 UTC (permalink / raw)
  To: linux-media; +Cc: Nibble Max, Antti Palosaari

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.

Reported-by: Nibble Max <nibble.max@gmail.com>
Cc: <stable@kernel.org>
Signed-off-by: Antti Palosaari <crope@iki.fi>
---
 drivers/media/tuners/m88ts2022.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/tuners/m88ts2022.c b/drivers/media/tuners/m88ts2022.c
index 40c42de..7a62097 100644
--- a/drivers/media/tuners/m88ts2022.c
+++ b/drivers/media/tuners/m88ts2022.c
@@ -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);
 
-- 
http://palosaari.fi/


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-08-22  2:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-22  2:32 [PATCH] m88ts2022: fix 32bit overflow on filter calc Nibble Max
  -- strict thread matches above, loose matches on Subject: below --
2014-08-21 17:16 Antti Palosaari

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.