Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Michael Krufky and committed by
Mauro Carvalho Chehab
4bd5d107 10ed0bf4

+44 -35
+7 -7
drivers/media/common/tuners/tda18271-common.c
··· 508 508 u32 div; 509 509 510 510 int ret = tda18271_lookup_pll_map(fe, MAIN_PLL, &freq, &pd, &d); 511 - if (ret < 0) 511 + if (tda_fail(ret)) 512 512 goto fail; 513 513 514 514 regs[R_MPD] = (0x77 & pd); ··· 540 540 u32 div; 541 541 542 542 int ret = tda18271_lookup_pll_map(fe, CAL_PLL, &freq, &pd, &d); 543 - if (ret < 0) 543 + if (tda_fail(ret)) 544 544 goto fail; 545 545 546 546 regs[R_CPD] = pd; ··· 564 564 u8 val; 565 565 566 566 int ret = tda18271_lookup_map(fe, BP_FILTER, freq, &val); 567 - if (ret < 0) 567 + if (tda_fail(ret)) 568 568 goto fail; 569 569 570 570 regs[R_EP1] &= ~0x07; /* clear bp filter bits */ ··· 581 581 u8 val; 582 582 583 583 int ret = tda18271_lookup_map(fe, RF_CAL_KMCO, freq, &val); 584 - if (ret < 0) 584 + if (tda_fail(ret)) 585 585 goto fail; 586 586 587 587 regs[R_EB13] &= ~0x7c; /* clear k & m bits */ ··· 598 598 u8 val; 599 599 600 600 int ret = tda18271_lookup_map(fe, RF_BAND, freq, &val); 601 - if (ret < 0) 601 + if (tda_fail(ret)) 602 602 goto fail; 603 603 604 604 regs[R_EP2] &= ~0xe0; /* clear rf band bits */ ··· 615 615 u8 val; 616 616 617 617 int ret = tda18271_lookup_map(fe, GAIN_TAPER, freq, &val); 618 - if (ret < 0) 618 + if (tda_fail(ret)) 619 619 goto fail; 620 620 621 621 regs[R_EP2] &= ~0x1f; /* clear gain taper bits */ ··· 632 632 u8 val; 633 633 634 634 int ret = tda18271_lookup_map(fe, IR_MEASURE, freq, &val); 635 - if (ret < 0) 635 + if (tda_fail(ret)) 636 636 goto fail; 637 637 638 638 regs[R_EP5] &= ~0x07;
+28 -28
drivers/media/common/tuners/tda18271-fe.c
··· 87 87 regs[R_EB22] = 0x00; 88 88 regs[R_EB22] |= map->rfagc_top; 89 89 ret = tda18271_write_regs(fe, R_EB22, 1); 90 - if (ret < 0) 90 + if (tda_fail(ret)) 91 91 goto fail; 92 92 93 93 /* --------------------------------------------------------------- */ ··· 125 125 regs[R_EB1] &= ~0x01; 126 126 127 127 ret = tda18271_write_regs(fe, R_EB1, 1); 128 - if (ret < 0) 128 + if (tda_fail(ret)) 129 129 goto fail; 130 130 131 131 /* --------------------------------------------------------------- */ ··· 147 147 } 148 148 149 149 ret = tda18271_write_regs(fe, R_TM, 7); 150 - if (ret < 0) 150 + if (tda_fail(ret)) 151 151 goto fail; 152 152 153 153 /* force charge pump source */ ··· 225 225 226 226 /* power up */ 227 227 ret = tda18271_set_standby_mode(fe, 0, 0, 0); 228 - if (ret < 0) 228 + if (tda_fail(ret)) 229 229 goto fail; 230 230 231 231 /* read die current temperature */ ··· 237 237 rf_tab = regs[R_EB14]; 238 238 239 239 i = tda18271_lookup_rf_band(fe, &freq, NULL); 240 - if (i < 0) 241 - return -EINVAL; 240 + if (tda_fail(i)) 241 + return i; 242 242 243 243 if ((0 == map[i].rf3) || (freq / 1000 < map[i].rf2)) { 244 244 approx = map[i].rf_a1 * ··· 273 273 /* power up detector 1 */ 274 274 regs[R_EB12] &= ~0x20; 275 275 ret = tda18271_write_regs(fe, R_EB12, 1); 276 - if (ret < 0) 276 + if (tda_fail(ret)) 277 277 goto fail; 278 278 279 279 regs[R_EB18] &= ~0x80; /* turn agc1 loop on */ 280 280 regs[R_EB18] &= ~0x03; /* set agc1_gain to 6 dB */ 281 281 ret = tda18271_write_regs(fe, R_EB18, 1); 282 - if (ret < 0) 282 + if (tda_fail(ret)) 283 283 goto fail; 284 284 285 285 regs[R_EB21] |= 0x03; /* set agc2_gain to -6 dB */ 286 286 287 287 /* POR mode */ 288 288 ret = tda18271_set_standby_mode(fe, 1, 0, 0); 289 - if (ret < 0) 289 + if (tda_fail(ret)) 290 290 goto fail; 291 291 292 292 /* disable 1.5 MHz low pass filter */ ··· 438 438 439 439 /* read power detection info, stored in EB10 */ 440 440 ret = tda18271_read_extended(fe); 441 - if (ret < 0) 441 + if (tda_fail(ret)) 442 442 return ret; 443 443 444 444 /* algorithm initialization */ ··· 466 466 467 467 /* read power detection info, stored in EB10 */ 468 468 ret = tda18271_read_extended(fe); 469 - if (ret < 0) 469 + if (tda_fail(ret)) 470 470 return ret; 471 471 472 472 count += 200; ··· 511 511 regs[R_EP4] &= ~0x1c; /* clear if level bits */ 512 512 513 513 ret = tda18271_write_regs(fe, R_EP3, 2); 514 - if (ret < 0) 514 + if (tda_fail(ret)) 515 515 goto fail; 516 516 517 517 regs[R_EB18] &= ~0x03; /* set agc1_gain to 6 dB */ 518 518 ret = tda18271_write_regs(fe, R_EB18, 1); 519 - if (ret < 0) 519 + if (tda_fail(ret)) 520 520 goto fail; 521 521 522 522 regs[R_EB21] &= ~0x03; /* set agc2_gain to -15 dB */ ··· 546 546 547 547 i = tda18271_lookup_rf_band(fe, &freq, NULL); 548 548 549 - if (i < 0) 549 + if (tda_fail(i)) 550 550 return i; 551 551 552 552 rf_default[RF1] = 1000 * map[i].rf1_def; ··· 560 560 561 561 /* look for optimized calibration frequency */ 562 562 bcal = tda18271_powerscan(fe, &rf_default[rf], &rf_freq[rf]); 563 - if (bcal < 0) 563 + if (tda_fail(bcal)) 564 564 return bcal; 565 565 566 566 tda18271_calc_rf_cal(fe, &rf_freq[rf]); ··· 610 610 msleep(200); 611 611 612 612 ret = tda18271_powerscan_init(fe); 613 - if (ret < 0) 613 + if (tda_fail(ret)) 614 614 goto fail; 615 615 616 616 /* rf band calibration */ ··· 618 618 ret = 619 619 tda18271_rf_tracking_filters_init(fe, 1000 * 620 620 priv->rf_cal_state[i].rfmax); 621 - if (ret < 0) 621 + if (tda_fail(ret)) 622 622 goto fail; 623 623 } 624 624 ··· 643 643 return 0; 644 644 645 645 ret = tda18271_calc_rf_filter_curve(fe); 646 - if (ret < 0) 646 + if (tda_fail(ret)) 647 647 goto fail; 648 648 649 649 ret = tda18271_por(fe); 650 - if (ret < 0) 650 + if (tda_fail(ret)) 651 651 goto fail; 652 652 653 653 tda_info("tda18271: RF tracking filter calibration complete\n"); ··· 715 715 tda18271_calc_main_pll(fe, N); 716 716 717 717 ret = tda18271_write_regs(fe, R_EP3, 11); 718 - if (ret < 0) 718 + if (tda_fail(ret)) 719 719 return ret; 720 720 721 721 msleep(5); /* RF tracking filter calibration initialization */ ··· 768 768 int ret; 769 769 770 770 ret = tda18271_read_regs(fe); 771 - if (ret < 0) 771 + if (tda_fail(ret)) 772 772 goto fail; 773 773 774 774 /* test IR_CAL_OK to see if we need init */ ··· 787 787 788 788 /* power up */ 789 789 ret = tda18271_set_standby_mode(fe, 0, 0, 0); 790 - if (ret < 0) 790 + if (tda_fail(ret)) 791 791 goto fail; 792 792 793 793 /* initialization */ 794 794 ret = tda18271_ir_cal_init(fe); 795 - if (ret < 0) 795 + if (tda_fail(ret)) 796 796 goto fail; 797 797 798 798 if (priv->id == TDA18271HDC2) ··· 813 813 freq, map->if_freq, bw, map->agc_mode, map->std); 814 814 815 815 ret = tda18271_init(fe); 816 - if (ret < 0) 816 + if (tda_fail(ret)) 817 817 goto fail; 818 818 819 819 mutex_lock(&priv->lock); ··· 894 894 895 895 ret = tda18271_tune(fe, map, freq, bw); 896 896 897 - if (ret < 0) 897 + if (tda_fail(ret)) 898 898 goto fail; 899 899 900 900 priv->frequency = freq; ··· 950 950 951 951 ret = tda18271_tune(fe, map, freq, 0); 952 952 953 - if (ret < 0) 953 + if (tda_fail(ret)) 954 954 goto fail; 955 955 956 956 priv->frequency = freq; ··· 1153 1153 if (cfg) 1154 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 1157 goto fail; 1158 1158 1159 - if (tda18271_assign_map_layout(fe) < 0) 1159 + if (tda_fail(tda18271_assign_map_layout(fe))) 1160 1160 goto fail; 1161 1161 1162 1162 mutex_lock(&priv->lock);
+9
drivers/media/common/tuners/tda18271-priv.h
··· 153 153 #define tda_reg(fmt, arg...) dprintk(KERN_DEBUG, DBG_REG, fmt, ##arg) 154 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 158 167 enum tda18271_map_type {