V4L/DVB (4386): Convert DVB devices to use dvb_attach()

Only devices using > 1 frontend were ported; ones which did not are left
using static binding.

Signed-off-by: Andrew de Quincey <adq_dvb@lidskialf.net>
Acked-by: Michael Krufky <mkrufky@linuxtv.org>
Acked-by: Trent Piepho <xyzzy@speakeasy.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
diff --git a/drivers/media/dvb/bt8xx/dvb-bt8xx.c b/drivers/media/dvb/bt8xx/dvb-bt8xx.c
index b715b97..6f0bb73 100644
--- a/drivers/media/dvb/bt8xx/dvb-bt8xx.c
+++ b/drivers/media/dvb/bt8xx/dvb-bt8xx.c
@@ -67,7 +67,7 @@
 
 static int dvb_bt8xx_start_feed(struct dvb_demux_feed *dvbdmxfeed)
 {
-	struct dvb_demux *dvbdmx = dvbdmxfeed->demux;
+	struct dvb_demux*dvbdmx = dvbdmxfeed->demux;
 	struct dvb_bt8xx_card *card = dvbdmx->priv;
 	int rc;
 
@@ -595,15 +595,14 @@
 
 static void frontend_init(struct dvb_bt8xx_card *card, u32 type)
 {
-	int ret;
 	struct dst_state* state = NULL;
 
 	switch(type) {
 	case BTTV_BOARD_DVICO_DVBT_LITE:
-		card->fe = mt352_attach(&thomson_dtt7579_config, card->i2c_adapter);
+		card->fe = dvb_attach(mt352_attach, &thomson_dtt7579_config, card->i2c_adapter);
 
 		if (card->fe == NULL)
-			card->fe = zl10353_attach(&thomson_dtt7579_zl10353_config,
+			card->fe = dvb_attach(zl10353_attach, &thomson_dtt7579_zl10353_config,
 						  card->i2c_adapter);
 
 		if (card->fe != NULL) {
@@ -615,7 +614,7 @@
 
 	case BTTV_BOARD_DVICO_FUSIONHDTV_5_LITE:
 		lgdt330x_reset(card);
-		card->fe = lgdt330x_attach(&tdvs_tua6034_config, card->i2c_adapter);
+		card->fe = dvb_attach(lgdt330x_attach, &tdvs_tua6034_config, card->i2c_adapter);
 		if (card->fe != NULL) {
 			card->fe->ops.tuner_ops.set_params = tdvs_tua6034_tuner_set_params;
 			dprintk ("dvb_bt8xx: lgdt330x detected\n");
@@ -630,7 +629,7 @@
 
 		/* Old Nebula (marked (c)2003 on high profile pci card) has nxt6000 demod */
 		digitv_alps_tded4_reset(card);
-		card->fe = nxt6000_attach(&vp3021_alps_tded4_config, card->i2c_adapter);
+		card->fe = dvb_attach(nxt6000_attach, &vp3021_alps_tded4_config, card->i2c_adapter);
 		if (card->fe != NULL) {
 			card->fe->ops.tuner_ops.set_params = vp3021_alps_tded4_tuner_set_params;
 			dprintk ("dvb_bt8xx: an nxt6000 was detected on your digitv card\n");
@@ -639,7 +638,7 @@
 
 		/* New Nebula (marked (c)2005 on low profile pci card) has mt352 demod */
 		digitv_alps_tded4_reset(card);
-		card->fe = mt352_attach(&digitv_alps_tded4_config, card->i2c_adapter);
+		card->fe = dvb_attach(mt352_attach, &digitv_alps_tded4_config, card->i2c_adapter);
 
 		if (card->fe != NULL) {
 			card->fe->ops.tuner_ops.calc_regs = digitv_alps_tded4_tuner_calc_regs;
@@ -648,14 +647,14 @@
 		break;
 
 	case BTTV_BOARD_AVDVBT_761:
-		card->fe = sp887x_attach(&microtune_mt7202dtf_config, card->i2c_adapter);
+		card->fe = dvb_attach(sp887x_attach, &microtune_mt7202dtf_config, card->i2c_adapter);
 		if (card->fe) {
 			card->fe->ops.tuner_ops.set_params = microtune_mt7202dtf_tuner_set_params;
 		}
 		break;
 
 	case BTTV_BOARD_AVDVBT_771:
-		card->fe = mt352_attach(&advbt771_samsung_tdtc9251dh0_config, card->i2c_adapter);
+		card->fe = dvb_attach(mt352_attach, &advbt771_samsung_tdtc9251dh0_config, card->i2c_adapter);
 		if (card->fe != NULL) {
 			card->fe->ops.tuner_ops.calc_regs = advbt771_samsung_tdtc9251dh0_tuner_calc_regs;
 			card->fe->ops.info.frequency_min = 174000000;
@@ -672,7 +671,7 @@
 		state->bt = card->bt;
 
 		/*	DST is not a frontend, attaching the ASIC	*/
-		if ((dst_attach(state, &card->dvb_adapter)) == NULL) {
+		if (dvb_attach(dst_attach, state, &card->dvb_adapter) == NULL) {
 			printk("%s: Could not find a Twinhan DST.\n", __FUNCTION__);
 			break;
 		}
@@ -681,11 +680,11 @@
 		/*	Attach other DST peripherals if any		*/
 		/*	Conditional Access device			*/
 		if (state->dst_hw_cap & DST_TYPE_HAS_CA)
-			ret = dst_ca_attach(state, &card->dvb_adapter);
+			dvb_attach(dst_ca_attach, state, &card->dvb_adapter);
 		break;
 
 	case BTTV_BOARD_PINNACLESAT:
-		card->fe = cx24110_attach(&pctvsat_config, card->i2c_adapter);
+		card->fe = dvb_attach(cx24110_attach, &pctvsat_config, card->i2c_adapter);
 		if (card->fe) {
 			card->fe->ops.tuner_ops.init = pinnsat_tuner_init;
 			card->fe->ops.tuner_ops.sleep = pinnsat_tuner_sleep;
@@ -694,7 +693,7 @@
 		break;
 
 	case BTTV_BOARD_PC_HDTV:
-		card->fe = or51211_attach(&or51211_config, card->i2c_adapter);
+		card->fe = dvb_attach(or51211_attach, &or51211_config, card->i2c_adapter);
 		break;
 	}
 
@@ -707,8 +706,9 @@
 	else
 		if (dvb_register_frontend(&card->dvb_adapter, card->fe)) {
 			printk("dvb-bt8xx: Frontend registration failed!\n");
-			if (card->fe->ops.release)
-				card->fe->ops.release(card->fe);
+			dvb_detach(card->fe->ops.release_sec, card->fe);
+			dvb_detach(card->fe->ops.tuner_ops.release, card->fe);
+			dvb_detach(card->fe->ops.release, card->fe);
 			card->fe = NULL;
 		}
 }
@@ -925,8 +925,12 @@
 	card->demux.dmx.remove_frontend(&card->demux.dmx, &card->fe_hw);
 	dvb_dmxdev_release(&card->dmxdev);
 	dvb_dmx_release(&card->demux);
-	if (card->fe)
+	if (card->fe) {
 		dvb_unregister_frontend(card->fe);
+		dvb_detach(card->fe->ops.release_sec, card->fe);
+		dvb_detach(card->fe->ops.tuner_ops.release, card->fe);
+		dvb_detach(card->fe->ops.release, card->fe);
+	}
 	dvb_unregister_adapter(&card->dvb_adapter);
 
 	kfree(card);