The patch number 7844 was added via Michael Krufky <[EMAIL PROTECTED]>
to http://linuxtv.org/hg/v4l-dvb master development tree.

Kernel patches in this development tree may be modified to be backward
compatible with older kernels. Compatibility modifications will be
removed before inclusion into the mainstream Kernel

If anyone has any objections, please let us know by sending a message to:
        [EMAIL PROTECTED]

------

From: Michael Krufky  <[EMAIL PROTECTED]>
tda18271: add tda_fail macro to log error cases


Signed-off-by: Michael Krufky <[EMAIL PROTECTED]>


---

 linux/drivers/media/common/tuners/tda18271-common.c |   14 +--
 linux/drivers/media/common/tuners/tda18271-fe.c     |   56 ++++++------
 linux/drivers/media/common/tuners/tda18271-priv.h   |    9 +
 3 files changed, 44 insertions(+), 35 deletions(-)

diff -r 9068de03549c -r 623c8043082d 
linux/drivers/media/common/tuners/tda18271-common.c
--- a/linux/drivers/media/common/tuners/tda18271-common.c       Sun May 04 
16:26:47 2008 -0400
+++ b/linux/drivers/media/common/tuners/tda18271-common.c       Sun May 04 
17:32:21 2008 -0400
@@ -576,7 +576,7 @@ int tda18271_calc_main_pll(struct dvb_fr
        u32 div;
 
        int ret = tda18271_lookup_pll_map(fe, MAIN_PLL, &freq, &pd, &d);
-       if (ret < 0)
+       if (tda_fail(ret))
                goto fail;
 
        regs[R_MPD]   = (0x77 & pd);
@@ -608,7 +608,7 @@ int tda18271_calc_cal_pll(struct dvb_fro
        u32 div;
 
        int ret = tda18271_lookup_pll_map(fe, CAL_PLL, &freq, &pd, &d);
-       if (ret < 0)
+       if (tda_fail(ret))
                goto fail;
 
        regs[R_CPD]   = pd;
@@ -632,7 +632,7 @@ int tda18271_calc_bp_filter(struct dvb_f
        u8 val;
 
        int ret = tda18271_lookup_map(fe, BP_FILTER, freq, &val);
-       if (ret < 0)
+       if (tda_fail(ret))
                goto fail;
 
        regs[R_EP1]  &= ~0x07; /* clear bp filter bits */
@@ -649,7 +649,7 @@ int tda18271_calc_km(struct dvb_frontend
        u8 val;
 
        int ret = tda18271_lookup_map(fe, RF_CAL_KMCO, freq, &val);
-       if (ret < 0)
+       if (tda_fail(ret))
                goto fail;
 
        regs[R_EB13] &= ~0x7c; /* clear k & m bits */
@@ -666,7 +666,7 @@ int tda18271_calc_rf_band(struct dvb_fro
        u8 val;
 
        int ret = tda18271_lookup_map(fe, RF_BAND, freq, &val);
-       if (ret < 0)
+       if (tda_fail(ret))
                goto fail;
 
        regs[R_EP2]  &= ~0xe0; /* clear rf band bits */
@@ -683,7 +683,7 @@ int tda18271_calc_gain_taper(struct dvb_
        u8 val;
 
        int ret = tda18271_lookup_map(fe, GAIN_TAPER, freq, &val);
-       if (ret < 0)
+       if (tda_fail(ret))
                goto fail;
 
        regs[R_EP2]  &= ~0x1f; /* clear gain taper bits */
@@ -700,7 +700,7 @@ int tda18271_calc_ir_measure(struct dvb_
        u8 val;
 
        int ret = tda18271_lookup_map(fe, IR_MEASURE, freq, &val);
-       if (ret < 0)
+       if (tda_fail(ret))
                goto fail;
 
        regs[R_EP5] &= ~0x07;
diff -r 9068de03549c -r 623c8043082d 
linux/drivers/media/common/tuners/tda18271-fe.c
--- a/linux/drivers/media/common/tuners/tda18271-fe.c   Sun May 04 16:26:47 
2008 -0400
+++ b/linux/drivers/media/common/tuners/tda18271-fe.c   Sun May 04 17:32:21 
2008 -0400
@@ -88,7 +88,7 @@ static int tda18271_channel_configuratio
        regs[R_EB22]  = 0x00;
        regs[R_EB22] |= map->rfagc_top;
        ret = tda18271_write_regs(fe, R_EB22, 1);
-       if (ret < 0)
+       if (tda_fail(ret))
                goto fail;
 
        /* --------------------------------------------------------------- */
@@ -126,7 +126,7 @@ static int tda18271_channel_configuratio
        regs[R_EB1]  &= ~0x01;
 
        ret = tda18271_write_regs(fe, R_EB1, 1);
-       if (ret < 0)
+       if (tda_fail(ret))
                goto fail;
 
        /* --------------------------------------------------------------- */
@@ -148,7 +148,7 @@ static int tda18271_channel_configuratio
        }
 
        ret = tda18271_write_regs(fe, R_TM, 7);
-       if (ret < 0)
+       if (tda_fail(ret))
                goto fail;
 
        /* force charge pump source */
@@ -226,7 +226,7 @@ static int tda18271c2_rf_tracking_filter
 
        /* power up */
        ret = tda18271_set_standby_mode(fe, 0, 0, 0);
-       if (ret < 0)
+       if (tda_fail(ret))
                goto fail;
 
        /* read die current temperature */
@@ -238,8 +238,8 @@ static int tda18271c2_rf_tracking_filter
        rf_tab = regs[R_EB14];
 
        i = tda18271_lookup_rf_band(fe, &freq, NULL);
-       if (i < 0)
-               return -EINVAL;
+       if (tda_fail(i))
+               return i;
 
        if ((0 == map[i].rf3) || (freq / 1000 < map[i].rf2)) {
                approx = map[i].rf_a1 *
@@ -274,20 +274,20 @@ static int tda18271_por(struct dvb_front
        /* power up detector 1 */
        regs[R_EB12] &= ~0x20;
        ret = tda18271_write_regs(fe, R_EB12, 1);
-       if (ret < 0)
+       if (tda_fail(ret))
                goto fail;
 
        regs[R_EB18] &= ~0x80; /* turn agc1 loop on */
        regs[R_EB18] &= ~0x03; /* set agc1_gain to  6 dB */
        ret = tda18271_write_regs(fe, R_EB18, 1);
-       if (ret < 0)
+       if (tda_fail(ret))
                goto fail;
 
        regs[R_EB21] |= 0x03; /* set agc2_gain to -6 dB */
 
        /* POR mode */
        ret = tda18271_set_standby_mode(fe, 1, 0, 0);
-       if (ret < 0)
+       if (tda_fail(ret))
                goto fail;
 
        /* disable 1.5 MHz low pass filter */
@@ -439,7 +439,7 @@ static int tda18271_powerscan(struct dvb
 
        /* read power detection info, stored in EB10 */
        ret = tda18271_read_extended(fe);
-       if (ret < 0)
+       if (tda_fail(ret))
                return ret;
 
        /* algorithm initialization */
@@ -467,7 +467,7 @@ static int tda18271_powerscan(struct dvb
 
                /* read power detection info, stored in EB10 */
                ret = tda18271_read_extended(fe);
-               if (ret < 0)
+               if (tda_fail(ret))
                        return ret;
 
                count += 200;
@@ -512,12 +512,12 @@ static int tda18271_powerscan_init(struc
        regs[R_EP4]  &= ~0x1c; /* clear if level bits */
 
        ret = tda18271_write_regs(fe, R_EP3, 2);
-       if (ret < 0)
+       if (tda_fail(ret))
                goto fail;
 
        regs[R_EB18] &= ~0x03; /* set agc1_gain to   6 dB */
        ret = tda18271_write_regs(fe, R_EB18, 1);
-       if (ret < 0)
+       if (tda_fail(ret))
                goto fail;
 
        regs[R_EB21] &= ~0x03; /* set agc2_gain to -15 dB */
@@ -547,7 +547,7 @@ static int tda18271_rf_tracking_filters_
 
        i = tda18271_lookup_rf_band(fe, &freq, NULL);
 
-       if (i < 0)
+       if (tda_fail(i))
                return i;
 
        rf_default[RF1] = 1000 * map[i].rf1_def;
@@ -561,7 +561,7 @@ static int tda18271_rf_tracking_filters_
 
                /* look for optimized calibration frequency */
                bcal = tda18271_powerscan(fe, &rf_default[rf], &rf_freq[rf]);
-               if (bcal < 0)
+               if (tda_fail(bcal))
                        return bcal;
 
                tda18271_calc_rf_cal(fe, &rf_freq[rf]);
@@ -611,7 +611,7 @@ static int tda18271_calc_rf_filter_curve
        msleep(200);
 
        ret = tda18271_powerscan_init(fe);
-       if (ret < 0)
+       if (tda_fail(ret))
                goto fail;
 
        /* rf band calibration */
@@ -619,7 +619,7 @@ static int tda18271_calc_rf_filter_curve
                ret =
                tda18271_rf_tracking_filters_init(fe, 1000 *
                                                  priv->rf_cal_state[i].rfmax);
-               if (ret < 0)
+               if (tda_fail(ret))
                        goto fail;
        }
 
@@ -644,11 +644,11 @@ static int tda18271c2_rf_cal_init(struct
                return 0;
 
        ret = tda18271_calc_rf_filter_curve(fe);
-       if (ret < 0)
+       if (tda_fail(ret))
                goto fail;
 
        ret = tda18271_por(fe);
-       if (ret < 0)
+       if (tda_fail(ret))
                goto fail;
 
        tda_info("tda18271: RF tracking filter calibration complete\n");
@@ -716,7 +716,7 @@ static int tda18271c1_rf_tracking_filter
        tda18271_calc_main_pll(fe, N);
 
        ret = tda18271_write_regs(fe, R_EP3, 11);
-       if (ret < 0)
+       if (tda_fail(ret))
                return ret;
 
        msleep(5); /* RF tracking filter calibration initialization */
@@ -769,7 +769,7 @@ static int tda18271_ir_cal_init(struct d
        int ret;
 
        ret = tda18271_read_regs(fe);
-       if (ret < 0)
+       if (tda_fail(ret))
                goto fail;
 
        /* test IR_CAL_OK to see if we need init */
@@ -788,12 +788,12 @@ static int tda18271_init(struct dvb_fron
 
        /* power up */
        ret = tda18271_set_standby_mode(fe, 0, 0, 0);
-       if (ret < 0)
+       if (tda_fail(ret))
                goto fail;
 
        /* initialization */
        ret = tda18271_ir_cal_init(fe);
-       if (ret < 0)
+       if (tda_fail(ret))
                goto fail;
 
        if (priv->id == TDA18271HDC2)
@@ -814,7 +814,7 @@ static int tda18271_tune(struct dvb_fron
                freq, map->if_freq, bw, map->agc_mode, map->std);
 
        ret = tda18271_init(fe);
-       if (ret < 0)
+       if (tda_fail(ret))
                goto fail;
 
        mutex_lock(&priv->lock);
@@ -895,7 +895,7 @@ static int tda18271_set_params(struct dv
 
        ret = tda18271_tune(fe, map, freq, bw);
 
-       if (ret < 0)
+       if (tda_fail(ret))
                goto fail;
 
        priv->frequency = freq;
@@ -951,7 +951,7 @@ static int tda18271_set_analog_params(st
 
        ret = tda18271_tune(fe, map, freq, 0);
 
-       if (ret < 0)
+       if (tda_fail(ret))
                goto fail;
 
        priv->frequency = freq;
@@ -1154,10 +1154,10 @@ struct dvb_frontend *tda18271_attach(str
                if (cfg)
                        priv->small_i2c = cfg->small_i2c;
 
-               if (tda18271_get_id(fe) < 0)
+               if (tda_fail(tda18271_get_id(fe)))
                        goto fail;
 
-               if (tda18271_assign_map_layout(fe) < 0)
+               if (tda_fail(tda18271_assign_map_layout(fe)))
                        goto fail;
 
                mutex_lock(&priv->lock);
diff -r 9068de03549c -r 623c8043082d 
linux/drivers/media/common/tuners/tda18271-priv.h
--- a/linux/drivers/media/common/tuners/tda18271-priv.h Sun May 04 16:26:47 
2008 -0400
+++ b/linux/drivers/media/common/tuners/tda18271-priv.h Sun May 04 17:32:21 
2008 -0400
@@ -162,6 +162,15 @@ extern int tda18271_debug;
 #define tda_reg(fmt, arg...)  dprintk(KERN_DEBUG, DBG_REG,  fmt, ##arg)
 #define tda_cal(fmt, arg...)  dprintk(KERN_DEBUG, DBG_CAL,  fmt, ##arg)
 
+#define tda_fail(ret)                                                       \
+({                                                                          \
+       int __ret;                                                           \
+       __ret = (ret < 0);                                                   \
+       if (__ret)                                                           \
+               tda_printk(KERN_ERR, "error %d on line %d\n", ret, __LINE__);\
+       __ret;                                                               \
+})
+
 /*---------------------------------------------------------------------*/
 
 enum tda18271_map_type {


---

Patch is available at: 
http://linuxtv.org/hg/v4l-dvb/rev/623c8043082d77d6d75f31a4c1f682df89f67046

_______________________________________________
linuxtv-commits mailing list
linuxtv-commits@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits

Reply via email to