Commit 639ffd2d authored by Luca Olivetti's avatar Luca Olivetti Committed by Mauro Carvalho Chehab

V4L/DVB (5932): Af9005 fix tuner module unload

This patch removes the useless tuner field and avoids a double free of 
the tuner (either mt2060 or qt1010).
Signed-off-by: default avatarLuca Olivetti <luca@ventoso.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@infradead.org>
parent be9a5c7d
...@@ -29,8 +29,6 @@ ...@@ -29,8 +29,6 @@
struct af9005_fe_state { struct af9005_fe_state {
struct dvb_usb_device *d; struct dvb_usb_device *d;
struct dvb_frontend *tuner;
fe_status_t stat; fe_status_t stat;
/* retraining parameters */ /* retraining parameters */
...@@ -447,7 +445,7 @@ static int af9005_fe_read_status(struct dvb_frontend *fe, fe_status_t * stat) ...@@ -447,7 +445,7 @@ static int af9005_fe_read_status(struct dvb_frontend *fe, fe_status_t * stat)
u8 temp; u8 temp;
int ret; int ret;
if (state->tuner == NULL) if (fe->ops.tuner_ops.release == NULL)
return -ENODEV; return -ENODEV;
*stat = 0; *stat = 0;
...@@ -493,7 +491,7 @@ static int af9005_fe_read_status(struct dvb_frontend *fe, fe_status_t * stat) ...@@ -493,7 +491,7 @@ static int af9005_fe_read_status(struct dvb_frontend *fe, fe_status_t * stat)
static int af9005_fe_read_ber(struct dvb_frontend *fe, u32 * ber) static int af9005_fe_read_ber(struct dvb_frontend *fe, u32 * ber)
{ {
struct af9005_fe_state *state = fe->demodulator_priv; struct af9005_fe_state *state = fe->demodulator_priv;
if (state->tuner == NULL) if (fe->ops.tuner_ops.release == NULL)
return -ENODEV; return -ENODEV;
af9005_fe_refresh_state(fe); af9005_fe_refresh_state(fe);
*ber = state->ber; *ber = state->ber;
...@@ -503,7 +501,7 @@ static int af9005_fe_read_ber(struct dvb_frontend *fe, u32 * ber) ...@@ -503,7 +501,7 @@ static int af9005_fe_read_ber(struct dvb_frontend *fe, u32 * ber)
static int af9005_fe_read_unc_blocks(struct dvb_frontend *fe, u32 * unc) static int af9005_fe_read_unc_blocks(struct dvb_frontend *fe, u32 * unc)
{ {
struct af9005_fe_state *state = fe->demodulator_priv; struct af9005_fe_state *state = fe->demodulator_priv;
if (state->tuner == NULL) if (fe->ops.tuner_ops.release == NULL)
return -ENODEV; return -ENODEV;
af9005_fe_refresh_state(fe); af9005_fe_refresh_state(fe);
*unc = state->unc; *unc = state->unc;
...@@ -517,7 +515,7 @@ static int af9005_fe_read_signal_strength(struct dvb_frontend *fe, ...@@ -517,7 +515,7 @@ static int af9005_fe_read_signal_strength(struct dvb_frontend *fe,
int ret; int ret;
u8 if_gain, rf_gain; u8 if_gain, rf_gain;
if (state->tuner == NULL) if (fe->ops.tuner_ops.release == NULL)
return -ENODEV; return -ENODEV;
ret = ret =
af9005_read_ofdm_register(state->d, xd_r_reg_aagc_rf_gain, af9005_read_ofdm_register(state->d, xd_r_reg_aagc_rf_gain,
...@@ -1041,7 +1039,7 @@ static int af9005_fe_init(struct dvb_frontend *fe) ...@@ -1041,7 +1039,7 @@ static int af9005_fe_init(struct dvb_frontend *fe)
return ret; return ret;
/* attach tuner and init */ /* attach tuner and init */
if (state->tuner == NULL) { if (fe->ops.tuner_ops.release == NULL) {
/* read tuner and board id from eeprom */ /* read tuner and board id from eeprom */
ret = af9005_read_eeprom(adap->dev, 0xc6, buf, 2); ret = af9005_read_eeprom(adap->dev, 0xc6, buf, 2);
if (ret) { if (ret) {
...@@ -1058,20 +1056,16 @@ static int af9005_fe_init(struct dvb_frontend *fe) ...@@ -1058,20 +1056,16 @@ static int af9005_fe_init(struct dvb_frontend *fe)
return ret; return ret;
} }
if1 = (u16) (buf[0] << 8) + buf[1]; if1 = (u16) (buf[0] << 8) + buf[1];
state->tuner = if (dvb_attach(mt2060_attach, fe, &adap->dev->i2c_adap,
dvb_attach(mt2060_attach, fe, &adap->dev->i2c_adap, &af9005_mt2060_config, if1) == NULL) {
&af9005_mt2060_config, if1);
if (state->tuner == NULL) {
deb_info("MT2060 attach failed\n"); deb_info("MT2060 attach failed\n");
return -ENODEV; return -ENODEV;
} }
break; break;
case 3: /* QT1010 */ case 3: /* QT1010 */
case 9: /* QT1010B */ case 9: /* QT1010B */
state->tuner = if (dvb_attach(qt1010_attach, fe, &adap->dev->i2c_adap,
dvb_attach(qt1010_attach, fe, &adap->dev->i2c_adap, &af9005_qt1010_config) ==NULL) {
&af9005_qt1010_config);
if (state->tuner == NULL) {
deb_info("QT1010 attach failed\n"); deb_info("QT1010 attach failed\n");
return -ENODEV; return -ENODEV;
} }
...@@ -1080,7 +1074,7 @@ static int af9005_fe_init(struct dvb_frontend *fe) ...@@ -1080,7 +1074,7 @@ static int af9005_fe_init(struct dvb_frontend *fe)
err("Unsupported tuner type %d", buf[0]); err("Unsupported tuner type %d", buf[0]);
return -ENODEV; return -ENODEV;
} }
ret = state->tuner->ops.tuner_ops.init(state->tuner); ret = fe->ops.tuner_ops.init(fe);
if (ret) if (ret)
return ret; return ret;
} }
...@@ -1118,7 +1112,7 @@ static int af9005_fe_set_frontend(struct dvb_frontend *fe, ...@@ -1118,7 +1112,7 @@ static int af9005_fe_set_frontend(struct dvb_frontend *fe,
deb_info("af9005_fe_set_frontend freq %d bw %d\n", fep->frequency, deb_info("af9005_fe_set_frontend freq %d bw %d\n", fep->frequency,
fep->u.ofdm.bandwidth); fep->u.ofdm.bandwidth);
if (state->tuner == NULL) { if (fe->ops.tuner_ops.release == NULL) {
err("Tuner not attached"); err("Tuner not attached");
return -ENODEV; return -ENODEV;
} }
...@@ -1199,7 +1193,7 @@ static int af9005_fe_set_frontend(struct dvb_frontend *fe, ...@@ -1199,7 +1193,7 @@ static int af9005_fe_set_frontend(struct dvb_frontend *fe,
return ret; return ret;
/* set tuner */ /* set tuner */
deb_info("set tuner\n"); deb_info("set tuner\n");
ret = state->tuner->ops.tuner_ops.set_params(state->tuner, fep); ret = fe->ops.tuner_ops.set_params(fe, fep);
if (ret) if (ret)
return ret; return ret;
...@@ -1435,12 +1429,6 @@ static void af9005_fe_release(struct dvb_frontend *fe) ...@@ -1435,12 +1429,6 @@ static void af9005_fe_release(struct dvb_frontend *fe)
{ {
struct af9005_fe_state *state = struct af9005_fe_state *state =
(struct af9005_fe_state *)fe->demodulator_priv; (struct af9005_fe_state *)fe->demodulator_priv;
if (state->tuner != NULL && state->tuner->ops.tuner_ops.release != NULL) {
state->tuner->ops.tuner_ops.release(state->tuner);
#ifdef CONFIG_DVB_CORE_ATTACH
symbol_put_addr(state->tuner->ops.tuner_ops.release);
#endif
}
kfree(state); kfree(state);
} }
...@@ -1458,7 +1446,6 @@ struct dvb_frontend *af9005_fe_attach(struct dvb_usb_device *d) ...@@ -1458,7 +1446,6 @@ struct dvb_frontend *af9005_fe_attach(struct dvb_usb_device *d)
deb_info("attaching frontend af9005\n"); deb_info("attaching frontend af9005\n");
state->d = d; state->d = d;
state->tuner = NULL;
state->opened = 0; state->opened = 0;
memcpy(&state->frontend.ops, &af9005_fe_ops, memcpy(&state->frontend.ops, &af9005_fe_ops,
......
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