Commit be4a5e7f authored by Gordon Hecker's avatar Gordon Hecker Committed by Mauro Carvalho Chehab

[media] af9015: fix i2c failures for dual-tuner devices

The i2c failures were caused by enabling both i2c gates
at the same time while putting the tuners asleep.

This patch removes the init() and sleep() callbacks from the tuner,
to prevent frontend.c from calling
  i2c_gate_ctrl
  tuner init / sleep
  i2c_gate_ctrl
without holding the lock.
tuner init() and sleep() are instead called in frontend init() and
sleep().
Signed-off-by: default avatarGordon Hecker <ghecker@gmx.de>
Signed-off-by: default avatarAntti Palosaari <crope@iki.fi>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent d3db22e1
...@@ -1141,7 +1141,18 @@ static int af9015_af9013_init(struct dvb_frontend *fe) ...@@ -1141,7 +1141,18 @@ static int af9015_af9013_init(struct dvb_frontend *fe)
return -EAGAIN; return -EAGAIN;
ret = priv->init[adap->id](fe); ret = priv->init[adap->id](fe);
if (ret)
goto err_unlock;
if (priv->tuner_ops_init[adap->id]) {
if (fe->ops.i2c_gate_ctrl)
fe->ops.i2c_gate_ctrl(fe, 1);
ret = priv->tuner_ops_init[adap->id](fe);
if (fe->ops.i2c_gate_ctrl)
fe->ops.i2c_gate_ctrl(fe, 0);
}
err_unlock:
mutex_unlock(&adap->dev->usb_mutex); mutex_unlock(&adap->dev->usb_mutex);
return ret; return ret;
...@@ -1157,8 +1168,19 @@ static int af9015_af9013_sleep(struct dvb_frontend *fe) ...@@ -1157,8 +1168,19 @@ static int af9015_af9013_sleep(struct dvb_frontend *fe)
if (mutex_lock_interruptible(&adap->dev->usb_mutex)) if (mutex_lock_interruptible(&adap->dev->usb_mutex))
return -EAGAIN; return -EAGAIN;
if (priv->tuner_ops_sleep[adap->id]) {
if (fe->ops.i2c_gate_ctrl)
fe->ops.i2c_gate_ctrl(fe, 1);
ret = priv->tuner_ops_sleep[adap->id](fe);
if (fe->ops.i2c_gate_ctrl)
fe->ops.i2c_gate_ctrl(fe, 0);
if (ret)
goto err_unlock;
}
ret = priv->sleep[adap->id](fe); ret = priv->sleep[adap->id](fe);
err_unlock:
mutex_unlock(&adap->dev->usb_mutex); mutex_unlock(&adap->dev->usb_mutex);
return ret; return ret;
...@@ -1283,6 +1305,7 @@ static struct mxl5007t_config af9015_mxl5007t_config = { ...@@ -1283,6 +1305,7 @@ static struct mxl5007t_config af9015_mxl5007t_config = {
static int af9015_tuner_attach(struct dvb_usb_adapter *adap) static int af9015_tuner_attach(struct dvb_usb_adapter *adap)
{ {
int ret; int ret;
struct af9015_state *state = adap->dev->priv;
deb_info("%s:\n", __func__); deb_info("%s:\n", __func__);
switch (af9015_af9013_config[adap->id].tuner) { switch (af9015_af9013_config[adap->id].tuner) {
...@@ -1340,6 +1363,14 @@ static int af9015_tuner_attach(struct dvb_usb_adapter *adap) ...@@ -1340,6 +1363,14 @@ static int af9015_tuner_attach(struct dvb_usb_adapter *adap)
err("Unknown tuner id:%d", err("Unknown tuner id:%d",
af9015_af9013_config[adap->id].tuner); af9015_af9013_config[adap->id].tuner);
} }
state->tuner_ops_sleep[adap->id] =
adap->fe_adap[0].fe->ops.tuner_ops.sleep;
adap->fe_adap[0].fe->ops.tuner_ops.sleep = 0;
state->tuner_ops_init[adap->id] =
adap->fe_adap[0].fe->ops.tuner_ops.init;
adap->fe_adap[0].fe->ops.tuner_ops.init = 0;
return ret; return ret;
} }
......
...@@ -108,6 +108,8 @@ struct af9015_state { ...@@ -108,6 +108,8 @@ struct af9015_state {
int (*read_status[2]) (struct dvb_frontend *fe, fe_status_t *status); int (*read_status[2]) (struct dvb_frontend *fe, fe_status_t *status);
int (*init[2]) (struct dvb_frontend *fe); int (*init[2]) (struct dvb_frontend *fe);
int (*sleep[2]) (struct dvb_frontend *fe); int (*sleep[2]) (struct dvb_frontend *fe);
int (*tuner_ops_init[2]) (struct dvb_frontend *fe);
int (*tuner_ops_sleep[2]) (struct dvb_frontend *fe);
}; };
struct af9015_config { struct af9015_config {
......
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