#include "mt2063.h"
 
-static unsigned int verbose;
-module_param(verbose, int, 0644);
+static unsigned int debug;
+module_param(debug, int, 0644);
+MODULE_PARM_DESC(debug, "Set Verbosity level");
+
+#define dprintk(level, fmt, arg...) do {                               \
+if (debug >= level)                                                    \
+       printk(KERN_DEBUG "mt2063 %s: " fmt, __func__, ## arg); \
+} while (0)
+
 
 /* positive error codes used internally */
 
                .len = len + 1
        };
 
+       dprintk(2, "\n");
+
        msg.buf[0] = reg;
        memcpy(msg.buf + 1, data, len);
 
 {
        u32 status;
 
+       dprintk(2, "\n");
+
        if (reg >= MT2063_REG_END_REGS)
                return -ERANGE;
 
        struct dvb_frontend *fe = state->frontend;
        u32 i = 0;
 
+       dprintk(2, "\n");
+
        if (fe->ops.i2c_gate_ctrl)
                fe->ops.i2c_gate_ctrl(fe, 1);
 
                                            struct MT2063_ExclZone_t *pPrevNode)
 {
        struct MT2063_ExclZone_t *pNode;
+
+       dprintk(2, "\n");
+
        /*  Check for a node in the free list  */
        if (pAS_Info->freeZones != NULL) {
                /*  Use one from the free list  */
 {
        struct MT2063_ExclZone_t *pNext = pNodeToRemove->next_;
 
+       dprintk(2, "\n");
+
        /*  Make previous node point to the subsequent node  */
        if (pPrevNode != NULL)
                pPrevNode->next_ = pNext;
        struct MT2063_ExclZone_t *pPrev = NULL;
        struct MT2063_ExclZone_t *pNext = NULL;
 
+       dprintk(2, "\n");
+
        /*  Check to see if this overlaps the 1st IF filter  */
        if ((f_max > (pAS_Info->f_if1_Center - (pAS_Info->f_if1_bw / 2)))
            && (f_min < (pAS_Info->f_if1_Center + (pAS_Info->f_if1_bw / 2)))
 {
        u32 center;
 
+       dprintk(2, "\n");
+
        pAS_Info->nZones = 0;   /*  this clears the used list  */
        pAS_Info->usedZones = NULL;     /*  reset ptr                  */
        pAS_Info->freeZones = NULL;     /*  reset ptr                  */
             pAS_Info->f_LO2_Step) ? pAS_Info->f_LO1_Step : pAS_Info->
            f_LO2_Step;
        u32 f_Center;
-
        s32 i;
        s32 j = 0;
        u32 bDesiredExcluded = 0;
        struct MT2063_ExclZone_t *pNode = pAS_Info->usedZones;
        struct MT2063_FIFZone_t zones[MT2063_MAX_ZONES];
 
+       dprintk(2, "\n");
+
        if (pAS_Info->nZones == 0)
                return f_Desired;
 
        s32 f_Spur;
        u32 ma, mb, mc, md, me, mf;
        u32 lo_gcd, gd_Scale, gc_Scale, gf_Scale, hgds, hgfs, hgcs;
+
+       dprintk(2, "\n");
+
        *fm = 0;
 
        /*
        pAS_Info->bSpurAvoided = 0;
        pAS_Info->nSpursFound = 0;
 
+       dprintk(2, "\n");
+
        if (pAS_Info->maxH1 == 0)
                return 0;
 
        u32 status;
        u32 nDelays = 0;
 
+       dprintk(2, "\n");
+
        /*  LO2 Lock bit was in a different place for B0 version  */
        if (state->tuner_id == MT2063_B0)
                LO2LK = 0x40;
 static u32 mt2063_get_dnc_output_enable(struct mt2063_state *state,
                                        enum MT2063_DNC_Output_Enable *pValue)
 {
+       dprintk(2, "\n");
+
        if ((state->reg[MT2063_REG_DNC_GAIN] & 0x03) == 0x03) { /* if DNC1 is off */
                if ((state->reg[MT2063_REG_VGA_GAIN] & 0x03) == 0x03)   /* if DNC2 is off */
                        *pValue = MT2063_DNC_NONE;
        u32 status = 0; /* Status to be returned        */
        u8 val = 0;
 
+       dprintk(2, "\n");
+
        /* selects, which DNC output is used */
        switch (nValue) {
        case MT2063_DNC_NONE:
        u8 val;
        u32 longval;
 
+       dprintk(2, "\n");
+
        if (Mode >= MT2063_NUM_RCVR_MODES)
                status = -ERANGE;
 
 {
        u32 status = 0;
 
+       dprintk(2, "\n");
        Bits = (enum MT2063_Mask_Bits)(Bits & MT2063_ALL_SD);   /* Only valid bits for this tuner */
        if ((Bits & 0xFF00) != 0) {
                state->reg[MT2063_REG_PWR_2] &= ~(u8) (Bits >> 8);
 {
        u32 status;
 
+       dprintk(2, "\n");
        if (Shutdown == 1)
                state->reg[MT2063_REG_PWR_1] |= 0x04;
        else
        u8 val;
        u32 RFBand;
 
+       dprintk(2, "\n");
        /*  Check the input and output frequency ranges                   */
        if ((f_in < MT2063_MIN_FIN_FREQ) || (f_in > MT2063_MAX_FIN_FREQ))
                return -EINVAL;
        u32 fcu_osc;
        u32 i;
 
+       dprintk(2, "\n");
+
        state->rcvr_mode = MT2063_CABLE_QAM;
 
        /*  Read the Part/Rev code from the tuner */
        status = mt2063_read(state, MT2063_REG_PART_REV, state->reg, 1);
-       if (status < 0)
+       if (status < 0) {
+               printk(KERN_ERR "Can't read mt2063 part ID\n");
                return status;
+       }
 
        /* Check the part/rev code */
        if (((state->reg[MT2063_REG_PART_REV] != MT2063_B0)     /*  MT2063 B0  */
                             &state->reg[MT2063_REG_RSVD_3B], 1);
 
        /* b7 != 0 ==> NOT MT2063 */
-       if (status < 0 || ((state->reg[MT2063_REG_RSVD_3B] & 0x80) != 0x00))
+       if (status < 0 || ((state->reg[MT2063_REG_RSVD_3B] & 0x80) != 0x00)) {
+               printk(KERN_ERR "Can't read mt2063 2nd part ID\n");
                return -ENODEV; /*  Wrong tuner Part/Rev code */
+       }
 
        /*  Reset the tuner  */
        status = mt2063_write(state, MT2063_REG_LO2CQ_3, &all_resets, 1);
        struct mt2063_state *state = fe->tuner_priv;
        int status;
 
+       dprintk(2, "\n");
+
        *tuner_status = 0;
        status = mt2063_lockStatus(state);
        if (status < 0)
 {
        struct mt2063_state *state = fe->tuner_priv;
 
+       dprintk(2, "\n");
+
        fe->tuner_priv = NULL;
        kfree(state);
 
        s32 rcvr_mode = 0;
        int status;
 
+       dprintk(2, "\n");
+
        switch (params->mode) {
        case V4L2_TUNER_RADIO:
                pict_car = 38900000;
        s32 if_mid = 0;
        s32 rcvr_mode = 0;
 
+       dprintk(2, "\n");
+
        if (c->bandwidth_hz == 0)
                return -EINVAL;
        if (c->bandwidth_hz <= 6000000)
 {
        struct mt2063_state *state = fe->tuner_priv;
 
+       dprintk(2, "\n");
+
        *freq = state->frequency;
        return 0;
 }
 {
        struct mt2063_state *state = fe->tuner_priv;
 
+       dprintk(2, "\n");
+
        *bw = state->AS_Data.f_out_bw - 750000;
        return 0;
 }
 {
        struct mt2063_state *state = NULL;
 
+       dprintk(2, "\n");
+
        state = kzalloc(sizeof(struct mt2063_state), GFP_KERNEL);
        if (state == NULL)
                goto error;
        struct mt2063_state *state = fe->tuner_priv;
        int err = 0;
 
+       dprintk(2, "\n");
+
        err = MT2063_SoftwareShutdown(state, 1);
        if (err < 0)
                printk(KERN_ERR "%s: Couldn't shutdown\n", __func__);
        struct mt2063_state *state = fe->tuner_priv;
        int err = 0;
 
+       dprintk(2, "\n");
+
        err = MT2063_ClearPowerMaskBits(state, MT2063_ALL_SD);
        if (err < 0)
                printk(KERN_ERR "%s: Invalid parameter\n", __func__);
 }
 EXPORT_SYMBOL_GPL(tuner_MT2063_ClearPowerMaskBits);
 
-
-MODULE_PARM_DESC(verbose, "Set Verbosity level");
-
 MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>");
 MODULE_DESCRIPTION("MT2063 Silicon tuner");
 MODULE_LICENSE("GPL");