summaryrefslogtreecommitdiff
path: root/drivers/media/dvb-frontends/lgdt3306a.c
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@osg.samsung.com>2014-10-28 12:30:44 -0200
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2015-03-03 10:34:14 -0300
commit9369fe012d06c4a8775984609bc068e85bfeec8f (patch)
tree7a5591aafc6dedba6e8c92c1bbf91dba1eb19f37 /drivers/media/dvb-frontends/lgdt3306a.c
parentc9897649db868dc7d42a92437534baa7bbe04044 (diff)
[media] lgdt3306a: constify log tables
Ideally, we should be replacing this function by intlog10(). While we don't do that, let's at least constify the tables, in order to remove its code footfrint, and get rid of nelems. This also fixes a few 80-cols CodingStyle warnings. Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'drivers/media/dvb-frontends/lgdt3306a.c')
-rw-r--r--drivers/media/dvb-frontends/lgdt3306a.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/drivers/media/dvb-frontends/lgdt3306a.c b/drivers/media/dvb-frontends/lgdt3306a.c
index 9c80d4c26381..ad483be1b64e 100644
--- a/drivers/media/dvb-frontends/lgdt3306a.c
+++ b/drivers/media/dvb-frontends/lgdt3306a.c
@@ -1386,11 +1386,15 @@ static u8 lgdt3306a_get_packet_error(struct lgdt3306a_state *state)
return val;
}
+static const u32 valx_x10[] = {
+ 10, 11, 13, 15, 17, 20, 25, 33, 41, 50, 59, 73, 87, 100
+};
+static const u32 log10x_x1000[] = {
+ 0, 41, 114, 176, 230, 301, 398, 518, 613, 699, 771, 863, 939, 1000
+};
+
static u32 log10_x1000(u32 x)
{
- static u32 valx_x10[] = { 10, 11, 13, 15, 17, 20, 25, 33, 41, 50, 59, 73, 87, 100 };
- static u32 log10x_x1000[] = { 0, 41, 114, 176, 230, 301, 398, 518, 613, 699, 771, 863, 939, 1000 };
- static u32 nelems = sizeof(valx_x10)/sizeof(valx_x10[0]);
u32 diff_val, step_val, step_log10;
u32 log_val = 0;
u32 i;
@@ -1418,11 +1422,11 @@ static u32 log10_x1000(u32 x)
return log_val; /* don't need to interpolate */
/* find our place on the log curve */
- for (i = 1; i < nelems; i++) {
+ for (i = 1; i < ARRAY_SIZE(valx_x10); i++) {
if (valx_x10[i] >= x)
break;
}
- if (i == nelems)
+ if (i == ARRAY_SIZE(valx_x10))
return log_val + log10x_x1000[i - 1];
diff_val = x - valx_x10[i-1];