aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorMichael Krufky <mkrufky@linuxtv.org>2008-05-04 20:32:21 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-05-14 01:54:06 -0400
commit4bd5d1071ddbb35ae545c7738e6411e50ce28b17 (patch)
tree44ea03fd76a2aa8838b005c349f0838c11820b1c /drivers/media
parent10ed0bf4af00c25590e8bfca344d8dec5c3637ae (diff)
V4L/DVB (7844): tda18271: add tda_fail macro to log error cases
Signed-off-by: Michael Krufky <mkrufky@linuxtv.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/common/tuners/tda18271-common.c14
-rw-r--r--drivers/media/common/tuners/tda18271-fe.c56
-rw-r--r--drivers/media/common/tuners/tda18271-priv.h9
3 files changed, 44 insertions, 35 deletions
diff --git a/drivers/media/common/tuners/tda18271-common.c b/drivers/media/common/tuners/tda18271-common.c
index d6938fc2c4c6..42b5f5d4bfe6 100644
--- a/drivers/media/common/tuners/tda18271-common.c
+++ b/drivers/media/common/tuners/tda18271-common.c
@@ -508,7 +508,7 @@ int tda18271_calc_main_pll(struct dvb_frontend *fe, u32 freq)
508 u32 div; 508 u32 div;
509 509
510 int ret = tda18271_lookup_pll_map(fe, MAIN_PLL, &freq, &pd, &d); 510 int ret = tda18271_lookup_pll_map(fe, MAIN_PLL, &freq, &pd, &d);
511 if (ret < 0) 511 if (tda_fail(ret))
512 goto fail; 512 goto fail;
513 513
514 regs[R_MPD] = (0x77 & pd); 514 regs[R_MPD] = (0x77 & pd);
@@ -540,7 +540,7 @@ int tda18271_calc_cal_pll(struct dvb_frontend *fe, u32 freq)
540 u32 div; 540 u32 div;
541 541
542 int ret = tda18271_lookup_pll_map(fe, CAL_PLL, &freq, &pd, &d); 542 int ret = tda18271_lookup_pll_map(fe, CAL_PLL, &freq, &pd, &d);
543 if (ret < 0) 543 if (tda_fail(ret))
544 goto fail; 544 goto fail;
545 545
546 regs[R_CPD] = pd; 546 regs[R_CPD] = pd;
@@ -564,7 +564,7 @@ int tda18271_calc_bp_filter(struct dvb_frontend *fe, u32 *freq)
564 u8 val; 564 u8 val;
565 565
566 int ret = tda18271_lookup_map(fe, BP_FILTER, freq, &val); 566 int ret = tda18271_lookup_map(fe, BP_FILTER, freq, &val);
567 if (ret < 0) 567 if (tda_fail(ret))
568 goto fail; 568 goto fail;
569 569
570 regs[R_EP1] &= ~0x07; /* clear bp filter bits */ 570 regs[R_EP1] &= ~0x07; /* clear bp filter bits */
@@ -581,7 +581,7 @@ int tda18271_calc_km(struct dvb_frontend *fe, u32 *freq)
581 u8 val; 581 u8 val;
582 582
583 int ret = tda18271_lookup_map(fe, RF_CAL_KMCO, freq, &val); 583 int ret = tda18271_lookup_map(fe, RF_CAL_KMCO, freq, &val);
584 if (ret < 0) 584 if (tda_fail(ret))
585 goto fail; 585 goto fail;
586 586
587 regs[R_EB13] &= ~0x7c; /* clear k & m bits */ 587 regs[R_EB13] &= ~0x7c; /* clear k & m bits */
@@ -598,7 +598,7 @@ int tda18271_calc_rf_band(struct dvb_frontend *fe, u32 *freq)
598 u8 val; 598 u8 val;
599 599
600 int ret = tda18271_lookup_map(fe, RF_BAND, freq, &val); 600 int ret = tda18271_lookup_map(fe, RF_BAND, freq, &val);
601 if (ret < 0) 601 if (tda_fail(ret))
602 goto fail; 602 goto fail;
603 603
604 regs[R_EP2] &= ~0xe0; /* clear rf band bits */ 604 regs[R_EP2] &= ~0xe0; /* clear rf band bits */
@@ -615,7 +615,7 @@ int tda18271_calc_gain_taper(struct dvb_frontend *fe, u32 *freq)
615 u8 val; 615 u8 val;
616 616
617 int ret = tda18271_lookup_map(fe, GAIN_TAPER, freq, &val); 617 int ret = tda18271_lookup_map(fe, GAIN_TAPER, freq, &val);
618 if (ret < 0) 618 if (tda_fail(ret))
619 goto fail; 619 goto fail;
620 620
621 regs[R_EP2] &= ~0x1f; /* clear gain taper bits */ 621 regs[R_EP2] &= ~0x1f; /* clear gain taper bits */
@@ -632,7 +632,7 @@ int tda18271_calc_ir_measure(struct dvb_frontend *fe, u32 *freq)
632 u8 val; 632 u8 val;
633 633
634 int ret = tda18271_lookup_map(fe, IR_MEASURE, freq, &val); 634 int ret = tda18271_lookup_map(fe, IR_MEASURE, freq, &val);
635 if (ret < 0) 635 if (tda_fail(ret))
636 goto fail; 636 goto fail;
637 637
638 regs[R_EP5] &= ~0x07; 638 regs[R_EP5] &= ~0x07;
diff --git a/drivers/media/common/tuners/tda18271-fe.c b/drivers/media/common/tuners/tda18271-fe.c
index 13d651c987a3..89c01fb1f859 100644
--- a/drivers/media/common/tuners/tda18271-fe.c
+++ b/drivers/media/common/tuners/tda18271-fe.c
@@ -87,7 +87,7 @@ static int tda18271_channel_configuration(struct dvb_frontend *fe,
87 regs[R_EB22] = 0x00; 87 regs[R_EB22] = 0x00;
88 regs[R_EB22] |= map->rfagc_top; 88 regs[R_EB22] |= map->rfagc_top;
89 ret = tda18271_write_regs(fe, R_EB22, 1); 89 ret = tda18271_write_regs(fe, R_EB22, 1);
90 if (ret < 0) 90 if (tda_fail(ret))
91 goto fail; 91 goto fail;
92 92
93 /* --------------------------------------------------------------- */ 93 /* --------------------------------------------------------------- */
@@ -125,7 +125,7 @@ static int tda18271_channel_configuration(struct dvb_frontend *fe,
125 regs[R_EB1] &= ~0x01; 125 regs[R_EB1] &= ~0x01;
126 126
127 ret = tda18271_write_regs(fe, R_EB1, 1); 127 ret = tda18271_write_regs(fe, R_EB1, 1);
128 if (ret < 0) 128 if (tda_fail(ret))
129 goto fail; 129 goto fail;
130 130
131 /* --------------------------------------------------------------- */ 131 /* --------------------------------------------------------------- */
@@ -147,7 +147,7 @@ static int tda18271_channel_configuration(struct dvb_frontend *fe,
147 } 147 }
148 148
149 ret = tda18271_write_regs(fe, R_TM, 7); 149 ret = tda18271_write_regs(fe, R_TM, 7);
150 if (ret < 0) 150 if (tda_fail(ret))
151 goto fail; 151 goto fail;
152 152
153 /* force charge pump source */ 153 /* force charge pump source */
@@ -225,7 +225,7 @@ static int tda18271c2_rf_tracking_filters_correction(struct dvb_frontend *fe,
225 225
226 /* power up */ 226 /* power up */
227 ret = tda18271_set_standby_mode(fe, 0, 0, 0); 227 ret = tda18271_set_standby_mode(fe, 0, 0, 0);
228 if (ret < 0) 228 if (tda_fail(ret))
229 goto fail; 229 goto fail;
230 230
231 /* read die current temperature */ 231 /* read die current temperature */
@@ -237,8 +237,8 @@ static int tda18271c2_rf_tracking_filters_correction(struct dvb_frontend *fe,
237 rf_tab = regs[R_EB14]; 237 rf_tab = regs[R_EB14];
238 238
239 i = tda18271_lookup_rf_band(fe, &freq, NULL); 239 i = tda18271_lookup_rf_band(fe, &freq, NULL);
240 if (i < 0) 240 if (tda_fail(i))
241 return -EINVAL; 241 return i;
242 242
243 if ((0 == map[i].rf3) || (freq / 1000 < map[i].rf2)) { 243 if ((0 == map[i].rf3) || (freq / 1000 < map[i].rf2)) {
244 approx = map[i].rf_a1 * 244 approx = map[i].rf_a1 *
@@ -273,20 +273,20 @@ static int tda18271_por(struct dvb_frontend *fe)
273 /* power up detector 1 */ 273 /* power up detector 1 */
274 regs[R_EB12] &= ~0x20; 274 regs[R_EB12] &= ~0x20;
275 ret = tda18271_write_regs(fe, R_EB12, 1); 275 ret = tda18271_write_regs(fe, R_EB12, 1);
276 if (ret < 0) 276 if (tda_fail(ret))
277 goto fail; 277 goto fail;
278 278
279 regs[R_EB18] &= ~0x80; /* turn agc1 loop on */ 279 regs[R_EB18] &= ~0x80; /* turn agc1 loop on */
280 regs[R_EB18] &= ~0x03; /* set agc1_gain to 6 dB */ 280 regs[R_EB18] &= ~0x03; /* set agc1_gain to 6 dB */
281 ret = tda18271_write_regs(fe, R_EB18, 1); 281 ret = tda18271_write_regs(fe, R_EB18, 1);
282 if (ret < 0) 282 if (tda_fail(ret))
283 goto fail; 283 goto fail;
284 284
285 regs[R_EB21] |= 0x03; /* set agc2_gain to -6 dB */ 285 regs[R_EB21] |= 0x03; /* set agc2_gain to -6 dB */
286 286
287 /* POR mode */ 287 /* POR mode */
288 ret = tda18271_set_standby_mode(fe, 1, 0, 0); 288 ret = tda18271_set_standby_mode(fe, 1, 0, 0);
289 if (ret < 0) 289 if (tda_fail(ret))
290 goto fail; 290 goto fail;
291 291
292 /* disable 1.5 MHz low pass filter */ 292 /* disable 1.5 MHz low pass filter */
@@ -438,7 +438,7 @@ static int tda18271_powerscan(struct dvb_frontend *fe,
438 438
439 /* read power detection info, stored in EB10 */ 439 /* read power detection info, stored in EB10 */
440 ret = tda18271_read_extended(fe); 440 ret = tda18271_read_extended(fe);
441 if (ret < 0) 441 if (tda_fail(ret))
442 return ret; 442 return ret;
443 443
444 /* algorithm initialization */ 444 /* algorithm initialization */
@@ -466,7 +466,7 @@ static int tda18271_powerscan(struct dvb_frontend *fe,
466 466
467 /* read power detection info, stored in EB10 */ 467 /* read power detection info, stored in EB10 */
468 ret = tda18271_read_extended(fe); 468 ret = tda18271_read_extended(fe);
469 if (ret < 0) 469 if (tda_fail(ret))
470 return ret; 470 return ret;
471 471
472 count += 200; 472 count += 200;
@@ -511,12 +511,12 @@ static int tda18271_powerscan_init(struct dvb_frontend *fe)
511 regs[R_EP4] &= ~0x1c; /* clear if level bits */ 511 regs[R_EP4] &= ~0x1c; /* clear if level bits */
512 512
513 ret = tda18271_write_regs(fe, R_EP3, 2); 513 ret = tda18271_write_regs(fe, R_EP3, 2);
514 if (ret < 0) 514 if (tda_fail(ret))
515 goto fail; 515 goto fail;
516 516
517 regs[R_EB18] &= ~0x03; /* set agc1_gain to 6 dB */ 517 regs[R_EB18] &= ~0x03; /* set agc1_gain to 6 dB */
518 ret = tda18271_write_regs(fe, R_EB18, 1); 518 ret = tda18271_write_regs(fe, R_EB18, 1);
519 if (ret < 0) 519 if (tda_fail(ret))
520 goto fail; 520 goto fail;
521 521
522 regs[R_EB21] &= ~0x03; /* set agc2_gain to -15 dB */ 522 regs[R_EB21] &= ~0x03; /* set agc2_gain to -15 dB */
@@ -546,7 +546,7 @@ static int tda18271_rf_tracking_filters_init(struct dvb_frontend *fe, u32 freq)
546 546
547 i = tda18271_lookup_rf_band(fe, &freq, NULL); 547 i = tda18271_lookup_rf_band(fe, &freq, NULL);
548 548
549 if (i < 0) 549 if (tda_fail(i))
550 return i; 550 return i;
551 551
552 rf_default[RF1] = 1000 * map[i].rf1_def; 552 rf_default[RF1] = 1000 * map[i].rf1_def;
@@ -560,7 +560,7 @@ static int tda18271_rf_tracking_filters_init(struct dvb_frontend *fe, u32 freq)
560 560
561 /* look for optimized calibration frequency */ 561 /* look for optimized calibration frequency */
562 bcal = tda18271_powerscan(fe, &rf_default[rf], &rf_freq[rf]); 562 bcal = tda18271_powerscan(fe, &rf_default[rf], &rf_freq[rf]);
563 if (bcal < 0) 563 if (tda_fail(bcal))
564 return bcal; 564 return bcal;
565 565
566 tda18271_calc_rf_cal(fe, &rf_freq[rf]); 566 tda18271_calc_rf_cal(fe, &rf_freq[rf]);
@@ -610,7 +610,7 @@ static int tda18271_calc_rf_filter_curve(struct dvb_frontend *fe)
610 msleep(200); 610 msleep(200);
611 611
612 ret = tda18271_powerscan_init(fe); 612 ret = tda18271_powerscan_init(fe);
613 if (ret < 0) 613 if (tda_fail(ret))
614 goto fail; 614 goto fail;
615 615
616 /* rf band calibration */ 616 /* rf band calibration */
@@ -618,7 +618,7 @@ static int tda18271_calc_rf_filter_curve(struct dvb_frontend *fe)
618 ret = 618 ret =
619 tda18271_rf_tracking_filters_init(fe, 1000 * 619 tda18271_rf_tracking_filters_init(fe, 1000 *
620 priv->rf_cal_state[i].rfmax); 620 priv->rf_cal_state[i].rfmax);
621 if (ret < 0) 621 if (tda_fail(ret))
622 goto fail; 622 goto fail;
623 } 623 }
624 624
@@ -643,11 +643,11 @@ static int tda18271c2_rf_cal_init(struct dvb_frontend *fe)
643 return 0; 643 return 0;
644 644
645 ret = tda18271_calc_rf_filter_curve(fe); 645 ret = tda18271_calc_rf_filter_curve(fe);
646 if (ret < 0) 646 if (tda_fail(ret))
647 goto fail; 647 goto fail;
648 648
649 ret = tda18271_por(fe); 649 ret = tda18271_por(fe);
650 if (ret < 0) 650 if (tda_fail(ret))
651 goto fail; 651 goto fail;
652 652
653 tda_info("tda18271: RF tracking filter calibration complete\n"); 653 tda_info("tda18271: RF tracking filter calibration complete\n");
@@ -715,7 +715,7 @@ static int tda18271c1_rf_tracking_filter_calibration(struct dvb_frontend *fe,
715 tda18271_calc_main_pll(fe, N); 715 tda18271_calc_main_pll(fe, N);
716 716
717 ret = tda18271_write_regs(fe, R_EP3, 11); 717 ret = tda18271_write_regs(fe, R_EP3, 11);
718 if (ret < 0) 718 if (tda_fail(ret))
719 return ret; 719 return ret;
720 720
721 msleep(5); /* RF tracking filter calibration initialization */ 721 msleep(5); /* RF tracking filter calibration initialization */
@@ -768,7 +768,7 @@ static int tda18271_ir_cal_init(struct dvb_frontend *fe)
768 int ret; 768 int ret;
769 769
770 ret = tda18271_read_regs(fe); 770 ret = tda18271_read_regs(fe);
771 if (ret < 0) 771 if (tda_fail(ret))
772 goto fail; 772 goto fail;
773 773
774 /* test IR_CAL_OK to see if we need init */ 774 /* test IR_CAL_OK to see if we need init */
@@ -787,12 +787,12 @@ static int tda18271_init(struct dvb_frontend *fe)
787 787
788 /* power up */ 788 /* power up */
789 ret = tda18271_set_standby_mode(fe, 0, 0, 0); 789 ret = tda18271_set_standby_mode(fe, 0, 0, 0);
790 if (ret < 0) 790 if (tda_fail(ret))
791 goto fail; 791 goto fail;
792 792
793 /* initialization */ 793 /* initialization */
794 ret = tda18271_ir_cal_init(fe); 794 ret = tda18271_ir_cal_init(fe);
795 if (ret < 0) 795 if (tda_fail(ret))
796 goto fail; 796 goto fail;
797 797
798 if (priv->id == TDA18271HDC2) 798 if (priv->id == TDA18271HDC2)
@@ -813,7 +813,7 @@ static int tda18271_tune(struct dvb_frontend *fe,
813 freq, map->if_freq, bw, map->agc_mode, map->std); 813 freq, map->if_freq, bw, map->agc_mode, map->std);
814 814
815 ret = tda18271_init(fe); 815 ret = tda18271_init(fe);
816 if (ret < 0) 816 if (tda_fail(ret))
817 goto fail; 817 goto fail;
818 818
819 mutex_lock(&priv->lock); 819 mutex_lock(&priv->lock);
@@ -894,7 +894,7 @@ static int tda18271_set_params(struct dvb_frontend *fe,
894 894
895 ret = tda18271_tune(fe, map, freq, bw); 895 ret = tda18271_tune(fe, map, freq, bw);
896 896
897 if (ret < 0) 897 if (tda_fail(ret))
898 goto fail; 898 goto fail;
899 899
900 priv->frequency = freq; 900 priv->frequency = freq;
@@ -950,7 +950,7 @@ static int tda18271_set_analog_params(struct dvb_frontend *fe,
950 950
951 ret = tda18271_tune(fe, map, freq, 0); 951 ret = tda18271_tune(fe, map, freq, 0);
952 952
953 if (ret < 0) 953 if (tda_fail(ret))
954 goto fail; 954 goto fail;
955 955
956 priv->frequency = freq; 956 priv->frequency = freq;
@@ -1153,10 +1153,10 @@ struct dvb_frontend *tda18271_attach(struct dvb_frontend *fe, u8 addr,
1153 if (cfg) 1153 if (cfg)
1154 priv->small_i2c = cfg->small_i2c; 1154 priv->small_i2c = cfg->small_i2c;
1155 1155
1156 if (tda18271_get_id(fe) < 0) 1156 if (tda_fail(tda18271_get_id(fe)))
1157 goto fail; 1157 goto fail;
1158 1158
1159 if (tda18271_assign_map_layout(fe) < 0) 1159 if (tda_fail(tda18271_assign_map_layout(fe)))
1160 goto fail; 1160 goto fail;
1161 1161
1162 mutex_lock(&priv->lock); 1162 mutex_lock(&priv->lock);
diff --git a/drivers/media/common/tuners/tda18271-priv.h b/drivers/media/common/tuners/tda18271-priv.h
index 2bc5eb368ea2..81a739365f8c 100644
--- a/drivers/media/common/tuners/tda18271-priv.h
+++ b/drivers/media/common/tuners/tda18271-priv.h
@@ -153,6 +153,15 @@ extern int tda18271_debug;
153#define tda_reg(fmt, arg...) dprintk(KERN_DEBUG, DBG_REG, fmt, ##arg) 153#define tda_reg(fmt, arg...) dprintk(KERN_DEBUG, DBG_REG, fmt, ##arg)
154#define tda_cal(fmt, arg...) dprintk(KERN_DEBUG, DBG_CAL, fmt, ##arg) 154#define tda_cal(fmt, arg...) dprintk(KERN_DEBUG, DBG_CAL, fmt, ##arg)
155 155
156#define tda_fail(ret) \
157({ \
158 int __ret; \
159 __ret = (ret < 0); \
160 if (__ret) \
161 tda_printk(KERN_ERR, "error %d on line %d\n", ret, __LINE__);\
162 __ret; \
163})
164
156/*---------------------------------------------------------------------*/ 165/*---------------------------------------------------------------------*/
157 166
158enum tda18271_map_type { 167enum tda18271_map_type {