Commit 3f83aa6b authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab

media: tda10021: avoid casts when using symbol_rate

The usage of castings and float point when checking for
the setup based at the symbol_rate cause those warnings
with smatch:

	drivers/media/dvb-frontends/tda10021.c:153 tda10021_set_symbolrate() warn: unsigned 'symbolrate' is never less than zero.
	drivers/media/dvb-frontends/tda10021.c:155 tda10021_set_symbolrate() warn: unsigned 'symbolrate' is never less than zero.
	drivers/media/dvb-frontends/tda10021.c:157 tda10021_set_symbolrate() warn: unsigned 'symbolrate' is never less than zero.
	drivers/media/dvb-frontends/tda10021.c:159 tda10021_set_symbolrate() warn: unsigned 'symbolrate' is never less than zero.

While the code should work with gcc, as it will evaluate the
values into a constant before compiling, other compilers
could do otherwise. So, get rid of float pointing math on it,
avoiding the need of doing typecasts.

While here, cleanup some coding style issues at the related
code.
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent 10f07a6b
......@@ -137,26 +137,36 @@ static int tda10021_set_symbolrate (struct tda10021_state* state, u32 symbolrate
{
s32 BDR;
s32 BDRI;
s16 SFIL=0;
s16 SFIL = 0;
u16 NDEC = 0;
u32 tmp, ratio;
if (symbolrate > XIN/2)
symbolrate = XIN/2;
if (symbolrate < 500000)
if (symbolrate > XIN / 2)
symbolrate = XIN / 2;
else if (symbolrate < 500000)
symbolrate = 500000;
if (symbolrate < XIN/16) NDEC = 1;
if (symbolrate < XIN/32) NDEC = 2;
if (symbolrate < XIN/64) NDEC = 3;
if (symbolrate < (u32)(XIN/12.3)) SFIL = 1;
if (symbolrate < (u32)(XIN/16)) SFIL = 0;
if (symbolrate < (u32)(XIN/24.6)) SFIL = 1;
if (symbolrate < (u32)(XIN/32)) SFIL = 0;
if (symbolrate < (u32)(XIN/49.2)) SFIL = 1;
if (symbolrate < (u32)(XIN/64)) SFIL = 0;
if (symbolrate < (u32)(XIN/98.4)) SFIL = 1;
if (symbolrate < XIN / 16)
NDEC = 1;
if (symbolrate < XIN / 32)
NDEC = 2;
if (symbolrate < XIN / 64)
NDEC = 3;
if (symbolrate < XIN * 10 / 123)
SFIL = 1;
if (symbolrate < XIN * 10 / 160)
SFIL = 0;
if (symbolrate < XIN * 10 / 246)
SFIL = 1;
if (symbolrate < XIN * 10 / 320)
SFIL = 0;
if (symbolrate < XIN * 10 / 492)
SFIL = 1;
if (symbolrate < XIN * 10 / 640)
SFIL = 0;
if (symbolrate < XIN * 10 / 984)
SFIL = 1;
symbolrate <<= NDEC;
ratio = (symbolrate << 4) / FIN;
......
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