]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
V4L/DVB (8531): mxl5007t: move i2c gate handling outside of mutex protected code...
authorMichael Krufky <mkrufky@linuxtv.org>
Sat, 26 Jul 2008 15:06:57 +0000 (12:06 -0300)
committerMauro Carvalho Chehab <mchehab@infradead.org>
Sun, 27 Jul 2008 14:07:33 +0000 (11:07 -0300)
There is no reason to protect the i2c gate handling within the mxl5007t
state mutex.

Thanks to Steven Toth for pointing this out.

Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
drivers/media/common/tuners/mxl5007t.c

index f3b193ac6614b422a99f18c5ea315cd9a9a945c3..4a1ea5425850252bd6bcac4b2372cfda5cf74a68 100644 (file)
@@ -660,11 +660,11 @@ static int mxl5007t_get_status(struct dvb_frontend *fe, u32 *status)
        s32 rf_input_level;
        int ret;
 
-       mutex_lock(&state->lock);
-
        if (fe->ops.i2c_gate_ctrl)
                fe->ops.i2c_gate_ctrl(fe, 1);
 
+       mutex_lock(&state->lock);
+
        ret = mxl5007t_synth_lock_status(state, &rf_locked, &ref_locked);
        if (mxl_fail(ret))
                goto fail;
@@ -676,10 +676,11 @@ static int mxl5007t_get_status(struct dvb_frontend *fe, u32 *status)
                goto fail;
        mxl_debug("rf input power: %d", rf_input_level);
 fail:
+       mutex_unlock(&state->lock);
+
        if (fe->ops.i2c_gate_ctrl)
                fe->ops.i2c_gate_ctrl(fe, 0);
 
-       mutex_unlock(&state->lock);
        return ret;
 }
 
@@ -730,11 +731,11 @@ static int mxl5007t_set_params(struct dvb_frontend *fe,
                return -EINVAL;
        }
 
-       mutex_lock(&state->lock);
-
        if (fe->ops.i2c_gate_ctrl)
                fe->ops.i2c_gate_ctrl(fe, 1);
 
+       mutex_lock(&state->lock);
+
        ret = mxl5007t_tuner_init(state, mode);
        if (mxl_fail(ret))
                goto fail;
@@ -747,10 +748,11 @@ static int mxl5007t_set_params(struct dvb_frontend *fe,
        state->bandwidth = (fe->ops.info.type == FE_OFDM) ?
                params->u.ofdm.bandwidth : 0;
 fail:
+       mutex_unlock(&state->lock);
+
        if (fe->ops.i2c_gate_ctrl)
                fe->ops.i2c_gate_ctrl(fe, 0);
 
-       mutex_unlock(&state->lock);
        return ret;
 }
 
@@ -802,11 +804,11 @@ static int mxl5007t_set_analog_params(struct dvb_frontend *fe,
        }
        mxl_debug("setting mxl5007 to system %s", mode_name);
 
-       mutex_lock(&state->lock);
-
        if (fe->ops.i2c_gate_ctrl)
                fe->ops.i2c_gate_ctrl(fe, 1);
 
+       mutex_lock(&state->lock);
+
        ret = mxl5007t_tuner_init(state, cable ? cbl_mode : ota_mode);
        if (mxl_fail(ret))
                goto fail;
@@ -818,10 +820,11 @@ static int mxl5007t_set_analog_params(struct dvb_frontend *fe,
        state->frequency = freq;
        state->bandwidth = 0;
 fail:
+       mutex_unlock(&state->lock);
+
        if (fe->ops.i2c_gate_ctrl)
                fe->ops.i2c_gate_ctrl(fe, 0);
 
-       mutex_unlock(&state->lock);
        return ret;
 }
 
@@ -833,11 +836,11 @@ static int mxl5007t_init(struct dvb_frontend *fe)
        int ret;
        u8 d;
 
-       mutex_lock(&state->lock);
-
        if (fe->ops.i2c_gate_ctrl)
                fe->ops.i2c_gate_ctrl(fe, 1);
 
+       mutex_lock(&state->lock);
+
        ret = mxl5007t_read_reg(state, 0x05, &d);
        if (mxl_fail(ret))
                goto fail;
@@ -845,11 +848,11 @@ static int mxl5007t_init(struct dvb_frontend *fe)
        ret = mxl5007t_write_reg(state, 0x05, d | 0x01);
        mxl_fail(ret);
 fail:
+       mutex_unlock(&state->lock);
+
        if (fe->ops.i2c_gate_ctrl)
                fe->ops.i2c_gate_ctrl(fe, 0);
 
-       mutex_unlock(&state->lock);
-
        return ret;
 }
 
@@ -859,11 +862,11 @@ static int mxl5007t_sleep(struct dvb_frontend *fe)
        int ret;
        u8 d;
 
-       mutex_lock(&state->lock);
-
        if (fe->ops.i2c_gate_ctrl)
                fe->ops.i2c_gate_ctrl(fe, 1);
 
+       mutex_lock(&state->lock);
+
        ret = mxl5007t_read_reg(state, 0x05, &d);
        if (mxl_fail(ret))
                goto fail;
@@ -871,11 +874,11 @@ static int mxl5007t_sleep(struct dvb_frontend *fe)
        ret = mxl5007t_write_reg(state, 0x05, d & ~0x01);
        mxl_fail(ret);
 fail:
+       mutex_unlock(&state->lock);
+
        if (fe->ops.i2c_gate_ctrl)
                fe->ops.i2c_gate_ctrl(fe, 0);
 
-       mutex_unlock(&state->lock);
-
        return ret;
 }
 
@@ -995,18 +998,18 @@ struct dvb_frontend *mxl5007t_attach(struct dvb_frontend *fe,
 
                mutex_init(&state->lock);
 
-               mutex_lock(&state->lock);
-
                if (fe->ops.i2c_gate_ctrl)
                        fe->ops.i2c_gate_ctrl(fe, 1);
 
+               mutex_lock(&state->lock);
+
                ret = mxl5007t_get_chip_id(state);
 
+               mutex_unlock(&state->lock);
+
                if (fe->ops.i2c_gate_ctrl)
                        fe->ops.i2c_gate_ctrl(fe, 0);
 
-               mutex_unlock(&state->lock);
-
                /* check return value of mxl5007t_get_chip_id */
                if (mxl_fail(ret))
                        goto fail;