diff options
author | Michael Krufky <mkrufky@linuxtv.org> | 2007-12-29 19:46:01 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-01-25 16:04:34 -0500 |
commit | 33f25b42753f464c5927e8b828352333780c14bd (patch) | |
tree | ccd92d6a0e2996e6f553d6def330ec77fb81593b /drivers/media/dvb/frontends/tda18271-tables.c | |
parent | 0be4375410f1ecc917f3c0caf8f98908d357c93f (diff) |
V4L/DVB (6957): tda18271: fail table lookups if frequency is out of range
Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/dvb/frontends/tda18271-tables.c')
-rw-r--r-- | drivers/media/dvb/frontends/tda18271-tables.c | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/drivers/media/dvb/frontends/tda18271-tables.c b/drivers/media/dvb/frontends/tda18271-tables.c index e10a93bf12c1..f8202c40b046 100644 --- a/drivers/media/dvb/frontends/tda18271-tables.c +++ b/drivers/media/dvb/frontends/tda18271-tables.c | |||
@@ -273,6 +273,7 @@ int tda18271_lookup_pll_map(enum tda18271_map_type map_type, | |||
273 | struct tda18271_pll_map *map = NULL; | 273 | struct tda18271_pll_map *map = NULL; |
274 | unsigned int i = 0; | 274 | unsigned int i = 0; |
275 | char *map_name; | 275 | char *map_name; |
276 | int ret = 0; | ||
276 | 277 | ||
277 | switch (map_type) { | 278 | switch (map_type) { |
278 | case MAIN_PLL: | 279 | case MAIN_PLL: |
@@ -291,12 +292,17 @@ int tda18271_lookup_pll_map(enum tda18271_map_type map_type, | |||
291 | 292 | ||
292 | if (!map) { | 293 | if (!map) { |
293 | tda_warn("%s map is not set!\n", map_name); | 294 | tda_warn("%s map is not set!\n", map_name); |
294 | return -EINVAL; | 295 | ret = -EINVAL; |
296 | goto fail; | ||
295 | } | 297 | } |
296 | 298 | ||
297 | while ((map[i].lomax * 1000) < *freq) { | 299 | while ((map[i].lomax * 1000) < *freq) { |
298 | if (map[i + 1].lomax == 0) | 300 | if (map[i].lomax == 0) { |
301 | tda_map("%s: frequency (%d) out of range\n", | ||
302 | map_name, *freq); | ||
303 | ret = -ERANGE; | ||
299 | break; | 304 | break; |
305 | } | ||
300 | i++; | 306 | i++; |
301 | } | 307 | } |
302 | *post_div = map[i].pd; | 308 | *post_div = map[i].pd; |
@@ -304,8 +310,8 @@ int tda18271_lookup_pll_map(enum tda18271_map_type map_type, | |||
304 | 310 | ||
305 | tda_map("%s: post div = 0x%02x, div = 0x%02x\n", | 311 | tda_map("%s: post div = 0x%02x, div = 0x%02x\n", |
306 | map_name, *post_div, *div); | 312 | map_name, *post_div, *div); |
307 | 313 | fail: | |
308 | return 0; | 314 | return ret; |
309 | } | 315 | } |
310 | 316 | ||
311 | int tda18271_lookup_map(enum tda18271_map_type map_type, u32 *freq, u8 *val) | 317 | 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 | struct tda18271_map *map = NULL; | 319 | struct tda18271_map *map = NULL; |
314 | unsigned int i = 0; | 320 | unsigned int i = 0; |
315 | char *map_name; | 321 | char *map_name; |
322 | int ret = 0; | ||
316 | 323 | ||
317 | switch (map_type) { | 324 | switch (map_type) { |
318 | case BP_FILTER: | 325 | case BP_FILTER: |
@@ -347,19 +354,24 @@ int tda18271_lookup_map(enum tda18271_map_type map_type, u32 *freq, u8 *val) | |||
347 | 354 | ||
348 | if (!map) { | 355 | if (!map) { |
349 | tda_warn("%s map is not set!\n", map_name); | 356 | tda_warn("%s map is not set!\n", map_name); |
350 | return -EINVAL; | 357 | ret = -EINVAL; |
358 | goto fail; | ||
351 | } | 359 | } |
352 | 360 | ||
353 | while ((map[i].rfmax * 1000) < *freq) { | 361 | while ((map[i].rfmax * 1000) < *freq) { |
354 | if (map[i + 1].rfmax == 0) | 362 | if (map[i].rfmax == 0) { |
363 | tda_map("%s: frequency (%d) out of range\n", | ||
364 | map_name, *freq); | ||
365 | ret = -ERANGE; | ||
355 | break; | 366 | break; |
367 | } | ||
356 | i++; | 368 | i++; |
357 | } | 369 | } |
358 | *val = map[i].val; | 370 | *val = map[i].val; |
359 | 371 | ||
360 | tda_map("%s: 0x%02x\n", map_name, *val); | 372 | tda_map("%s: 0x%02x\n", map_name, *val); |
361 | 373 | fail: | |
362 | return 0; | 374 | return ret; |
363 | } | 375 | } |
364 | 376 | ||
365 | /* | 377 | /* |