Commit 96506a50 authored by Andreas Regel's avatar Andreas Regel Committed by Mauro Carvalho Chehab

V4L/DVB (13976): [STV090x] Added mutex protection around tuner I2C access.

With this change it is possible to have the same I2C address for both tuners.
Signed-off-by: default avatarAndreas Regel <andreas.regel@gmx.de>
Signed-off-by: default avatarManu Abraham <manu@linuxtv.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 97f7a2ae
...@@ -758,6 +758,9 @@ static int stv090x_i2c_gate_ctrl(struct dvb_frontend *fe, int enable) ...@@ -758,6 +758,9 @@ static int stv090x_i2c_gate_ctrl(struct dvb_frontend *fe, int enable)
struct stv090x_state *state = fe->demodulator_priv; struct stv090x_state *state = fe->demodulator_priv;
u32 reg; u32 reg;
if (enable)
mutex_lock(&state->internal->tuner_lock);
reg = STV090x_READ_DEMOD(state, I2CRPT); reg = STV090x_READ_DEMOD(state, I2CRPT);
if (enable) { if (enable) {
dprintk(FE_DEBUG, 1, "Enable Gate"); dprintk(FE_DEBUG, 1, "Enable Gate");
...@@ -771,9 +774,14 @@ static int stv090x_i2c_gate_ctrl(struct dvb_frontend *fe, int enable) ...@@ -771,9 +774,14 @@ static int stv090x_i2c_gate_ctrl(struct dvb_frontend *fe, int enable)
if ((STV090x_WRITE_DEMOD(state, I2CRPT, reg)) < 0) if ((STV090x_WRITE_DEMOD(state, I2CRPT, reg)) < 0)
goto err; goto err;
} }
if (!enable)
mutex_unlock(&state->internal->tuner_lock);
return 0; return 0;
err: err:
dprintk(FE_ERROR, 1, "I/O error"); dprintk(FE_ERROR, 1, "I/O error");
mutex_unlock(&state->internal->tuner_lock);
return -1; return -1;
} }
...@@ -4439,6 +4447,7 @@ struct dvb_frontend *stv090x_attach(const struct stv090x_config *config, ...@@ -4439,6 +4447,7 @@ struct dvb_frontend *stv090x_attach(const struct stv090x_config *config,
} }
mutex_init(&state->internal->demod_lock); mutex_init(&state->internal->demod_lock);
mutex_init(&state->internal->tuner_lock);
if (stv090x_sleep(&state->frontend) < 0) { if (stv090x_sleep(&state->frontend) < 0) {
dprintk(FE_ERROR, 1, "Error putting device to sleep"); dprintk(FE_ERROR, 1, "Error putting device to sleep");
......
...@@ -235,6 +235,7 @@ struct stv090x_internal { ...@@ -235,6 +235,7 @@ struct stv090x_internal {
u8 i2c_addr; u8 i2c_addr;
struct mutex demod_lock; /* Lock access to shared register */ struct mutex demod_lock; /* Lock access to shared register */
struct mutex tuner_lock; /* Lock access to tuners */
s32 mclk; /* Masterclock Divider factor */ s32 mclk; /* Masterclock Divider factor */
u32 dev_ver; u32 dev_ver;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment