diff options
Diffstat (limited to 'drivers/media/common/tuners/tda18271-fe.c')
-rw-r--r-- | drivers/media/common/tuners/tda18271-fe.c | 168 |
1 files changed, 113 insertions, 55 deletions
diff --git a/drivers/media/common/tuners/tda18271-fe.c b/drivers/media/common/tuners/tda18271-fe.c index b262100ae897..89c01fb1f859 100644 --- a/drivers/media/common/tuners/tda18271-fe.c +++ b/drivers/media/common/tuners/tda18271-fe.c | |||
@@ -51,6 +51,7 @@ static int tda18271_channel_configuration(struct dvb_frontend *fe, | |||
51 | { | 51 | { |
52 | struct tda18271_priv *priv = fe->tuner_priv; | 52 | struct tda18271_priv *priv = fe->tuner_priv; |
53 | unsigned char *regs = priv->tda18271_regs; | 53 | unsigned char *regs = priv->tda18271_regs; |
54 | int ret; | ||
54 | u32 N; | 55 | u32 N; |
55 | 56 | ||
56 | /* update TV broadcast parameters */ | 57 | /* update TV broadcast parameters */ |
@@ -85,7 +86,9 @@ static int tda18271_channel_configuration(struct dvb_frontend *fe, | |||
85 | /* update rf top / if top */ | 86 | /* update rf top / if top */ |
86 | regs[R_EB22] = 0x00; | 87 | regs[R_EB22] = 0x00; |
87 | regs[R_EB22] |= map->rfagc_top; | 88 | regs[R_EB22] |= map->rfagc_top; |
88 | tda18271_write_regs(fe, R_EB22, 1); | 89 | ret = tda18271_write_regs(fe, R_EB22, 1); |
90 | if (tda_fail(ret)) | ||
91 | goto fail; | ||
89 | 92 | ||
90 | /* --------------------------------------------------------------- */ | 93 | /* --------------------------------------------------------------- */ |
91 | 94 | ||
@@ -121,7 +124,9 @@ static int tda18271_channel_configuration(struct dvb_frontend *fe, | |||
121 | /* agc1 has priority on agc2 */ | 124 | /* agc1 has priority on agc2 */ |
122 | regs[R_EB1] &= ~0x01; | 125 | regs[R_EB1] &= ~0x01; |
123 | 126 | ||
124 | tda18271_write_regs(fe, R_EB1, 1); | 127 | ret = tda18271_write_regs(fe, R_EB1, 1); |
128 | if (tda_fail(ret)) | ||
129 | goto fail; | ||
125 | 130 | ||
126 | /* --------------------------------------------------------------- */ | 131 | /* --------------------------------------------------------------- */ |
127 | 132 | ||
@@ -141,7 +146,9 @@ static int tda18271_channel_configuration(struct dvb_frontend *fe, | |||
141 | break; | 146 | break; |
142 | } | 147 | } |
143 | 148 | ||
144 | tda18271_write_regs(fe, R_TM, 7); | 149 | ret = tda18271_write_regs(fe, R_TM, 7); |
150 | if (tda_fail(ret)) | ||
151 | goto fail; | ||
145 | 152 | ||
146 | /* force charge pump source */ | 153 | /* force charge pump source */ |
147 | charge_pump_source(fe, 1); | 154 | charge_pump_source(fe, 1); |
@@ -158,9 +165,9 @@ static int tda18271_channel_configuration(struct dvb_frontend *fe, | |||
158 | regs[R_EP3] &= ~0x04; | 165 | regs[R_EP3] &= ~0x04; |
159 | else | 166 | else |
160 | regs[R_EP3] |= 0x04; | 167 | regs[R_EP3] |= 0x04; |
161 | tda18271_write_regs(fe, R_EP3, 1); | 168 | ret = tda18271_write_regs(fe, R_EP3, 1); |
162 | 169 | fail: | |
163 | return 0; | 170 | return ret; |
164 | } | 171 | } |
165 | 172 | ||
166 | static int tda18271_read_thermometer(struct dvb_frontend *fe) | 173 | static int tda18271_read_thermometer(struct dvb_frontend *fe) |
@@ -213,11 +220,13 @@ static int tda18271c2_rf_tracking_filters_correction(struct dvb_frontend *fe, | |||
213 | struct tda18271_priv *priv = fe->tuner_priv; | 220 | struct tda18271_priv *priv = fe->tuner_priv; |
214 | struct tda18271_rf_tracking_filter_cal *map = priv->rf_cal_state; | 221 | struct tda18271_rf_tracking_filter_cal *map = priv->rf_cal_state; |
215 | unsigned char *regs = priv->tda18271_regs; | 222 | unsigned char *regs = priv->tda18271_regs; |
216 | int tm_current, rfcal_comp, approx, i; | 223 | int tm_current, rfcal_comp, approx, i, ret; |
217 | u8 dc_over_dt, rf_tab; | 224 | u8 dc_over_dt, rf_tab; |
218 | 225 | ||
219 | /* power up */ | 226 | /* power up */ |
220 | tda18271_set_standby_mode(fe, 0, 0, 0); | 227 | ret = tda18271_set_standby_mode(fe, 0, 0, 0); |
228 | if (tda_fail(ret)) | ||
229 | goto fail; | ||
221 | 230 | ||
222 | /* read die current temperature */ | 231 | /* read die current temperature */ |
223 | tm_current = tda18271_read_thermometer(fe); | 232 | tm_current = tda18271_read_thermometer(fe); |
@@ -228,8 +237,8 @@ static int tda18271c2_rf_tracking_filters_correction(struct dvb_frontend *fe, | |||
228 | rf_tab = regs[R_EB14]; | 237 | rf_tab = regs[R_EB14]; |
229 | 238 | ||
230 | i = tda18271_lookup_rf_band(fe, &freq, NULL); | 239 | i = tda18271_lookup_rf_band(fe, &freq, NULL); |
231 | if (i < 0) | 240 | if (tda_fail(i)) |
232 | return -EINVAL; | 241 | return i; |
233 | 242 | ||
234 | if ((0 == map[i].rf3) || (freq / 1000 < map[i].rf2)) { | 243 | if ((0 == map[i].rf3) || (freq / 1000 < map[i].rf2)) { |
235 | approx = map[i].rf_a1 * | 244 | approx = map[i].rf_a1 * |
@@ -250,35 +259,42 @@ static int tda18271c2_rf_tracking_filters_correction(struct dvb_frontend *fe, | |||
250 | rfcal_comp = dc_over_dt * (tm_current - priv->tm_rfcal); | 259 | rfcal_comp = dc_over_dt * (tm_current - priv->tm_rfcal); |
251 | 260 | ||
252 | regs[R_EB14] = approx + rfcal_comp; | 261 | regs[R_EB14] = approx + rfcal_comp; |
253 | tda18271_write_regs(fe, R_EB14, 1); | 262 | ret = tda18271_write_regs(fe, R_EB14, 1); |
254 | 263 | fail: | |
255 | return 0; | 264 | return ret; |
256 | } | 265 | } |
257 | 266 | ||
258 | static int tda18271_por(struct dvb_frontend *fe) | 267 | static int tda18271_por(struct dvb_frontend *fe) |
259 | { | 268 | { |
260 | struct tda18271_priv *priv = fe->tuner_priv; | 269 | struct tda18271_priv *priv = fe->tuner_priv; |
261 | unsigned char *regs = priv->tda18271_regs; | 270 | unsigned char *regs = priv->tda18271_regs; |
271 | int ret; | ||
262 | 272 | ||
263 | /* power up detector 1 */ | 273 | /* power up detector 1 */ |
264 | regs[R_EB12] &= ~0x20; | 274 | regs[R_EB12] &= ~0x20; |
265 | tda18271_write_regs(fe, R_EB12, 1); | 275 | ret = tda18271_write_regs(fe, R_EB12, 1); |
276 | if (tda_fail(ret)) | ||
277 | goto fail; | ||
266 | 278 | ||
267 | regs[R_EB18] &= ~0x80; /* turn agc1 loop on */ | 279 | regs[R_EB18] &= ~0x80; /* turn agc1 loop on */ |
268 | regs[R_EB18] &= ~0x03; /* set agc1_gain to 6 dB */ | 280 | regs[R_EB18] &= ~0x03; /* set agc1_gain to 6 dB */ |
269 | tda18271_write_regs(fe, R_EB18, 1); | 281 | ret = tda18271_write_regs(fe, R_EB18, 1); |
282 | if (tda_fail(ret)) | ||
283 | goto fail; | ||
270 | 284 | ||
271 | regs[R_EB21] |= 0x03; /* set agc2_gain to -6 dB */ | 285 | regs[R_EB21] |= 0x03; /* set agc2_gain to -6 dB */ |
272 | 286 | ||
273 | /* POR mode */ | 287 | /* POR mode */ |
274 | tda18271_set_standby_mode(fe, 1, 0, 0); | 288 | ret = tda18271_set_standby_mode(fe, 1, 0, 0); |
289 | if (tda_fail(ret)) | ||
290 | goto fail; | ||
275 | 291 | ||
276 | /* disable 1.5 MHz low pass filter */ | 292 | /* disable 1.5 MHz low pass filter */ |
277 | regs[R_EB23] &= ~0x04; /* forcelp_fc2_en = 0 */ | 293 | regs[R_EB23] &= ~0x04; /* forcelp_fc2_en = 0 */ |
278 | regs[R_EB23] &= ~0x02; /* XXX: lp_fc[2] = 0 */ | 294 | regs[R_EB23] &= ~0x02; /* XXX: lp_fc[2] = 0 */ |
279 | tda18271_write_regs(fe, R_EB21, 3); | 295 | ret = tda18271_write_regs(fe, R_EB21, 3); |
280 | 296 | fail: | |
281 | return 0; | 297 | return ret; |
282 | } | 298 | } |
283 | 299 | ||
284 | static int tda18271_calibrate_rf(struct dvb_frontend *fe, u32 freq) | 300 | static int tda18271_calibrate_rf(struct dvb_frontend *fe, u32 freq) |
@@ -389,7 +405,7 @@ static int tda18271_powerscan(struct dvb_frontend *fe, | |||
389 | { | 405 | { |
390 | struct tda18271_priv *priv = fe->tuner_priv; | 406 | struct tda18271_priv *priv = fe->tuner_priv; |
391 | unsigned char *regs = priv->tda18271_regs; | 407 | unsigned char *regs = priv->tda18271_regs; |
392 | int sgn, bcal, count, wait; | 408 | int sgn, bcal, count, wait, ret; |
393 | u8 cid_target; | 409 | u8 cid_target; |
394 | u16 count_limit; | 410 | u16 count_limit; |
395 | u32 freq; | 411 | u32 freq; |
@@ -421,7 +437,9 @@ static int tda18271_powerscan(struct dvb_frontend *fe, | |||
421 | tda18271_write_regs(fe, R_EP2, 1); | 437 | tda18271_write_regs(fe, R_EP2, 1); |
422 | 438 | ||
423 | /* read power detection info, stored in EB10 */ | 439 | /* read power detection info, stored in EB10 */ |
424 | tda18271_read_extended(fe); | 440 | ret = tda18271_read_extended(fe); |
441 | if (tda_fail(ret)) | ||
442 | return ret; | ||
425 | 443 | ||
426 | /* algorithm initialization */ | 444 | /* algorithm initialization */ |
427 | sgn = 1; | 445 | sgn = 1; |
@@ -447,7 +465,9 @@ static int tda18271_powerscan(struct dvb_frontend *fe, | |||
447 | tda18271_write_regs(fe, R_EP2, 1); | 465 | tda18271_write_regs(fe, R_EP2, 1); |
448 | 466 | ||
449 | /* read power detection info, stored in EB10 */ | 467 | /* read power detection info, stored in EB10 */ |
450 | tda18271_read_extended(fe); | 468 | ret = tda18271_read_extended(fe); |
469 | if (tda_fail(ret)) | ||
470 | return ret; | ||
451 | 471 | ||
452 | count += 200; | 472 | count += 200; |
453 | 473 | ||
@@ -478,6 +498,7 @@ static int tda18271_powerscan_init(struct dvb_frontend *fe) | |||
478 | { | 498 | { |
479 | struct tda18271_priv *priv = fe->tuner_priv; | 499 | struct tda18271_priv *priv = fe->tuner_priv; |
480 | unsigned char *regs = priv->tda18271_regs; | 500 | unsigned char *regs = priv->tda18271_regs; |
501 | int ret; | ||
481 | 502 | ||
482 | /* set standard to digital */ | 503 | /* set standard to digital */ |
483 | regs[R_EP3] &= ~0x1f; /* clear std bits */ | 504 | regs[R_EP3] &= ~0x1f; /* clear std bits */ |
@@ -489,10 +510,14 @@ static int tda18271_powerscan_init(struct dvb_frontend *fe) | |||
489 | /* update IF output level & IF notch frequency */ | 510 | /* update IF output level & IF notch frequency */ |
490 | regs[R_EP4] &= ~0x1c; /* clear if level bits */ | 511 | regs[R_EP4] &= ~0x1c; /* clear if level bits */ |
491 | 512 | ||
492 | tda18271_write_regs(fe, R_EP3, 2); | 513 | ret = tda18271_write_regs(fe, R_EP3, 2); |
514 | if (tda_fail(ret)) | ||
515 | goto fail; | ||
493 | 516 | ||
494 | regs[R_EB18] &= ~0x03; /* set agc1_gain to 6 dB */ | 517 | regs[R_EB18] &= ~0x03; /* set agc1_gain to 6 dB */ |
495 | tda18271_write_regs(fe, R_EB18, 1); | 518 | ret = tda18271_write_regs(fe, R_EB18, 1); |
519 | if (tda_fail(ret)) | ||
520 | goto fail; | ||
496 | 521 | ||
497 | regs[R_EB21] &= ~0x03; /* set agc2_gain to -15 dB */ | 522 | regs[R_EB21] &= ~0x03; /* set agc2_gain to -15 dB */ |
498 | 523 | ||
@@ -500,9 +525,9 @@ static int tda18271_powerscan_init(struct dvb_frontend *fe) | |||
500 | regs[R_EB23] |= 0x04; /* forcelp_fc2_en = 1 */ | 525 | regs[R_EB23] |= 0x04; /* forcelp_fc2_en = 1 */ |
501 | regs[R_EB23] |= 0x02; /* lp_fc[2] = 1 */ | 526 | regs[R_EB23] |= 0x02; /* lp_fc[2] = 1 */ |
502 | 527 | ||
503 | tda18271_write_regs(fe, R_EB21, 3); | 528 | ret = tda18271_write_regs(fe, R_EB21, 3); |
504 | 529 | fail: | |
505 | return 0; | 530 | return ret; |
506 | } | 531 | } |
507 | 532 | ||
508 | static int tda18271_rf_tracking_filters_init(struct dvb_frontend *fe, u32 freq) | 533 | static int tda18271_rf_tracking_filters_init(struct dvb_frontend *fe, u32 freq) |
@@ -521,7 +546,7 @@ static int tda18271_rf_tracking_filters_init(struct dvb_frontend *fe, u32 freq) | |||
521 | 546 | ||
522 | i = tda18271_lookup_rf_band(fe, &freq, NULL); | 547 | i = tda18271_lookup_rf_band(fe, &freq, NULL); |
523 | 548 | ||
524 | if (i < 0) | 549 | if (tda_fail(i)) |
525 | return i; | 550 | return i; |
526 | 551 | ||
527 | rf_default[RF1] = 1000 * map[i].rf1_def; | 552 | rf_default[RF1] = 1000 * map[i].rf1_def; |
@@ -535,6 +560,8 @@ static int tda18271_rf_tracking_filters_init(struct dvb_frontend *fe, u32 freq) | |||
535 | 560 | ||
536 | /* look for optimized calibration frequency */ | 561 | /* look for optimized calibration frequency */ |
537 | bcal = tda18271_powerscan(fe, &rf_default[rf], &rf_freq[rf]); | 562 | bcal = tda18271_powerscan(fe, &rf_default[rf], &rf_freq[rf]); |
563 | if (tda_fail(bcal)) | ||
564 | return bcal; | ||
538 | 565 | ||
539 | tda18271_calc_rf_cal(fe, &rf_freq[rf]); | 566 | tda18271_calc_rf_cal(fe, &rf_freq[rf]); |
540 | prog_tab[rf] = regs[R_EB14]; | 567 | prog_tab[rf] = regs[R_EB14]; |
@@ -575,22 +602,29 @@ static int tda18271_calc_rf_filter_curve(struct dvb_frontend *fe) | |||
575 | { | 602 | { |
576 | struct tda18271_priv *priv = fe->tuner_priv; | 603 | struct tda18271_priv *priv = fe->tuner_priv; |
577 | unsigned int i; | 604 | unsigned int i; |
605 | int ret; | ||
578 | 606 | ||
579 | tda_info("tda18271: performing RF tracking filter calibration\n"); | 607 | tda_info("tda18271: performing RF tracking filter calibration\n"); |
580 | 608 | ||
581 | /* wait for die temperature stabilization */ | 609 | /* wait for die temperature stabilization */ |
582 | msleep(200); | 610 | msleep(200); |
583 | 611 | ||
584 | tda18271_powerscan_init(fe); | 612 | ret = tda18271_powerscan_init(fe); |
613 | if (tda_fail(ret)) | ||
614 | goto fail; | ||
585 | 615 | ||
586 | /* rf band calibration */ | 616 | /* rf band calibration */ |
587 | for (i = 0; priv->rf_cal_state[i].rfmax != 0; i++) | 617 | for (i = 0; priv->rf_cal_state[i].rfmax != 0; i++) { |
618 | ret = | ||
588 | tda18271_rf_tracking_filters_init(fe, 1000 * | 619 | tda18271_rf_tracking_filters_init(fe, 1000 * |
589 | priv->rf_cal_state[i].rfmax); | 620 | priv->rf_cal_state[i].rfmax); |
621 | if (tda_fail(ret)) | ||
622 | goto fail; | ||
623 | } | ||
590 | 624 | ||
591 | priv->tm_rfcal = tda18271_read_thermometer(fe); | 625 | priv->tm_rfcal = tda18271_read_thermometer(fe); |
592 | 626 | fail: | |
593 | return 0; | 627 | return ret; |
594 | } | 628 | } |
595 | 629 | ||
596 | /* ------------------------------------------------------------------ */ | 630 | /* ------------------------------------------------------------------ */ |
@@ -599,6 +633,7 @@ static int tda18271c2_rf_cal_init(struct dvb_frontend *fe) | |||
599 | { | 633 | { |
600 | struct tda18271_priv *priv = fe->tuner_priv; | 634 | struct tda18271_priv *priv = fe->tuner_priv; |
601 | unsigned char *regs = priv->tda18271_regs; | 635 | unsigned char *regs = priv->tda18271_regs; |
636 | int ret; | ||
602 | 637 | ||
603 | /* test RF_CAL_OK to see if we need init */ | 638 | /* test RF_CAL_OK to see if we need init */ |
604 | if ((regs[R_EP1] & 0x10) == 0) | 639 | if ((regs[R_EP1] & 0x10) == 0) |
@@ -607,15 +642,22 @@ static int tda18271c2_rf_cal_init(struct dvb_frontend *fe) | |||
607 | if (priv->cal_initialized) | 642 | if (priv->cal_initialized) |
608 | return 0; | 643 | return 0; |
609 | 644 | ||
610 | tda18271_calc_rf_filter_curve(fe); | 645 | ret = tda18271_calc_rf_filter_curve(fe); |
646 | if (tda_fail(ret)) | ||
647 | goto fail; | ||
611 | 648 | ||
612 | tda18271_por(fe); | 649 | ret = tda18271_por(fe); |
650 | if (tda_fail(ret)) | ||
651 | goto fail; | ||
613 | 652 | ||
614 | tda_info("tda18271: RF tracking filter calibration complete\n"); | 653 | tda_info("tda18271: RF tracking filter calibration complete\n"); |
615 | 654 | ||
616 | priv->cal_initialized = true; | 655 | priv->cal_initialized = true; |
617 | 656 | goto end; | |
618 | return 0; | 657 | fail: |
658 | tda_info("tda18271: RF tracking filter calibration failed!\n"); | ||
659 | end: | ||
660 | return ret; | ||
619 | } | 661 | } |
620 | 662 | ||
621 | static int tda18271c1_rf_tracking_filter_calibration(struct dvb_frontend *fe, | 663 | static int tda18271c1_rf_tracking_filter_calibration(struct dvb_frontend *fe, |
@@ -623,6 +665,7 @@ static int tda18271c1_rf_tracking_filter_calibration(struct dvb_frontend *fe, | |||
623 | { | 665 | { |
624 | struct tda18271_priv *priv = fe->tuner_priv; | 666 | struct tda18271_priv *priv = fe->tuner_priv; |
625 | unsigned char *regs = priv->tda18271_regs; | 667 | unsigned char *regs = priv->tda18271_regs; |
668 | int ret; | ||
626 | u32 N = 0; | 669 | u32 N = 0; |
627 | 670 | ||
628 | /* calculate bp filter */ | 671 | /* calculate bp filter */ |
@@ -671,7 +714,10 @@ static int tda18271c1_rf_tracking_filter_calibration(struct dvb_frontend *fe, | |||
671 | 714 | ||
672 | tda18271_calc_main_pll(fe, N); | 715 | tda18271_calc_main_pll(fe, N); |
673 | 716 | ||
674 | tda18271_write_regs(fe, R_EP3, 11); | 717 | ret = tda18271_write_regs(fe, R_EP3, 11); |
718 | if (tda_fail(ret)) | ||
719 | return ret; | ||
720 | |||
675 | msleep(5); /* RF tracking filter calibration initialization */ | 721 | msleep(5); /* RF tracking filter calibration initialization */ |
676 | 722 | ||
677 | /* search for K,M,CO for RF calibration */ | 723 | /* search for K,M,CO for RF calibration */ |
@@ -719,45 +765,56 @@ static int tda18271_ir_cal_init(struct dvb_frontend *fe) | |||
719 | { | 765 | { |
720 | struct tda18271_priv *priv = fe->tuner_priv; | 766 | struct tda18271_priv *priv = fe->tuner_priv; |
721 | unsigned char *regs = priv->tda18271_regs; | 767 | unsigned char *regs = priv->tda18271_regs; |
768 | int ret; | ||
722 | 769 | ||
723 | tda18271_read_regs(fe); | 770 | ret = tda18271_read_regs(fe); |
771 | if (tda_fail(ret)) | ||
772 | goto fail; | ||
724 | 773 | ||
725 | /* test IR_CAL_OK to see if we need init */ | 774 | /* test IR_CAL_OK to see if we need init */ |
726 | if ((regs[R_EP1] & 0x08) == 0) | 775 | if ((regs[R_EP1] & 0x08) == 0) |
727 | tda18271_init_regs(fe); | 776 | ret = tda18271_init_regs(fe); |
728 | 777 | fail: | |
729 | return 0; | 778 | return ret; |
730 | } | 779 | } |
731 | 780 | ||
732 | static int tda18271_init(struct dvb_frontend *fe) | 781 | static int tda18271_init(struct dvb_frontend *fe) |
733 | { | 782 | { |
734 | struct tda18271_priv *priv = fe->tuner_priv; | 783 | struct tda18271_priv *priv = fe->tuner_priv; |
784 | int ret; | ||
735 | 785 | ||
736 | mutex_lock(&priv->lock); | 786 | mutex_lock(&priv->lock); |
737 | 787 | ||
738 | /* power up */ | 788 | /* power up */ |
739 | tda18271_set_standby_mode(fe, 0, 0, 0); | 789 | ret = tda18271_set_standby_mode(fe, 0, 0, 0); |
790 | if (tda_fail(ret)) | ||
791 | goto fail; | ||
740 | 792 | ||
741 | /* initialization */ | 793 | /* initialization */ |
742 | tda18271_ir_cal_init(fe); | 794 | ret = tda18271_ir_cal_init(fe); |
795 | if (tda_fail(ret)) | ||
796 | goto fail; | ||
743 | 797 | ||
744 | if (priv->id == TDA18271HDC2) | 798 | if (priv->id == TDA18271HDC2) |
745 | tda18271c2_rf_cal_init(fe); | 799 | tda18271c2_rf_cal_init(fe); |
746 | 800 | fail: | |
747 | mutex_unlock(&priv->lock); | 801 | mutex_unlock(&priv->lock); |
748 | 802 | ||
749 | return 0; | 803 | return ret; |
750 | } | 804 | } |
751 | 805 | ||
752 | static int tda18271_tune(struct dvb_frontend *fe, | 806 | static int tda18271_tune(struct dvb_frontend *fe, |
753 | struct tda18271_std_map_item *map, u32 freq, u32 bw) | 807 | struct tda18271_std_map_item *map, u32 freq, u32 bw) |
754 | { | 808 | { |
755 | struct tda18271_priv *priv = fe->tuner_priv; | 809 | struct tda18271_priv *priv = fe->tuner_priv; |
810 | int ret; | ||
756 | 811 | ||
757 | tda_dbg("freq = %d, ifc = %d, bw = %d, agc_mode = %d, std = %d\n", | 812 | tda_dbg("freq = %d, ifc = %d, bw = %d, agc_mode = %d, std = %d\n", |
758 | freq, map->if_freq, bw, map->agc_mode, map->std); | 813 | freq, map->if_freq, bw, map->agc_mode, map->std); |
759 | 814 | ||
760 | tda18271_init(fe); | 815 | ret = tda18271_init(fe); |
816 | if (tda_fail(ret)) | ||
817 | goto fail; | ||
761 | 818 | ||
762 | mutex_lock(&priv->lock); | 819 | mutex_lock(&priv->lock); |
763 | 820 | ||
@@ -769,11 +826,11 @@ static int tda18271_tune(struct dvb_frontend *fe, | |||
769 | tda18271c2_rf_tracking_filters_correction(fe, freq); | 826 | tda18271c2_rf_tracking_filters_correction(fe, freq); |
770 | break; | 827 | break; |
771 | } | 828 | } |
772 | tda18271_channel_configuration(fe, map, freq, bw); | 829 | ret = tda18271_channel_configuration(fe, map, freq, bw); |
773 | 830 | ||
774 | mutex_unlock(&priv->lock); | 831 | mutex_unlock(&priv->lock); |
775 | 832 | fail: | |
776 | return 0; | 833 | return ret; |
777 | } | 834 | } |
778 | 835 | ||
779 | /* ------------------------------------------------------------------ */ | 836 | /* ------------------------------------------------------------------ */ |
@@ -837,7 +894,7 @@ static int tda18271_set_params(struct dvb_frontend *fe, | |||
837 | 894 | ||
838 | ret = tda18271_tune(fe, map, freq, bw); | 895 | ret = tda18271_tune(fe, map, freq, bw); |
839 | 896 | ||
840 | if (ret < 0) | 897 | if (tda_fail(ret)) |
841 | goto fail; | 898 | goto fail; |
842 | 899 | ||
843 | priv->frequency = freq; | 900 | priv->frequency = freq; |
@@ -893,7 +950,7 @@ static int tda18271_set_analog_params(struct dvb_frontend *fe, | |||
893 | 950 | ||
894 | ret = tda18271_tune(fe, map, freq, 0); | 951 | ret = tda18271_tune(fe, map, freq, 0); |
895 | 952 | ||
896 | if (ret < 0) | 953 | if (tda_fail(ret)) |
897 | goto fail; | 954 | goto fail; |
898 | 955 | ||
899 | priv->frequency = freq; | 956 | priv->frequency = freq; |
@@ -905,16 +962,17 @@ fail: | |||
905 | static int tda18271_sleep(struct dvb_frontend *fe) | 962 | static int tda18271_sleep(struct dvb_frontend *fe) |
906 | { | 963 | { |
907 | struct tda18271_priv *priv = fe->tuner_priv; | 964 | struct tda18271_priv *priv = fe->tuner_priv; |
965 | int ret; | ||
908 | 966 | ||
909 | mutex_lock(&priv->lock); | 967 | mutex_lock(&priv->lock); |
910 | 968 | ||
911 | /* standby mode w/ slave tuner output | 969 | /* standby mode w/ slave tuner output |
912 | * & loop thru & xtal oscillator on */ | 970 | * & loop thru & xtal oscillator on */ |
913 | tda18271_set_standby_mode(fe, 1, 0, 0); | 971 | ret = tda18271_set_standby_mode(fe, 1, 0, 0); |
914 | 972 | ||
915 | mutex_unlock(&priv->lock); | 973 | mutex_unlock(&priv->lock); |
916 | 974 | ||
917 | return 0; | 975 | return ret; |
918 | } | 976 | } |
919 | 977 | ||
920 | static int tda18271_release(struct dvb_frontend *fe) | 978 | static int tda18271_release(struct dvb_frontend *fe) |
@@ -1095,10 +1153,10 @@ struct dvb_frontend *tda18271_attach(struct dvb_frontend *fe, u8 addr, | |||
1095 | if (cfg) | 1153 | if (cfg) |
1096 | priv->small_i2c = cfg->small_i2c; | 1154 | priv->small_i2c = cfg->small_i2c; |
1097 | 1155 | ||
1098 | if (tda18271_get_id(fe) < 0) | 1156 | if (tda_fail(tda18271_get_id(fe))) |
1099 | goto fail; | 1157 | goto fail; |
1100 | 1158 | ||
1101 | if (tda18271_assign_map_layout(fe) < 0) | 1159 | if (tda_fail(tda18271_assign_map_layout(fe))) |
1102 | goto fail; | 1160 | goto fail; |
1103 | 1161 | ||
1104 | mutex_lock(&priv->lock); | 1162 | mutex_lock(&priv->lock); |