diff options
author | Antti Palosaari <crope@iki.fi> | 2012-03-14 09:27:31 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-03-19 18:41:07 -0400 |
commit | 6d535bd8829b18c6b5276d65f8f25e57dd0bcbed (patch) | |
tree | d363401deeebd2166463f01e48f1ffcb4c74ec00 /drivers/media | |
parent | be4a5e7f0e279b751a23570da583ec41ca32a34f (diff) |
[media] af9015: fix i2c failures for dual-tuner devices - part 2
Some changes for previous patch I liked to do.
Just move tuner init and sleep to own functions from the demod
init and sleep functions. Functionality remains still almost the same.
Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/dvb/dvb-usb/af9015.c | 74 | ||||
-rw-r--r-- | drivers/media/dvb/dvb-usb/af9015.h | 4 |
2 files changed, 48 insertions, 30 deletions
diff --git a/drivers/media/dvb/dvb-usb/af9015.c b/drivers/media/dvb/dvb-usb/af9015.c index 9307b4ca4b77..7e70ea50ef26 100644 --- a/drivers/media/dvb/dvb-usb/af9015.c +++ b/drivers/media/dvb/dvb-usb/af9015.c | |||
@@ -1141,18 +1141,7 @@ static int af9015_af9013_init(struct dvb_frontend *fe) | |||
1141 | return -EAGAIN; | 1141 | return -EAGAIN; |
1142 | 1142 | ||
1143 | ret = priv->init[adap->id](fe); | 1143 | ret = priv->init[adap->id](fe); |
1144 | if (ret) | ||
1145 | goto err_unlock; | ||
1146 | |||
1147 | if (priv->tuner_ops_init[adap->id]) { | ||
1148 | if (fe->ops.i2c_gate_ctrl) | ||
1149 | fe->ops.i2c_gate_ctrl(fe, 1); | ||
1150 | ret = priv->tuner_ops_init[adap->id](fe); | ||
1151 | if (fe->ops.i2c_gate_ctrl) | ||
1152 | fe->ops.i2c_gate_ctrl(fe, 0); | ||
1153 | } | ||
1154 | 1144 | ||
1155 | err_unlock: | ||
1156 | mutex_unlock(&adap->dev->usb_mutex); | 1145 | mutex_unlock(&adap->dev->usb_mutex); |
1157 | 1146 | ||
1158 | return ret; | 1147 | return ret; |
@@ -1168,24 +1157,48 @@ static int af9015_af9013_sleep(struct dvb_frontend *fe) | |||
1168 | if (mutex_lock_interruptible(&adap->dev->usb_mutex)) | 1157 | if (mutex_lock_interruptible(&adap->dev->usb_mutex)) |
1169 | return -EAGAIN; | 1158 | return -EAGAIN; |
1170 | 1159 | ||
1171 | if (priv->tuner_ops_sleep[adap->id]) { | ||
1172 | if (fe->ops.i2c_gate_ctrl) | ||
1173 | fe->ops.i2c_gate_ctrl(fe, 1); | ||
1174 | ret = priv->tuner_ops_sleep[adap->id](fe); | ||
1175 | if (fe->ops.i2c_gate_ctrl) | ||
1176 | fe->ops.i2c_gate_ctrl(fe, 0); | ||
1177 | if (ret) | ||
1178 | goto err_unlock; | ||
1179 | } | ||
1180 | |||
1181 | ret = priv->sleep[adap->id](fe); | 1160 | ret = priv->sleep[adap->id](fe); |
1182 | 1161 | ||
1183 | err_unlock: | ||
1184 | mutex_unlock(&adap->dev->usb_mutex); | 1162 | mutex_unlock(&adap->dev->usb_mutex); |
1185 | 1163 | ||
1186 | return ret; | 1164 | return ret; |
1187 | } | 1165 | } |
1188 | 1166 | ||
1167 | /* override tuner callbacks for resource locking */ | ||
1168 | static int af9015_tuner_init(struct dvb_frontend *fe) | ||
1169 | { | ||
1170 | int ret; | ||
1171 | struct dvb_usb_adapter *adap = fe->dvb->priv; | ||
1172 | struct af9015_state *priv = adap->dev->priv; | ||
1173 | |||
1174 | if (mutex_lock_interruptible(&adap->dev->usb_mutex)) | ||
1175 | return -EAGAIN; | ||
1176 | |||
1177 | ret = priv->tuner_init[adap->id](fe); | ||
1178 | |||
1179 | mutex_unlock(&adap->dev->usb_mutex); | ||
1180 | |||
1181 | return ret; | ||
1182 | } | ||
1183 | |||
1184 | /* override tuner callbacks for resource locking */ | ||
1185 | static int af9015_tuner_sleep(struct dvb_frontend *fe) | ||
1186 | { | ||
1187 | int ret; | ||
1188 | struct dvb_usb_adapter *adap = fe->dvb->priv; | ||
1189 | struct af9015_state *priv = adap->dev->priv; | ||
1190 | |||
1191 | if (mutex_lock_interruptible(&adap->dev->usb_mutex)) | ||
1192 | return -EAGAIN; | ||
1193 | |||
1194 | ret = priv->tuner_sleep[adap->id](fe); | ||
1195 | |||
1196 | mutex_unlock(&adap->dev->usb_mutex); | ||
1197 | |||
1198 | return ret; | ||
1199 | } | ||
1200 | |||
1201 | |||
1189 | static int af9015_af9013_frontend_attach(struct dvb_usb_adapter *adap) | 1202 | static int af9015_af9013_frontend_attach(struct dvb_usb_adapter *adap) |
1190 | { | 1203 | { |
1191 | int ret; | 1204 | int ret; |
@@ -1364,13 +1377,18 @@ static int af9015_tuner_attach(struct dvb_usb_adapter *adap) | |||
1364 | af9015_af9013_config[adap->id].tuner); | 1377 | af9015_af9013_config[adap->id].tuner); |
1365 | } | 1378 | } |
1366 | 1379 | ||
1367 | state->tuner_ops_sleep[adap->id] = | 1380 | if (adap->fe_adap[0].fe->ops.tuner_ops.init) { |
1368 | adap->fe_adap[0].fe->ops.tuner_ops.sleep; | 1381 | state->tuner_init[adap->id] = |
1369 | adap->fe_adap[0].fe->ops.tuner_ops.sleep = 0; | 1382 | adap->fe_adap[0].fe->ops.tuner_ops.init; |
1383 | adap->fe_adap[0].fe->ops.tuner_ops.init = af9015_tuner_init; | ||
1384 | } | ||
1385 | |||
1386 | if (adap->fe_adap[0].fe->ops.tuner_ops.sleep) { | ||
1387 | state->tuner_sleep[adap->id] = | ||
1388 | adap->fe_adap[0].fe->ops.tuner_ops.sleep; | ||
1389 | adap->fe_adap[0].fe->ops.tuner_ops.sleep = af9015_tuner_sleep; | ||
1390 | } | ||
1370 | 1391 | ||
1371 | state->tuner_ops_init[adap->id] = | ||
1372 | adap->fe_adap[0].fe->ops.tuner_ops.init; | ||
1373 | adap->fe_adap[0].fe->ops.tuner_ops.init = 0; | ||
1374 | return ret; | 1392 | return ret; |
1375 | } | 1393 | } |
1376 | 1394 | ||
diff --git a/drivers/media/dvb/dvb-usb/af9015.h b/drivers/media/dvb/dvb-usb/af9015.h index ee2ec5b8d570..2f68419e899b 100644 --- a/drivers/media/dvb/dvb-usb/af9015.h +++ b/drivers/media/dvb/dvb-usb/af9015.h | |||
@@ -108,8 +108,8 @@ struct af9015_state { | |||
108 | int (*read_status[2]) (struct dvb_frontend *fe, fe_status_t *status); | 108 | int (*read_status[2]) (struct dvb_frontend *fe, fe_status_t *status); |
109 | int (*init[2]) (struct dvb_frontend *fe); | 109 | int (*init[2]) (struct dvb_frontend *fe); |
110 | int (*sleep[2]) (struct dvb_frontend *fe); | 110 | int (*sleep[2]) (struct dvb_frontend *fe); |
111 | int (*tuner_ops_init[2]) (struct dvb_frontend *fe); | 111 | int (*tuner_init[2]) (struct dvb_frontend *fe); |
112 | int (*tuner_ops_sleep[2]) (struct dvb_frontend *fe); | 112 | int (*tuner_sleep[2]) (struct dvb_frontend *fe); |
113 | }; | 113 | }; |
114 | 114 | ||
115 | struct af9015_config { | 115 | struct af9015_config { |