Commit 33f25b42 authored by Michael Krufky's avatar Michael Krufky Committed by Mauro Carvalho Chehab

V4L/DVB (6957): tda18271: fail table lookups if frequency is out of range

Signed-off-by: default avatarMichael Krufky <mkrufky@linuxtv.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@infradead.org>
parent 0be43754
...@@ -502,11 +502,6 @@ static int tda18271_calc_rf_cal(struct dvb_frontend *fe, u32 *freq) ...@@ -502,11 +502,6 @@ static int tda18271_calc_rf_cal(struct dvb_frontend *fe, u32 *freq)
if (ret < 0) if (ret < 0)
goto fail; goto fail;
/* VHF_Low band only */
if (0 == val) {
ret = -ERANGE;
goto fail;
}
regs[R_EB14] = val; regs[R_EB14] = val;
fail: fail:
return ret; return ret;
......
...@@ -273,6 +273,7 @@ int tda18271_lookup_pll_map(enum tda18271_map_type map_type, ...@@ -273,6 +273,7 @@ int tda18271_lookup_pll_map(enum tda18271_map_type map_type,
struct tda18271_pll_map *map = NULL; struct tda18271_pll_map *map = NULL;
unsigned int i = 0; unsigned int i = 0;
char *map_name; char *map_name;
int ret = 0;
switch (map_type) { switch (map_type) {
case MAIN_PLL: case MAIN_PLL:
...@@ -291,12 +292,17 @@ int tda18271_lookup_pll_map(enum tda18271_map_type map_type, ...@@ -291,12 +292,17 @@ int tda18271_lookup_pll_map(enum tda18271_map_type map_type,
if (!map) { if (!map) {
tda_warn("%s map is not set!\n", map_name); tda_warn("%s map is not set!\n", map_name);
return -EINVAL; ret = -EINVAL;
goto fail;
} }
while ((map[i].lomax * 1000) < *freq) { while ((map[i].lomax * 1000) < *freq) {
if (map[i + 1].lomax == 0) if (map[i].lomax == 0) {
tda_map("%s: frequency (%d) out of range\n",
map_name, *freq);
ret = -ERANGE;
break; break;
}
i++; i++;
} }
*post_div = map[i].pd; *post_div = map[i].pd;
...@@ -304,8 +310,8 @@ int tda18271_lookup_pll_map(enum tda18271_map_type map_type, ...@@ -304,8 +310,8 @@ int tda18271_lookup_pll_map(enum tda18271_map_type map_type,
tda_map("%s: post div = 0x%02x, div = 0x%02x\n", tda_map("%s: post div = 0x%02x, div = 0x%02x\n",
map_name, *post_div, *div); map_name, *post_div, *div);
fail:
return 0; return ret;
} }
int tda18271_lookup_map(enum tda18271_map_type map_type, u32 *freq, u8 *val) int tda18271_lookup_map(enum tda18271_map_type map_type, u32 *freq, u8 *val)
...@@ -313,6 +319,7 @@ int tda18271_lookup_map(enum tda18271_map_type map_type, u32 *freq, u8 *val) ...@@ -313,6 +319,7 @@ int tda18271_lookup_map(enum tda18271_map_type map_type, u32 *freq, u8 *val)
struct tda18271_map *map = NULL; struct tda18271_map *map = NULL;
unsigned int i = 0; unsigned int i = 0;
char *map_name; char *map_name;
int ret = 0;
switch (map_type) { switch (map_type) {
case BP_FILTER: case BP_FILTER:
...@@ -347,19 +354,24 @@ int tda18271_lookup_map(enum tda18271_map_type map_type, u32 *freq, u8 *val) ...@@ -347,19 +354,24 @@ int tda18271_lookup_map(enum tda18271_map_type map_type, u32 *freq, u8 *val)
if (!map) { if (!map) {
tda_warn("%s map is not set!\n", map_name); tda_warn("%s map is not set!\n", map_name);
return -EINVAL; ret = -EINVAL;
goto fail;
} }
while ((map[i].rfmax * 1000) < *freq) { while ((map[i].rfmax * 1000) < *freq) {
if (map[i + 1].rfmax == 0) if (map[i].rfmax == 0) {
tda_map("%s: frequency (%d) out of range\n",
map_name, *freq);
ret = -ERANGE;
break; break;
}
i++; i++;
} }
*val = map[i].val; *val = map[i].val;
tda_map("%s: 0x%02x\n", map_name, *val); tda_map("%s: 0x%02x\n", map_name, *val);
fail:
return 0; return ret;
} }
/* /*
......
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