aboutsummaryrefslogtreecommitdiff
path: root/drivers/media
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/common/tuners/mxl5007t.c45
1 files changed, 24 insertions, 21 deletions
diff --git a/drivers/media/common/tuners/mxl5007t.c b/drivers/media/common/tuners/mxl5007t.c
index f3b193ac661..4a1ea542585 100644
--- a/drivers/media/common/tuners/mxl5007t.c
+++ b/drivers/media/common/tuners/mxl5007t.c
@@ -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;