Skip to content

Commit

Permalink
V4L/DVB (8531): mxl5007t: move i2c gate handling outside of mutex pro…
Browse files Browse the repository at this point in the history
…tected code blocks

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>
  • Loading branch information
Michael Krufky authored and Mauro Carvalho Chehab committed Jul 27, 2008
1 parent 59d2752 commit c39c1fd
Showing 1 changed file with 24 additions and 21 deletions.
45 changes: 24 additions & 21 deletions drivers/media/common/tuners/mxl5007t.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}

Expand Down Expand Up @@ -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;
Expand All @@ -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;
}

Expand Down Expand Up @@ -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;
Expand All @@ -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;
}

Expand All @@ -833,23 +836,23 @@ 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;

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;
}

Expand All @@ -859,23 +862,23 @@ 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;

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;
}

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit c39c1fd

Please sign in to comment.