aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew de Quincey <adq_dvb@lidskialf.net>2006-08-08 08:10:08 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2006-09-26 10:53:25 -0400
commit2bfe031df6bd5e3b8e503eba8e3b6461d7c2c27e (patch)
tree2d7288c2221fb6f7ef98ef7a1ee3fef3f04cf87e
parentd995506062c974133ba66d0822e58a923d4d74d9 (diff)
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>
-rw-r--r--drivers/media/dvb/b2c2/flexcop-fe-tuner.c26
-rw-r--r--drivers/media/dvb/bt8xx/dst.c4
-rw-r--r--drivers/media/dvb/bt8xx/dst_ca.c4
-rw-r--r--drivers/media/dvb/bt8xx/dst_common.h2
-rw-r--r--drivers/media/dvb/bt8xx/dvb-bt8xx.c36
-rw-r--r--drivers/media/dvb/dvb-usb/cxusb.c10
-rw-r--r--drivers/media/dvb/dvb-usb/digitv.c4
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-dvb.c11
-rw-r--r--drivers/media/dvb/dvb-usb/umt-010.c2
-rw-r--r--drivers/media/dvb/frontends/dvb-pll.c8
-rw-r--r--drivers/media/dvb/frontends/dvb-pll.h4
-rw-r--r--drivers/media/dvb/ttpci/av7110.c39
-rw-r--r--drivers/media/dvb/ttpci/budget-av.c37
-rw-r--r--drivers/media/dvb/ttpci/budget-ci.c25
-rw-r--r--drivers/media/dvb/ttpci/budget-patch.c19
-rw-r--r--drivers/media/dvb/ttpci/budget.c26
-rw-r--r--drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c26
-rw-r--r--drivers/media/dvb/ttusb-dec/ttusb_dec.c6
-rw-r--r--drivers/media/video/cx88/cx88-dvb.c64
-rw-r--r--drivers/media/video/saa7134/saa7134-dvb.c40
-rw-r--r--drivers/media/video/video-buf-dvb.c6
21 files changed, 229 insertions, 170 deletions
diff --git a/drivers/media/dvb/b2c2/flexcop-fe-tuner.c b/drivers/media/dvb/b2c2/flexcop-fe-tuner.c
index 816e700ae14b..e2d2e65dea52 100644
--- a/drivers/media/dvb/b2c2/flexcop-fe-tuner.c
+++ b/drivers/media/dvb/b2c2/flexcop-fe-tuner.c
@@ -505,7 +505,7 @@ int flexcop_frontend_init(struct flexcop_device *fc)
505 struct dvb_frontend_ops *ops; 505 struct dvb_frontend_ops *ops;
506 506
507 /* try the sky v2.6 (stv0299/Samsung tbmu24112(sl1935)) */ 507 /* try the sky v2.6 (stv0299/Samsung tbmu24112(sl1935)) */
508 if ((fc->fe = stv0299_attach(&samsung_tbmu24112_config, &fc->i2c_adap)) != NULL) { 508 if ((fc->fe = dvb_attach(stv0299_attach, &samsung_tbmu24112_config, &fc->i2c_adap)) != NULL) {
509 ops = &fc->fe->ops; 509 ops = &fc->fe->ops;
510 510
511 ops->tuner_ops.set_params = samsung_tbmu24112_tuner_set_params; 511 ops->tuner_ops.set_params = samsung_tbmu24112_tuner_set_params;
@@ -519,36 +519,36 @@ int flexcop_frontend_init(struct flexcop_device *fc)
519 info("found the stv0299 at i2c address: 0x%02x",samsung_tbmu24112_config.demod_address); 519 info("found the stv0299 at i2c address: 0x%02x",samsung_tbmu24112_config.demod_address);
520 } else 520 } else
521 /* try the air dvb-t (mt352/Samsung tdtc9251dh0(??)) */ 521 /* try the air dvb-t (mt352/Samsung tdtc9251dh0(??)) */
522 if ((fc->fe = mt352_attach(&samsung_tdtc9251dh0_config, &fc->i2c_adap)) != NULL ) { 522 if ((fc->fe = dvb_attach(mt352_attach, &samsung_tdtc9251dh0_config, &fc->i2c_adap)) != NULL ) {
523 fc->dev_type = FC_AIR_DVB; 523 fc->dev_type = FC_AIR_DVB;
524 fc->fe->ops.tuner_ops.calc_regs = samsung_tdtc9251dh0_calc_regs; 524 fc->fe->ops.tuner_ops.calc_regs = samsung_tdtc9251dh0_calc_regs;
525 info("found the mt352 at i2c address: 0x%02x",samsung_tdtc9251dh0_config.demod_address); 525 info("found the mt352 at i2c address: 0x%02x",samsung_tdtc9251dh0_config.demod_address);
526 } else 526 } else
527 /* try the air atsc 2nd generation (nxt2002) */ 527 /* try the air atsc 2nd generation (nxt2002) */
528 if ((fc->fe = nxt200x_attach(&samsung_tbmv_config, &fc->i2c_adap)) != NULL) { 528 if ((fc->fe = dvb_attach(nxt200x_attach, &samsung_tbmv_config, &fc->i2c_adap)) != NULL) {
529 fc->dev_type = FC_AIR_ATSC2; 529 fc->dev_type = FC_AIR_ATSC2;
530 dvb_attach(dvb_pll_attach, fc->fe, 0x61, &fc->i2c_adap, &dvb_pll_samsung_tbmv); 530 dvb_attach(dvb_pll_attach, fc->fe, 0x61, &fc->i2c_adap, &dvb_pll_samsung_tbmv);
531 info("found the nxt2002 at i2c address: 0x%02x",samsung_tbmv_config.demod_address); 531 info("found the nxt2002 at i2c address: 0x%02x",samsung_tbmv_config.demod_address);
532 } else 532 } else
533 /* try the air atsc 3nd generation (lgdt3303) */ 533 /* try the air atsc 3nd generation (lgdt3303) */
534 if ((fc->fe = lgdt330x_attach(&air2pc_atsc_hd5000_config, &fc->i2c_adap)) != NULL) { 534 if ((fc->fe = dvb_attach(lgdt330x_attach, &air2pc_atsc_hd5000_config, &fc->i2c_adap)) != NULL) {
535 fc->dev_type = FC_AIR_ATSC3; 535 fc->dev_type = FC_AIR_ATSC3;
536 fc->fe->ops.tuner_ops.set_params = lgdt3303_tuner_set_params; 536 fc->fe->ops.tuner_ops.set_params = lgdt3303_tuner_set_params;
537 info("found the lgdt3303 at i2c address: 0x%02x",air2pc_atsc_hd5000_config.demod_address); 537 info("found the lgdt3303 at i2c address: 0x%02x",air2pc_atsc_hd5000_config.demod_address);
538 } else 538 } else
539 /* try the air atsc 1nd generation (bcm3510)/panasonic ct10s */ 539 /* try the air atsc 1nd generation (bcm3510)/panasonic ct10s */
540 if ((fc->fe = bcm3510_attach(&air2pc_atsc_first_gen_config, &fc->i2c_adap)) != NULL) { 540 if ((fc->fe = dvb_attach(bcm3510_attach, &air2pc_atsc_first_gen_config, &fc->i2c_adap)) != NULL) {
541 fc->dev_type = FC_AIR_ATSC1; 541 fc->dev_type = FC_AIR_ATSC1;
542 info("found the bcm3510 at i2c address: 0x%02x",air2pc_atsc_first_gen_config.demod_address); 542 info("found the bcm3510 at i2c address: 0x%02x",air2pc_atsc_first_gen_config.demod_address);
543 } else 543 } else
544 /* try the cable dvb (stv0297) */ 544 /* try the cable dvb (stv0297) */
545 if ((fc->fe = stv0297_attach(&alps_tdee4_stv0297_config, &fc->i2c_adap)) != NULL) { 545 if ((fc->fe = dvb_attach(stv0297_attach, &alps_tdee4_stv0297_config, &fc->i2c_adap)) != NULL) {
546 fc->dev_type = FC_CABLE; 546 fc->dev_type = FC_CABLE;
547 fc->fe->ops.tuner_ops.set_params = alps_tdee4_stv0297_tuner_set_params; 547 fc->fe->ops.tuner_ops.set_params = alps_tdee4_stv0297_tuner_set_params;
548 info("found the stv0297 at i2c address: 0x%02x",alps_tdee4_stv0297_config.demod_address); 548 info("found the stv0297 at i2c address: 0x%02x",alps_tdee4_stv0297_config.demod_address);
549 } else 549 } else
550 /* try the sky v2.3 (vp310/Samsung tbdu18132(tsa5059)) */ 550 /* try the sky v2.3 (vp310/Samsung tbdu18132(tsa5059)) */
551 if ((fc->fe = vp310_mt312_attach(&skystar23_samsung_tbdu18132_config, &fc->i2c_adap)) != NULL) { 551 if ((fc->fe = dvb_attach(vp310_mt312_attach, &skystar23_samsung_tbdu18132_config, &fc->i2c_adap)) != NULL) {
552 ops = &fc->fe->ops; 552 ops = &fc->fe->ops;
553 553
554 ops->tuner_ops.set_params = skystar23_samsung_tbdu18132_tuner_set_params; 554 ops->tuner_ops.set_params = skystar23_samsung_tbdu18132_tuner_set_params;
@@ -571,9 +571,9 @@ int flexcop_frontend_init(struct flexcop_device *fc)
571 } else { 571 } else {
572 if (dvb_register_frontend(&fc->dvb_adapter, fc->fe)) { 572 if (dvb_register_frontend(&fc->dvb_adapter, fc->fe)) {
573 err("frontend registration failed!"); 573 err("frontend registration failed!");
574 ops = &fc->fe->ops; 574 dvb_detach(fc->fe->ops.release_sec, fc->fe);
575 if (ops->release != NULL) 575 dvb_detach(fc->fe->ops.tuner_ops.release, fc->fe);
576 ops->release(fc->fe); 576 dvb_detach(fc->fe->ops.release, fc->fe);
577 fc->fe = NULL; 577 fc->fe = NULL;
578 return -EINVAL; 578 return -EINVAL;
579 } 579 }
@@ -584,8 +584,12 @@ int flexcop_frontend_init(struct flexcop_device *fc)
584 584
585void flexcop_frontend_exit(struct flexcop_device *fc) 585void flexcop_frontend_exit(struct flexcop_device *fc)
586{ 586{
587 if (fc->init_state & FC_STATE_FE_INIT) 587 if (fc->init_state & FC_STATE_FE_INIT) {
588 dvb_unregister_frontend(fc->fe); 588 dvb_unregister_frontend(fc->fe);
589 dvb_detach(fc->fe->ops.release_sec, fc->fe);
590 dvb_detach(fc->fe->ops.tuner_ops.release, fc->fe);
591 dvb_detach(fc->fe->ops.release, fc->fe);
592 }
589 593
590 fc->init_state &= ~FC_STATE_FE_INIT; 594 fc->init_state &= ~FC_STATE_FE_INIT;
591} 595}
diff --git a/drivers/media/dvb/bt8xx/dst.c b/drivers/media/dvb/bt8xx/dst.c
index 06ac899a9a26..91dea91b1a43 100644
--- a/drivers/media/dvb/bt8xx/dst.c
+++ b/drivers/media/dvb/bt8xx/dst.c
@@ -1715,6 +1715,10 @@ static int dst_get_frontend(struct dvb_frontend *fe, struct dvb_frontend_paramet
1715static void dst_release(struct dvb_frontend *fe) 1715static void dst_release(struct dvb_frontend *fe)
1716{ 1716{
1717 struct dst_state *state = fe->demodulator_priv; 1717 struct dst_state *state = fe->demodulator_priv;
1718
1719 if (state->dst_hw_cap & DST_TYPE_HAS_CA)
1720 symbol_put(dst_ca_attach);
1721
1718 kfree(state); 1722 kfree(state);
1719} 1723}
1720 1724
diff --git a/drivers/media/dvb/bt8xx/dst_ca.c b/drivers/media/dvb/bt8xx/dst_ca.c
index fa923b9b346e..c4ff1abc15c3 100644
--- a/drivers/media/dvb/bt8xx/dst_ca.c
+++ b/drivers/media/dvb/bt8xx/dst_ca.c
@@ -699,12 +699,12 @@ static struct dvb_device dvbdev_ca = {
699 .fops = &dst_ca_fops 699 .fops = &dst_ca_fops
700}; 700};
701 701
702int dst_ca_attach(struct dst_state *dst, struct dvb_adapter *dvb_adapter) 702ssize_t dst_ca_attach(struct dst_state *dst, struct dvb_adapter *dvb_adapter)
703{ 703{
704 struct dvb_device *dvbdev; 704 struct dvb_device *dvbdev;
705 dprintk(verbose, DST_CA_ERROR, 1, "registering DST-CA device"); 705 dprintk(verbose, DST_CA_ERROR, 1, "registering DST-CA device");
706 dvb_register_device(dvb_adapter, &dvbdev, &dvbdev_ca, dst, DVB_DEVICE_CA); 706 dvb_register_device(dvb_adapter, &dvbdev, &dvbdev_ca, dst, DVB_DEVICE_CA);
707 return 0; 707 return 1; // must return non-zero for dvb_attach() to work
708} 708}
709 709
710EXPORT_SYMBOL(dst_ca_attach); 710EXPORT_SYMBOL(dst_ca_attach);
diff --git a/drivers/media/dvb/bt8xx/dst_common.h b/drivers/media/dvb/bt8xx/dst_common.h
index 0677b047b3a7..383452f9e497 100644
--- a/drivers/media/dvb/bt8xx/dst_common.h
+++ b/drivers/media/dvb/bt8xx/dst_common.h
@@ -178,7 +178,7 @@ int write_dst(struct dst_state *state, u8 * data, u8 len);
178int read_dst(struct dst_state *state, u8 * ret, u8 len); 178int read_dst(struct dst_state *state, u8 * ret, u8 len);
179u8 dst_check_sum(u8 * buf, u32 len); 179u8 dst_check_sum(u8 * buf, u32 len);
180struct dst_state* dst_attach(struct dst_state* state, struct dvb_adapter *dvb_adapter); 180struct dst_state* dst_attach(struct dst_state* state, struct dvb_adapter *dvb_adapter);
181int dst_ca_attach(struct dst_state *state, struct dvb_adapter *dvb_adapter); 181ssize_t dst_ca_attach(struct dst_state *state, struct dvb_adapter *dvb_adapter);
182int dst_gpio_outb(struct dst_state* state, u32 mask, u32 enbb, u32 outhigh, int delay); 182int dst_gpio_outb(struct dst_state* state, u32 mask, u32 enbb, u32 outhigh, int delay);
183 183
184int dst_command(struct dst_state* state, u8 * data, u8 len); 184int dst_command(struct dst_state* state, u8 * data, u8 len);
diff --git a/drivers/media/dvb/bt8xx/dvb-bt8xx.c b/drivers/media/dvb/bt8xx/dvb-bt8xx.c
index b715b972d2fc..6f0bb7360991 100644
--- a/drivers/media/dvb/bt8xx/dvb-bt8xx.c
+++ b/drivers/media/dvb/bt8xx/dvb-bt8xx.c
@@ -67,7 +67,7 @@ static void dvb_bt8xx_task(unsigned long data)
67 67
68static int dvb_bt8xx_start_feed(struct dvb_demux_feed *dvbdmxfeed) 68static int dvb_bt8xx_start_feed(struct dvb_demux_feed *dvbdmxfeed)
69{ 69{
70 struct dvb_demux *dvbdmx = dvbdmxfeed->demux; 70 struct dvb_demux*dvbdmx = dvbdmxfeed->demux;
71 struct dvb_bt8xx_card *card = dvbdmx->priv; 71 struct dvb_bt8xx_card *card = dvbdmx->priv;
72 int rc; 72 int rc;
73 73
@@ -595,15 +595,14 @@ static void lgdt330x_reset(struct dvb_bt8xx_card *bt)
595 595
596static void frontend_init(struct dvb_bt8xx_card *card, u32 type) 596static void frontend_init(struct dvb_bt8xx_card *card, u32 type)
597{ 597{
598 int ret;
599 struct dst_state* state = NULL; 598 struct dst_state* state = NULL;
600 599
601 switch(type) { 600 switch(type) {
602 case BTTV_BOARD_DVICO_DVBT_LITE: 601 case BTTV_BOARD_DVICO_DVBT_LITE:
603 card->fe = mt352_attach(&thomson_dtt7579_config, card->i2c_adapter); 602 card->fe = dvb_attach(mt352_attach, &thomson_dtt7579_config, card->i2c_adapter);
604 603
605 if (card->fe == NULL) 604 if (card->fe == NULL)
606 card->fe = zl10353_attach(&thomson_dtt7579_zl10353_config, 605 card->fe = dvb_attach(zl10353_attach, &thomson_dtt7579_zl10353_config,
607 card->i2c_adapter); 606 card->i2c_adapter);
608 607
609 if (card->fe != NULL) { 608 if (card->fe != NULL) {
@@ -615,7 +614,7 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type)
615 614
616 case BTTV_BOARD_DVICO_FUSIONHDTV_5_LITE: 615 case BTTV_BOARD_DVICO_FUSIONHDTV_5_LITE:
617 lgdt330x_reset(card); 616 lgdt330x_reset(card);
618 card->fe = lgdt330x_attach(&tdvs_tua6034_config, card->i2c_adapter); 617 card->fe = dvb_attach(lgdt330x_attach, &tdvs_tua6034_config, card->i2c_adapter);
619 if (card->fe != NULL) { 618 if (card->fe != NULL) {
620 card->fe->ops.tuner_ops.set_params = tdvs_tua6034_tuner_set_params; 619 card->fe->ops.tuner_ops.set_params = tdvs_tua6034_tuner_set_params;
621 dprintk ("dvb_bt8xx: lgdt330x detected\n"); 620 dprintk ("dvb_bt8xx: lgdt330x detected\n");
@@ -630,7 +629,7 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type)
630 629
631 /* Old Nebula (marked (c)2003 on high profile pci card) has nxt6000 demod */ 630 /* Old Nebula (marked (c)2003 on high profile pci card) has nxt6000 demod */
632 digitv_alps_tded4_reset(card); 631 digitv_alps_tded4_reset(card);
633 card->fe = nxt6000_attach(&vp3021_alps_tded4_config, card->i2c_adapter); 632 card->fe = dvb_attach(nxt6000_attach, &vp3021_alps_tded4_config, card->i2c_adapter);
634 if (card->fe != NULL) { 633 if (card->fe != NULL) {
635 card->fe->ops.tuner_ops.set_params = vp3021_alps_tded4_tuner_set_params; 634 card->fe->ops.tuner_ops.set_params = vp3021_alps_tded4_tuner_set_params;
636 dprintk ("dvb_bt8xx: an nxt6000 was detected on your digitv card\n"); 635 dprintk ("dvb_bt8xx: an nxt6000 was detected on your digitv card\n");
@@ -639,7 +638,7 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type)
639 638
640 /* New Nebula (marked (c)2005 on low profile pci card) has mt352 demod */ 639 /* New Nebula (marked (c)2005 on low profile pci card) has mt352 demod */
641 digitv_alps_tded4_reset(card); 640 digitv_alps_tded4_reset(card);
642 card->fe = mt352_attach(&digitv_alps_tded4_config, card->i2c_adapter); 641 card->fe = dvb_attach(mt352_attach, &digitv_alps_tded4_config, card->i2c_adapter);
643 642
644 if (card->fe != NULL) { 643 if (card->fe != NULL) {
645 card->fe->ops.tuner_ops.calc_regs = digitv_alps_tded4_tuner_calc_regs; 644 card->fe->ops.tuner_ops.calc_regs = digitv_alps_tded4_tuner_calc_regs;
@@ -648,14 +647,14 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type)
648 break; 647 break;
649 648
650 case BTTV_BOARD_AVDVBT_761: 649 case BTTV_BOARD_AVDVBT_761:
651 card->fe = sp887x_attach(&microtune_mt7202dtf_config, card->i2c_adapter); 650 card->fe = dvb_attach(sp887x_attach, &microtune_mt7202dtf_config, card->i2c_adapter);
652 if (card->fe) { 651 if (card->fe) {
653 card->fe->ops.tuner_ops.set_params = microtune_mt7202dtf_tuner_set_params; 652 card->fe->ops.tuner_ops.set_params = microtune_mt7202dtf_tuner_set_params;
654 } 653 }
655 break; 654 break;
656 655
657 case BTTV_BOARD_AVDVBT_771: 656 case BTTV_BOARD_AVDVBT_771:
658 card->fe = mt352_attach(&advbt771_samsung_tdtc9251dh0_config, card->i2c_adapter); 657 card->fe = dvb_attach(mt352_attach, &advbt771_samsung_tdtc9251dh0_config, card->i2c_adapter);
659 if (card->fe != NULL) { 658 if (card->fe != NULL) {
660 card->fe->ops.tuner_ops.calc_regs = advbt771_samsung_tdtc9251dh0_tuner_calc_regs; 659 card->fe->ops.tuner_ops.calc_regs = advbt771_samsung_tdtc9251dh0_tuner_calc_regs;
661 card->fe->ops.info.frequency_min = 174000000; 660 card->fe->ops.info.frequency_min = 174000000;
@@ -672,7 +671,7 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type)
672 state->bt = card->bt; 671 state->bt = card->bt;
673 672
674 /* DST is not a frontend, attaching the ASIC */ 673 /* DST is not a frontend, attaching the ASIC */
675 if ((dst_attach(state, &card->dvb_adapter)) == NULL) { 674 if (dvb_attach(dst_attach, state, &card->dvb_adapter) == NULL) {
676 printk("%s: Could not find a Twinhan DST.\n", __FUNCTION__); 675 printk("%s: Could not find a Twinhan DST.\n", __FUNCTION__);
677 break; 676 break;
678 } 677 }
@@ -681,11 +680,11 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type)
681 /* Attach other DST peripherals if any */ 680 /* Attach other DST peripherals if any */
682 /* Conditional Access device */ 681 /* Conditional Access device */
683 if (state->dst_hw_cap & DST_TYPE_HAS_CA) 682 if (state->dst_hw_cap & DST_TYPE_HAS_CA)
684 ret = dst_ca_attach(state, &card->dvb_adapter); 683 dvb_attach(dst_ca_attach, state, &card->dvb_adapter);
685 break; 684 break;
686 685
687 case BTTV_BOARD_PINNACLESAT: 686 case BTTV_BOARD_PINNACLESAT:
688 card->fe = cx24110_attach(&pctvsat_config, card->i2c_adapter); 687 card->fe = dvb_attach(cx24110_attach, &pctvsat_config, card->i2c_adapter);
689 if (card->fe) { 688 if (card->fe) {
690 card->fe->ops.tuner_ops.init = pinnsat_tuner_init; 689 card->fe->ops.tuner_ops.init = pinnsat_tuner_init;
691 card->fe->ops.tuner_ops.sleep = pinnsat_tuner_sleep; 690 card->fe->ops.tuner_ops.sleep = pinnsat_tuner_sleep;
@@ -694,7 +693,7 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type)
694 break; 693 break;
695 694
696 case BTTV_BOARD_PC_HDTV: 695 case BTTV_BOARD_PC_HDTV:
697 card->fe = or51211_attach(&or51211_config, card->i2c_adapter); 696 card->fe = dvb_attach(or51211_attach, &or51211_config, card->i2c_adapter);
698 break; 697 break;
699 } 698 }
700 699
@@ -707,8 +706,9 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type)
707 else 706 else
708 if (dvb_register_frontend(&card->dvb_adapter, card->fe)) { 707 if (dvb_register_frontend(&card->dvb_adapter, card->fe)) {
709 printk("dvb-bt8xx: Frontend registration failed!\n"); 708 printk("dvb-bt8xx: Frontend registration failed!\n");
710 if (card->fe->ops.release) 709 dvb_detach(card->fe->ops.release_sec, card->fe);
711 card->fe->ops.release(card->fe); 710 dvb_detach(card->fe->ops.tuner_ops.release, card->fe);
711 dvb_detach(card->fe->ops.release, card->fe);
712 card->fe = NULL; 712 card->fe = NULL;
713 } 713 }
714} 714}
@@ -925,8 +925,12 @@ static void dvb_bt8xx_remove(struct bttv_sub_device *sub)
925 card->demux.dmx.remove_frontend(&card->demux.dmx, &card->fe_hw); 925 card->demux.dmx.remove_frontend(&card->demux.dmx, &card->fe_hw);
926 dvb_dmxdev_release(&card->dmxdev); 926 dvb_dmxdev_release(&card->dmxdev);
927 dvb_dmx_release(&card->demux); 927 dvb_dmx_release(&card->demux);
928 if (card->fe) 928 if (card->fe) {
929 dvb_unregister_frontend(card->fe); 929 dvb_unregister_frontend(card->fe);
930 dvb_detach(card->fe->ops.release_sec, card->fe);
931 dvb_detach(card->fe->ops.tuner_ops.release, card->fe);
932 dvb_detach(card->fe->ops.release, card->fe);
933 }
930 dvb_unregister_adapter(&card->dvb_adapter); 934 dvb_unregister_adapter(&card->dvb_adapter);
931 935
932 kfree(card); 936 kfree(card);
diff --git a/drivers/media/dvb/dvb-usb/cxusb.c b/drivers/media/dvb/dvb-usb/cxusb.c
index ae23bdde42a8..ac72e7ed9fcc 100644
--- a/drivers/media/dvb/dvb-usb/cxusb.c
+++ b/drivers/media/dvb/dvb-usb/cxusb.c
@@ -409,7 +409,7 @@ static int cxusb_cx22702_frontend_attach(struct dvb_usb_device *d)
409 409
410 cxusb_ctrl_msg(d,CMD_DIGITAL, NULL, 0, &b, 1); 410 cxusb_ctrl_msg(d,CMD_DIGITAL, NULL, 0, &b, 1);
411 411
412 if ((d->fe = cx22702_attach(&cxusb_cx22702_config, &d->i2c_adap)) != NULL) 412 if ((d->fe = dvb_attach(cx22702_attach, &cxusb_cx22702_config, &d->i2c_adap)) != NULL)
413 return 0; 413 return 0;
414 414
415 return -EIO; 415 return -EIO;
@@ -422,7 +422,7 @@ static int cxusb_lgdt3303_frontend_attach(struct dvb_usb_device *d)
422 422
423 cxusb_ctrl_msg(d,CMD_DIGITAL, NULL, 0, NULL, 0); 423 cxusb_ctrl_msg(d,CMD_DIGITAL, NULL, 0, NULL, 0);
424 424
425 if ((d->fe = lgdt330x_attach(&cxusb_lgdt3303_config, &d->i2c_adap)) != NULL) 425 if ((d->fe = dvb_attach(lgdt330x_attach, &cxusb_lgdt3303_config, &d->i2c_adap)) != NULL)
426 return 0; 426 return 0;
427 427
428 return -EIO; 428 return -EIO;
@@ -435,7 +435,7 @@ static int cxusb_mt352_frontend_attach(struct dvb_usb_device *d)
435 435
436 cxusb_ctrl_msg(d,CMD_DIGITAL, NULL, 0, NULL, 0); 436 cxusb_ctrl_msg(d,CMD_DIGITAL, NULL, 0, NULL, 0);
437 437
438 if ((d->fe = mt352_attach(&cxusb_mt352_config, &d->i2c_adap)) != NULL) 438 if ((d->fe = dvb_attach(mt352_attach, &cxusb_mt352_config, &d->i2c_adap)) != NULL)
439 return 0; 439 return 0;
440 440
441 return -EIO; 441 return -EIO;
@@ -448,8 +448,8 @@ static int cxusb_dee1601_frontend_attach(struct dvb_usb_device *d)
448 448
449 cxusb_ctrl_msg(d,CMD_DIGITAL, NULL, 0, NULL, 0); 449 cxusb_ctrl_msg(d,CMD_DIGITAL, NULL, 0, NULL, 0);
450 450
451 if (((d->fe = mt352_attach(&cxusb_dee1601_config, &d->i2c_adap)) != NULL) || 451 if (((d->fe = dvb_attach(mt352_attach, &cxusb_dee1601_config, &d->i2c_adap)) != NULL) ||
452 ((d->fe = zl10353_attach(&cxusb_zl10353_dee1601_config, &d->i2c_adap)) != NULL)) 452 ((d->fe = dvb_attach(zl10353_attach, &cxusb_zl10353_dee1601_config, &d->i2c_adap)) != NULL))
453 return 0; 453 return 0;
454 454
455 return -EIO; 455 return -EIO;
diff --git a/drivers/media/dvb/dvb-usb/digitv.c b/drivers/media/dvb/dvb-usb/digitv.c
index c14d9efb48fd..f5cd3a4f82a8 100644
--- a/drivers/media/dvb/dvb-usb/digitv.c
+++ b/drivers/media/dvb/dvb-usb/digitv.c
@@ -128,11 +128,11 @@ static struct nxt6000_config digitv_nxt6000_config = {
128 128
129static int digitv_frontend_attach(struct dvb_usb_device *d) 129static int digitv_frontend_attach(struct dvb_usb_device *d)
130{ 130{
131 if ((d->fe = mt352_attach(&digitv_mt352_config, &d->i2c_adap)) != NULL) { 131 if ((d->fe = dvb_attach(mt352_attach, &digitv_mt352_config, &d->i2c_adap)) != NULL) {
132 d->fe->ops.tuner_ops.calc_regs = dvb_usb_tuner_calc_regs; 132 d->fe->ops.tuner_ops.calc_regs = dvb_usb_tuner_calc_regs;
133 return 0; 133 return 0;
134 } 134 }
135 if ((d->fe = nxt6000_attach(&digitv_nxt6000_config, &d->i2c_adap)) != NULL) { 135 if ((d->fe = dvb_attach(nxt6000_attach, &digitv_nxt6000_config, &d->i2c_adap)) != NULL) {
136 d->fe->ops.tuner_ops.set_params = digitv_nxt6000_tuner_set_params; 136 d->fe->ops.tuner_ops.set_params = digitv_nxt6000_tuner_set_params;
137 return 0; 137 return 0;
138 } 138 }
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-dvb.c b/drivers/media/dvb/dvb-usb/dvb-usb-dvb.c
index ec631708c394..f0da15ebe33b 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-dvb.c
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-dvb.c
@@ -188,8 +188,9 @@ int dvb_usb_fe_init(struct dvb_usb_device* d)
188 188
189 if (dvb_register_frontend(&d->dvb_adap, d->fe)) { 189 if (dvb_register_frontend(&d->dvb_adap, d->fe)) {
190 err("Frontend registration failed."); 190 err("Frontend registration failed.");
191 if (d->fe->ops.release) 191 dvb_detach(d->fe->ops.release_sec, d->fe);
192 d->fe->ops.release(d->fe); 192 dvb_detach(d->fe->ops.tuner_ops.release, d->fe);
193 dvb_detach(d->fe->ops.release, d->fe);
193 d->fe = NULL; 194 d->fe = NULL;
194 return -ENODEV; 195 return -ENODEV;
195 } 196 }
@@ -204,7 +205,11 @@ int dvb_usb_fe_init(struct dvb_usb_device* d)
204 205
205int dvb_usb_fe_exit(struct dvb_usb_device *d) 206int dvb_usb_fe_exit(struct dvb_usb_device *d)
206{ 207{
207 if (d->fe != NULL) 208 if (d->fe != NULL) {
208 dvb_unregister_frontend(d->fe); 209 dvb_unregister_frontend(d->fe);
210 dvb_detach(d->fe->ops.release_sec, d->fe);
211 dvb_detach(d->fe->ops.tuner_ops.release, d->fe);
212 dvb_detach(d->fe->ops.release, d->fe);
213 }
209 return 0; 214 return 0;
210} 215}
diff --git a/drivers/media/dvb/dvb-usb/umt-010.c b/drivers/media/dvb/dvb-usb/umt-010.c
index 97d74da0dad8..418a0b707151 100644
--- a/drivers/media/dvb/dvb-usb/umt-010.c
+++ b/drivers/media/dvb/dvb-usb/umt-010.c
@@ -58,7 +58,7 @@ static int umt_mt352_frontend_attach(struct dvb_usb_device *d)
58 umt_config.demod_init = umt_mt352_demod_init; 58 umt_config.demod_init = umt_mt352_demod_init;
59 umt_config.demod_address = 0xf; 59 umt_config.demod_address = 0xf;
60 60
61 d->fe = mt352_attach(&umt_config, &d->i2c_adap); 61 d->fe = dvb_attach(mt352_attach, &umt_config, &d->i2c_adap);
62 62
63 return 0; 63 return 0;
64} 64}
diff --git a/drivers/media/dvb/frontends/dvb-pll.c b/drivers/media/dvb/frontends/dvb-pll.c
index 2be33f27c69f..c92877baada2 100644
--- a/drivers/media/dvb/frontends/dvb-pll.c
+++ b/drivers/media/dvb/frontends/dvb-pll.c
@@ -611,7 +611,7 @@ static struct dvb_tuner_ops dvb_pll_tuner_ops = {
611 .get_bandwidth = dvb_pll_get_bandwidth, 611 .get_bandwidth = dvb_pll_get_bandwidth,
612}; 612};
613 613
614int dvb_pll_attach(struct dvb_frontend *fe, int pll_addr, struct i2c_adapter *i2c, struct dvb_pll_desc *desc) 614struct dvb_frontend *dvb_pll_attach(struct dvb_frontend *fe, int pll_addr, struct i2c_adapter *i2c, struct dvb_pll_desc *desc)
615{ 615{
616 u8 b1 [] = { 0 }; 616 u8 b1 [] = { 0 };
617 struct i2c_msg msg = { .addr = pll_addr, .flags = I2C_M_RD, .buf = b1, .len = 1 }; 617 struct i2c_msg msg = { .addr = pll_addr, .flags = I2C_M_RD, .buf = b1, .len = 1 };
@@ -624,14 +624,14 @@ int dvb_pll_attach(struct dvb_frontend *fe, int pll_addr, struct i2c_adapter *i2
624 624
625 ret = i2c_transfer (i2c, &msg, 1); 625 ret = i2c_transfer (i2c, &msg, 1);
626 if (ret != 1) 626 if (ret != 1)
627 return -1; 627 return NULL;
628 if (fe->ops.i2c_gate_ctrl) 628 if (fe->ops.i2c_gate_ctrl)
629 fe->ops.i2c_gate_ctrl(fe, 0); 629 fe->ops.i2c_gate_ctrl(fe, 0);
630 } 630 }
631 631
632 priv = kzalloc(sizeof(struct dvb_pll_priv), GFP_KERNEL); 632 priv = kzalloc(sizeof(struct dvb_pll_priv), GFP_KERNEL);
633 if (priv == NULL) 633 if (priv == NULL)
634 return -ENOMEM; 634 return NULL;
635 635
636 priv->pll_i2c_address = pll_addr; 636 priv->pll_i2c_address = pll_addr;
637 priv->i2c = i2c; 637 priv->i2c = i2c;
@@ -643,7 +643,7 @@ int dvb_pll_attach(struct dvb_frontend *fe, int pll_addr, struct i2c_adapter *i2
643 fe->ops.tuner_ops.info.frequency_min = desc->max; 643 fe->ops.tuner_ops.info.frequency_min = desc->max;
644 644
645 fe->tuner_priv = priv; 645 fe->tuner_priv = priv;
646 return 0; 646 return fe;
647} 647}
648EXPORT_SYMBOL(dvb_pll_attach); 648EXPORT_SYMBOL(dvb_pll_attach);
649 649
diff --git a/drivers/media/dvb/frontends/dvb-pll.h b/drivers/media/dvb/frontends/dvb-pll.h
index 66361cd18807..ed5ac5a361ae 100644
--- a/drivers/media/dvb/frontends/dvb-pll.h
+++ b/drivers/media/dvb/frontends/dvb-pll.h
@@ -57,8 +57,8 @@ extern int dvb_pll_configure(struct dvb_pll_desc *desc, u8 *buf,
57 * @param pll_addr i2c address of the PLL (if used). 57 * @param pll_addr i2c address of the PLL (if used).
58 * @param i2c i2c adapter to use (set to NULL if not used). 58 * @param i2c i2c adapter to use (set to NULL if not used).
59 * @param desc dvb_pll_desc to use. 59 * @param desc dvb_pll_desc to use.
60 * @return 0 on success, nonzero on failure. 60 * @return Frontend pointer on success, NULL on failure
61 */ 61 */
62extern int dvb_pll_attach(struct dvb_frontend *fe, int pll_addr, struct i2c_adapter *i2c, struct dvb_pll_desc *desc); 62extern struct dvb_frontend *dvb_pll_attach(struct dvb_frontend *fe, int pll_addr, struct i2c_adapter *i2c, struct dvb_pll_desc *desc);
63 63
64#endif 64#endif
diff --git a/drivers/media/dvb/ttpci/av7110.c b/drivers/media/dvb/ttpci/av7110.c
index fa0bed6779b5..d195cf591081 100644
--- a/drivers/media/dvb/ttpci/av7110.c
+++ b/drivers/media/dvb/ttpci/av7110.c
@@ -1383,8 +1383,12 @@ static void dvb_unregister(struct av7110 *av7110)
1383 dvb_dmxdev_release(&av7110->dmxdev); 1383 dvb_dmxdev_release(&av7110->dmxdev);
1384 dvb_dmx_release(&av7110->demux); 1384 dvb_dmx_release(&av7110->demux);
1385 1385
1386 if (av7110->fe != NULL) 1386 if (av7110->fe != NULL) {
1387 dvb_unregister_frontend(av7110->fe); 1387 dvb_unregister_frontend(av7110->fe);
1388 dvb_detach(av7110->fe->ops.release_sec, av7110->fe);
1389 dvb_detach(av7110->fe->ops.tuner_ops.release, av7110->fe);
1390 dvb_detach(av7110->fe->ops.release, av7110->fe);
1391 }
1388 dvb_unregister_device(av7110->osd_dev); 1392 dvb_unregister_device(av7110->osd_dev);
1389 av7110_av_unregister(av7110); 1393 av7110_av_unregister(av7110);
1390 av7110_ca_unregister(av7110); 1394 av7110_ca_unregister(av7110);
@@ -2077,7 +2081,7 @@ static int frontend_init(struct av7110 *av7110)
2077 if (av7110->dev->pci->subsystem_vendor == 0x110a) { 2081 if (av7110->dev->pci->subsystem_vendor == 0x110a) {
2078 switch(av7110->dev->pci->subsystem_device) { 2082 switch(av7110->dev->pci->subsystem_device) {
2079 case 0x0000: // Fujitsu/Siemens DVB-Cable (ves1820/Philips CD1516(??)) 2083 case 0x0000: // Fujitsu/Siemens DVB-Cable (ves1820/Philips CD1516(??))
2080 av7110->fe = ves1820_attach(&philips_cd1516_config, 2084 av7110->fe = dvb_attach(ves1820_attach, &philips_cd1516_config,
2081 &av7110->i2c_adap, read_pwm(av7110)); 2085 &av7110->i2c_adap, read_pwm(av7110));
2082 if (av7110->fe) { 2086 if (av7110->fe) {
2083 av7110->fe->ops.tuner_ops.set_params = philips_cd1516_tuner_set_params; 2087 av7110->fe->ops.tuner_ops.set_params = philips_cd1516_tuner_set_params;
@@ -2092,7 +2096,7 @@ static int frontend_init(struct av7110 *av7110)
2092 case 0x1002: // Hauppauge/TT WinTV DVB-S rev1.3SE 2096 case 0x1002: // Hauppauge/TT WinTV DVB-S rev1.3SE
2093 2097
2094 // try the ALPS BSRV2 first of all 2098 // try the ALPS BSRV2 first of all
2095 av7110->fe = ves1x93_attach(&alps_bsrv2_config, &av7110->i2c_adap); 2099 av7110->fe = dvb_attach(ves1x93_attach, &alps_bsrv2_config, &av7110->i2c_adap);
2096 if (av7110->fe) { 2100 if (av7110->fe) {
2097 av7110->fe->ops.tuner_ops.set_params = alps_bsrv2_tuner_set_params; 2101 av7110->fe->ops.tuner_ops.set_params = alps_bsrv2_tuner_set_params;
2098 av7110->fe->ops.diseqc_send_master_cmd = av7110_diseqc_send_master_cmd; 2102 av7110->fe->ops.diseqc_send_master_cmd = av7110_diseqc_send_master_cmd;
@@ -2103,7 +2107,7 @@ static int frontend_init(struct av7110 *av7110)
2103 } 2107 }
2104 2108
2105 // try the ALPS BSRU6 now 2109 // try the ALPS BSRU6 now
2106 av7110->fe = stv0299_attach(&alps_bsru6_config, &av7110->i2c_adap); 2110 av7110->fe = dvb_attach(stv0299_attach, &alps_bsru6_config, &av7110->i2c_adap);
2107 if (av7110->fe) { 2111 if (av7110->fe) {
2108 av7110->fe->ops.tuner_ops.set_params = alps_bsru6_tuner_set_params; 2112 av7110->fe->ops.tuner_ops.set_params = alps_bsru6_tuner_set_params;
2109 av7110->fe->tuner_priv = &av7110->i2c_adap; 2113 av7110->fe->tuner_priv = &av7110->i2c_adap;
@@ -2116,7 +2120,7 @@ static int frontend_init(struct av7110 *av7110)
2116 } 2120 }
2117 2121
2118 // Try the grundig 29504-451 2122 // Try the grundig 29504-451
2119 av7110->fe = tda8083_attach(&grundig_29504_451_config, &av7110->i2c_adap); 2123 av7110->fe = dvb_attach(tda8083_attach, &grundig_29504_451_config, &av7110->i2c_adap);
2120 if (av7110->fe) { 2124 if (av7110->fe) {
2121 av7110->fe->ops.tuner_ops.set_params = grundig_29504_451_tuner_set_params; 2125 av7110->fe->ops.tuner_ops.set_params = grundig_29504_451_tuner_set_params;
2122 av7110->fe->ops.diseqc_send_master_cmd = av7110_diseqc_send_master_cmd; 2126 av7110->fe->ops.diseqc_send_master_cmd = av7110_diseqc_send_master_cmd;
@@ -2130,7 +2134,7 @@ static int frontend_init(struct av7110 *av7110)
2130 switch(av7110->dev->pci->subsystem_device) { 2134 switch(av7110->dev->pci->subsystem_device) {
2131 case 0x0000: 2135 case 0x0000:
2132 /* Siemens DVB-C (full-length card) VES1820/Philips CD1516 */ 2136 /* Siemens DVB-C (full-length card) VES1820/Philips CD1516 */
2133 av7110->fe = ves1820_attach(&philips_cd1516_config, &av7110->i2c_adap, 2137 av7110->fe = dvb_attach(ves1820_attach, &philips_cd1516_config, &av7110->i2c_adap,
2134 read_pwm(av7110)); 2138 read_pwm(av7110));
2135 if (av7110->fe) { 2139 if (av7110->fe) {
2136 av7110->fe->ops.tuner_ops.set_params = philips_cd1516_tuner_set_params; 2140 av7110->fe->ops.tuner_ops.set_params = philips_cd1516_tuner_set_params;
@@ -2138,7 +2142,7 @@ static int frontend_init(struct av7110 *av7110)
2138 break; 2142 break;
2139 case 0x0003: 2143 case 0x0003:
2140 /* Hauppauge DVB-C 2.1 VES1820/ALPS TDBE2 */ 2144 /* Hauppauge DVB-C 2.1 VES1820/ALPS TDBE2 */
2141 av7110->fe = ves1820_attach(&alps_tdbe2_config, &av7110->i2c_adap, 2145 av7110->fe = dvb_attach(ves1820_attach, &alps_tdbe2_config, &av7110->i2c_adap,
2142 read_pwm(av7110)); 2146 read_pwm(av7110));
2143 if (av7110->fe) { 2147 if (av7110->fe) {
2144 av7110->fe->ops.tuner_ops.set_params = alps_tdbe2_tuner_set_params; 2148 av7110->fe->ops.tuner_ops.set_params = alps_tdbe2_tuner_set_params;
@@ -2150,7 +2154,7 @@ static int frontend_init(struct av7110 *av7110)
2150 case 0x0001: // Hauppauge/TT Nexus-T premium rev1.X 2154 case 0x0001: // Hauppauge/TT Nexus-T premium rev1.X
2151 2155
2152 // ALPS TDLB7 2156 // ALPS TDLB7
2153 av7110->fe = sp8870_attach(&alps_tdlb7_config, &av7110->i2c_adap); 2157 av7110->fe = dvb_attach(sp8870_attach, &alps_tdlb7_config, &av7110->i2c_adap);
2154 if (av7110->fe) { 2158 if (av7110->fe) {
2155 av7110->fe->ops.tuner_ops.set_params = alps_tdlb7_tuner_set_params; 2159 av7110->fe->ops.tuner_ops.set_params = alps_tdlb7_tuner_set_params;
2156 } 2160 }
@@ -2158,7 +2162,7 @@ static int frontend_init(struct av7110 *av7110)
2158 2162
2159 case 0x0002: // Hauppauge/TT DVB-C premium rev2.X 2163 case 0x0002: // Hauppauge/TT DVB-C premium rev2.X
2160 2164
2161 av7110->fe = ves1820_attach(&alps_tdbe2_config, &av7110->i2c_adap, read_pwm(av7110)); 2165 av7110->fe = dvb_attach(ves1820_attach, &alps_tdbe2_config, &av7110->i2c_adap, read_pwm(av7110));
2162 if (av7110->fe) { 2166 if (av7110->fe) {
2163 av7110->fe->ops.tuner_ops.set_params = alps_tdbe2_tuner_set_params; 2167 av7110->fe->ops.tuner_ops.set_params = alps_tdbe2_tuner_set_params;
2164 } 2168 }
@@ -2166,7 +2170,7 @@ static int frontend_init(struct av7110 *av7110)
2166 2170
2167 case 0x0004: // Galaxis DVB-S rev1.3 2171 case 0x0004: // Galaxis DVB-S rev1.3
2168 /* ALPS BSRV2 */ 2172 /* ALPS BSRV2 */
2169 av7110->fe = ves1x93_attach(&alps_bsrv2_config, &av7110->i2c_adap); 2173 av7110->fe = dvb_attach(ves1x93_attach, &alps_bsrv2_config, &av7110->i2c_adap);
2170 if (av7110->fe) { 2174 if (av7110->fe) {
2171 av7110->fe->ops.tuner_ops.set_params = alps_bsrv2_tuner_set_params; 2175 av7110->fe->ops.tuner_ops.set_params = alps_bsrv2_tuner_set_params;
2172 av7110->fe->ops.diseqc_send_master_cmd = av7110_diseqc_send_master_cmd; 2176 av7110->fe->ops.diseqc_send_master_cmd = av7110_diseqc_send_master_cmd;
@@ -2178,7 +2182,7 @@ static int frontend_init(struct av7110 *av7110)
2178 2182
2179 case 0x0006: /* Fujitsu-Siemens DVB-S rev 1.6 */ 2183 case 0x0006: /* Fujitsu-Siemens DVB-S rev 1.6 */
2180 /* Grundig 29504-451 */ 2184 /* Grundig 29504-451 */
2181 av7110->fe = tda8083_attach(&grundig_29504_451_config, &av7110->i2c_adap); 2185 av7110->fe = dvb_attach(tda8083_attach, &grundig_29504_451_config, &av7110->i2c_adap);
2182 if (av7110->fe) { 2186 if (av7110->fe) {
2183 av7110->fe->ops.tuner_ops.set_params = grundig_29504_451_tuner_set_params; 2187 av7110->fe->ops.tuner_ops.set_params = grundig_29504_451_tuner_set_params;
2184 av7110->fe->ops.diseqc_send_master_cmd = av7110_diseqc_send_master_cmd; 2188 av7110->fe->ops.diseqc_send_master_cmd = av7110_diseqc_send_master_cmd;
@@ -2190,7 +2194,7 @@ static int frontend_init(struct av7110 *av7110)
2190 2194
2191 case 0x0008: // Hauppauge/TT DVB-T 2195 case 0x0008: // Hauppauge/TT DVB-T
2192 2196
2193 av7110->fe = l64781_attach(&grundig_29504_401_config, &av7110->i2c_adap); 2197 av7110->fe = dvb_attach(l64781_attach, &grundig_29504_401_config, &av7110->i2c_adap);
2194 if (av7110->fe) { 2198 if (av7110->fe) {
2195 av7110->fe->ops.tuner_ops.set_params = grundig_29504_401_tuner_set_params; 2199 av7110->fe->ops.tuner_ops.set_params = grundig_29504_401_tuner_set_params;
2196 } 2200 }
@@ -2198,7 +2202,7 @@ static int frontend_init(struct av7110 *av7110)
2198 2202
2199 case 0x000A: // Hauppauge/TT Nexus-CA rev1.X 2203 case 0x000A: // Hauppauge/TT Nexus-CA rev1.X
2200 2204
2201 av7110->fe = stv0297_attach(&nexusca_stv0297_config, &av7110->i2c_adap); 2205 av7110->fe = dvb_attach(stv0297_attach, &nexusca_stv0297_config, &av7110->i2c_adap);
2202 if (av7110->fe) { 2206 if (av7110->fe) {
2203 av7110->fe->ops.tuner_ops.set_params = nexusca_stv0297_tuner_set_params; 2207 av7110->fe->ops.tuner_ops.set_params = nexusca_stv0297_tuner_set_params;
2204 2208
@@ -2214,12 +2218,12 @@ static int frontend_init(struct av7110 *av7110)
2214 2218
2215 case 0x000E: /* Hauppauge/TT Nexus-S rev 2.3 */ 2219 case 0x000E: /* Hauppauge/TT Nexus-S rev 2.3 */
2216 /* ALPS BSBE1 */ 2220 /* ALPS BSBE1 */
2217 av7110->fe = stv0299_attach(&alps_bsbe1_config, &av7110->i2c_adap); 2221 av7110->fe = dvb_attach(stv0299_attach, &alps_bsbe1_config, &av7110->i2c_adap);
2218 if (av7110->fe) { 2222 if (av7110->fe) {
2219 av7110->fe->ops.tuner_ops.set_params = alps_bsbe1_tuner_set_params; 2223 av7110->fe->ops.tuner_ops.set_params = alps_bsbe1_tuner_set_params;
2220 av7110->fe->tuner_priv = &av7110->i2c_adap; 2224 av7110->fe->tuner_priv = &av7110->i2c_adap;
2221 2225
2222 if (lnbp21_attach(av7110->fe, &av7110->i2c_adap, 0, 0) == NULL) { 2226 if (dvb_attach(lnbp21_attach, av7110->fe, &av7110->i2c_adap, 0, 0) == NULL) {
2223 printk("dvb-ttpci: LNBP21 not found!\n"); 2227 printk("dvb-ttpci: LNBP21 not found!\n");
2224 if (av7110->fe->ops.release) 2228 if (av7110->fe->ops.release)
2225 av7110->fe->ops.release(av7110->fe); 2229 av7110->fe->ops.release(av7110->fe);
@@ -2255,8 +2259,9 @@ static int frontend_init(struct av7110 *av7110)
2255 ret = dvb_register_frontend(&av7110->dvb_adapter, av7110->fe); 2259 ret = dvb_register_frontend(&av7110->dvb_adapter, av7110->fe);
2256 if (ret < 0) { 2260 if (ret < 0) {
2257 printk("av7110: Frontend registration failed!\n"); 2261 printk("av7110: Frontend registration failed!\n");
2258 if (av7110->fe->ops.release) 2262 dvb_detach(av7110->fe->ops.release_sec, av7110->fe);
2259 av7110->fe->ops.release(av7110->fe); 2263 dvb_detach(av7110->fe->ops.tuner_ops.release, av7110->fe);
2264 dvb_detach(av7110->fe->ops.release, av7110->fe);
2260 av7110->fe = NULL; 2265 av7110->fe = NULL;
2261 } 2266 }
2262 } 2267 }
diff --git a/drivers/media/dvb/ttpci/budget-av.c b/drivers/media/dvb/ttpci/budget-av.c
index 2d21fec23b4d..c648c01c8ec5 100644
--- a/drivers/media/dvb/ttpci/budget-av.c
+++ b/drivers/media/dvb/ttpci/budget-av.c
@@ -235,7 +235,7 @@ static int ciintf_slot_reset(struct dvb_ca_en50221 *ca, int slot)
235 235
236 /* set tda10021 back to original clock configuration on reset */ 236 /* set tda10021 back to original clock configuration on reset */
237 if (budget_av->tda10021_poclkp) { 237 if (budget_av->tda10021_poclkp) {
238 tda10021_write_byte(budget_av->budget.dvb_frontend, 0x12, 0xa0); 238 tda10021_writereg(budget_av->budget.dvb_frontend, 0x12, 0xa0);
239 budget_av->tda10021_ts_enabled = 0; 239 budget_av->tda10021_ts_enabled = 0;
240 } 240 }
241 241
@@ -257,7 +257,7 @@ static int ciintf_slot_shutdown(struct dvb_ca_en50221 *ca, int slot)
257 257
258 /* set tda10021 back to original clock configuration when cam removed */ 258 /* set tda10021 back to original clock configuration when cam removed */
259 if (budget_av->tda10021_poclkp) { 259 if (budget_av->tda10021_poclkp) {
260 tda10021_write_byte(budget_av->budget.dvb_frontend, 0x12, 0xa0); 260 tda10021_writereg(budget_av->budget.dvb_frontend, 0x12, 0xa0);
261 budget_av->tda10021_ts_enabled = 0; 261 budget_av->tda10021_ts_enabled = 0;
262 } 262 }
263 return 0; 263 return 0;
@@ -277,7 +277,7 @@ static int ciintf_slot_ts_enable(struct dvb_ca_en50221 *ca, int slot)
277 277
278 /* tda10021 seems to need a different TS clock config when data is routed to the CAM */ 278 /* tda10021 seems to need a different TS clock config when data is routed to the CAM */
279 if (budget_av->tda10021_poclkp) { 279 if (budget_av->tda10021_poclkp) {
280 tda10021_write_byte(budget_av->budget.dvb_frontend, 0x12, 0xa1); 280 tda10021_writereg(budget_av->budget.dvb_frontend, 0x12, 0xa1);
281 budget_av->tda10021_ts_enabled = 1; 281 budget_av->tda10021_ts_enabled = 1;
282 } 282 }
283 283
@@ -1068,9 +1068,9 @@ static int tda10021_set_frontend(struct dvb_frontend *fe,
1068 1068
1069 result = budget_av->tda10021_set_frontend(fe, p); 1069 result = budget_av->tda10021_set_frontend(fe, p);
1070 if (budget_av->tda10021_ts_enabled) { 1070 if (budget_av->tda10021_ts_enabled) {
1071 tda10021_write_byte(budget_av->budget.dvb_frontend, 0x12, 0xa1); 1071 tda10021_writereg(budget_av->budget.dvb_frontend, 0x12, 0xa1);
1072 } else { 1072 } else {
1073 tda10021_write_byte(budget_av->budget.dvb_frontend, 0x12, 0xa0); 1073 tda10021_writereg(budget_av->budget.dvb_frontend, 0x12, 0xa0);
1074 } 1074 }
1075 1075
1076 return result; 1076 return result;
@@ -1098,13 +1098,13 @@ static void frontend_init(struct budget_av *budget_av)
1098 case SUBID_DVBS_KNC1: 1098 case SUBID_DVBS_KNC1:
1099 case SUBID_DVBS_EASYWATCH_1: 1099 case SUBID_DVBS_EASYWATCH_1:
1100 if (saa->pci->subsystem_vendor == 0x1894) { 1100 if (saa->pci->subsystem_vendor == 0x1894) {
1101 fe = stv0299_attach(&cinergy_1200s_1894_0010_config, 1101 fe = dvb_attach(stv0299_attach, &cinergy_1200s_1894_0010_config,
1102 &budget_av->budget.i2c_adap); 1102 &budget_av->budget.i2c_adap);
1103 if (fe) { 1103 if (fe) {
1104 fe->ops.tuner_ops.set_params = philips_su1278sh2_tua6100_tuner_set_params; 1104 fe->ops.tuner_ops.set_params = philips_su1278sh2_tua6100_tuner_set_params;
1105 } 1105 }
1106 } else { 1106 } else {
1107 fe = stv0299_attach(&typhoon_config, 1107 fe = dvb_attach(stv0299_attach, &typhoon_config,
1108 &budget_av->budget.i2c_adap); 1108 &budget_av->budget.i2c_adap);
1109 if (fe) { 1109 if (fe) {
1110 fe->ops.tuner_ops.set_params = philips_su1278_ty_ci_tuner_set_params; 1110 fe->ops.tuner_ops.set_params = philips_su1278_ty_ci_tuner_set_params;
@@ -1116,7 +1116,7 @@ static void frontend_init(struct budget_av *budget_av)
1116 case SUBID_DVBS_TV_STAR_CI: 1116 case SUBID_DVBS_TV_STAR_CI:
1117 case SUBID_DVBS_CYNERGY1200N: 1117 case SUBID_DVBS_CYNERGY1200N:
1118 case SUBID_DVBS_EASYWATCH: 1118 case SUBID_DVBS_EASYWATCH:
1119 fe = stv0299_attach(&philips_sd1878_config, 1119 fe = dvb_attach(stv0299_attach, &philips_sd1878_config,
1120 &budget_av->budget.i2c_adap); 1120 &budget_av->budget.i2c_adap);
1121 if (fe) { 1121 if (fe) {
1122 fe->ops.tuner_ops.set_params = philips_sd1878_tda8261_tuner_set_params; 1122 fe->ops.tuner_ops.set_params = philips_sd1878_tda8261_tuner_set_params;
@@ -1125,7 +1125,7 @@ static void frontend_init(struct budget_av *budget_av)
1125 1125
1126 case SUBID_DVBS_KNC1_PLUS: 1126 case SUBID_DVBS_KNC1_PLUS:
1127 case SUBID_DVBS_TYPHOON: 1127 case SUBID_DVBS_TYPHOON:
1128 fe = stv0299_attach(&typhoon_config, 1128 fe = dvb_attach(stv0299_attach, &typhoon_config,
1129 &budget_av->budget.i2c_adap); 1129 &budget_av->budget.i2c_adap);
1130 if (fe) { 1130 if (fe) {
1131 fe->ops.tuner_ops.set_params = philips_su1278_ty_ci_tuner_set_params; 1131 fe->ops.tuner_ops.set_params = philips_su1278_ty_ci_tuner_set_params;
@@ -1133,7 +1133,7 @@ static void frontend_init(struct budget_av *budget_av)
1133 break; 1133 break;
1134 1134
1135 case SUBID_DVBS_CINERGY1200: 1135 case SUBID_DVBS_CINERGY1200:
1136 fe = stv0299_attach(&cinergy_1200s_config, 1136 fe = dvb_attach(stv0299_attach, &cinergy_1200s_config,
1137 &budget_av->budget.i2c_adap); 1137 &budget_av->budget.i2c_adap);
1138 if (fe) { 1138 if (fe) {
1139 fe->ops.tuner_ops.set_params = philips_su1278_ty_ci_tuner_set_params; 1139 fe->ops.tuner_ops.set_params = philips_su1278_ty_ci_tuner_set_params;
@@ -1142,7 +1142,7 @@ static void frontend_init(struct budget_av *budget_av)
1142 1142
1143 case SUBID_DVBC_KNC1: 1143 case SUBID_DVBC_KNC1:
1144 budget_av->reinitialise_demod = 1; 1144 budget_av->reinitialise_demod = 1;
1145 fe = tda10021_attach(&philips_cu1216_config, 1145 fe = dvb_attach(tda10021_attach, &philips_cu1216_config,
1146 &budget_av->budget.i2c_adap, 1146 &budget_av->budget.i2c_adap,
1147 read_pwm(budget_av)); 1147 read_pwm(budget_av));
1148 if (fe) { 1148 if (fe) {
@@ -1153,7 +1153,7 @@ static void frontend_init(struct budget_av *budget_av)
1153 case SUBID_DVBC_KNC1_PLUS: 1153 case SUBID_DVBC_KNC1_PLUS:
1154 case SUBID_DVBC_CINERGY1200: 1154 case SUBID_DVBC_CINERGY1200:
1155 budget_av->reinitialise_demod = 1; 1155 budget_av->reinitialise_demod = 1;
1156 fe = tda10021_attach(&philips_cu1216_config, 1156 fe = dvb_attach(tda10021_attach, &philips_cu1216_config,
1157 &budget_av->budget.i2c_adap, 1157 &budget_av->budget.i2c_adap,
1158 read_pwm(budget_av)); 1158 read_pwm(budget_av));
1159 if (fe) { 1159 if (fe) {
@@ -1168,7 +1168,7 @@ static void frontend_init(struct budget_av *budget_av)
1168 case SUBID_DVBT_KNC1_PLUS: 1168 case SUBID_DVBT_KNC1_PLUS:
1169 case SUBID_DVBT_CINERGY1200: 1169 case SUBID_DVBT_CINERGY1200:
1170 budget_av->reinitialise_demod = 1; 1170 budget_av->reinitialise_demod = 1;
1171 fe = tda10046_attach(&philips_tu1216_config, 1171 fe = dvb_attach(tda10046_attach, &philips_tu1216_config,
1172 &budget_av->budget.i2c_adap); 1172 &budget_av->budget.i2c_adap);
1173 if (fe) { 1173 if (fe) {
1174 fe->ops.tuner_ops.init = philips_tu1216_tuner_init; 1174 fe->ops.tuner_ops.init = philips_tu1216_tuner_init;
@@ -1192,8 +1192,9 @@ static void frontend_init(struct budget_av *budget_av)
1192 if (dvb_register_frontend(&budget_av->budget.dvb_adapter, 1192 if (dvb_register_frontend(&budget_av->budget.dvb_adapter,
1193 budget_av->budget.dvb_frontend)) { 1193 budget_av->budget.dvb_frontend)) {
1194 printk(KERN_ERR "budget-av: Frontend registration failed!\n"); 1194 printk(KERN_ERR "budget-av: Frontend registration failed!\n");
1195 if (budget_av->budget.dvb_frontend->ops.release) 1195 dvb_detach(budget_av->budget.dvb_frontend->ops.release_sec, budget_av->budget.dvb_frontend);
1196 budget_av->budget.dvb_frontend->ops.release(budget_av->budget.dvb_frontend); 1196 dvb_detach(budget_av->budget.dvb_frontend->ops.tuner_ops.release, budget_av->budget.dvb_frontend);
1197 dvb_detach(budget_av->budget.dvb_frontend->ops.release, budget_av->budget.dvb_frontend);
1197 budget_av->budget.dvb_frontend = NULL; 1198 budget_av->budget.dvb_frontend = NULL;
1198 } 1199 }
1199} 1200}
@@ -1227,8 +1228,12 @@ static int budget_av_detach(struct saa7146_dev *dev)
1227 if (budget_av->budget.ci_present) 1228 if (budget_av->budget.ci_present)
1228 ciintf_deinit(budget_av); 1229 ciintf_deinit(budget_av);
1229 1230
1230 if (budget_av->budget.dvb_frontend != NULL) 1231 if (budget_av->budget.dvb_frontend != NULL) {
1231 dvb_unregister_frontend(budget_av->budget.dvb_frontend); 1232 dvb_unregister_frontend(budget_av->budget.dvb_frontend);
1233 dvb_detach(budget_av->budget.dvb_frontend->ops.release_sec, budget_av->budget.dvb_frontend);
1234 dvb_detach(budget_av->budget.dvb_frontend->ops.tuner_ops.release, budget_av->budget.dvb_frontend);
1235 dvb_detach(budget_av->budget.dvb_frontend->ops.release, budget_av->budget.dvb_frontend);
1236 }
1232 err = ttpci_budget_deinit(&budget_av->budget); 1237 err = ttpci_budget_deinit(&budget_av->budget);
1233 1238
1234 kfree(budget_av); 1239 kfree(budget_av);
diff --git a/drivers/media/dvb/ttpci/budget-ci.c b/drivers/media/dvb/ttpci/budget-ci.c
index 8710813668f1..20b5e8dc8739 100644
--- a/drivers/media/dvb/ttpci/budget-ci.c
+++ b/drivers/media/dvb/ttpci/budget-ci.c
@@ -988,7 +988,7 @@ static void frontend_init(struct budget_ci *budget_ci)
988 switch (budget_ci->budget.dev->pci->subsystem_device) { 988 switch (budget_ci->budget.dev->pci->subsystem_device) {
989 case 0x100c: // Hauppauge/TT Nova-CI budget (stv0299/ALPS BSRU6(tsa5059)) 989 case 0x100c: // Hauppauge/TT Nova-CI budget (stv0299/ALPS BSRU6(tsa5059))
990 budget_ci->budget.dvb_frontend = 990 budget_ci->budget.dvb_frontend =
991 stv0299_attach(&alps_bsru6_config, &budget_ci->budget.i2c_adap); 991 dvb_attach(stv0299_attach, &alps_bsru6_config, &budget_ci->budget.i2c_adap);
992 if (budget_ci->budget.dvb_frontend) { 992 if (budget_ci->budget.dvb_frontend) {
993 budget_ci->budget.dvb_frontend->ops.tuner_ops.set_params = alps_bsru6_tuner_set_params; 993 budget_ci->budget.dvb_frontend->ops.tuner_ops.set_params = alps_bsru6_tuner_set_params;
994 budget_ci->budget.dvb_frontend->tuner_priv = &budget_ci->budget.i2c_adap; 994 budget_ci->budget.dvb_frontend->tuner_priv = &budget_ci->budget.i2c_adap;
@@ -998,7 +998,7 @@ static void frontend_init(struct budget_ci *budget_ci)
998 998
999 case 0x100f: // Hauppauge/TT Nova-CI budget (stv0299b/Philips su1278(tsa5059)) 999 case 0x100f: // Hauppauge/TT Nova-CI budget (stv0299b/Philips su1278(tsa5059))
1000 budget_ci->budget.dvb_frontend = 1000 budget_ci->budget.dvb_frontend =
1001 stv0299_attach(&philips_su1278_tt_config, &budget_ci->budget.i2c_adap); 1001 dvb_attach(stv0299_attach, &philips_su1278_tt_config, &budget_ci->budget.i2c_adap);
1002 if (budget_ci->budget.dvb_frontend) { 1002 if (budget_ci->budget.dvb_frontend) {
1003 budget_ci->budget.dvb_frontend->ops.tuner_ops.set_params = philips_su1278_tt_tuner_set_params; 1003 budget_ci->budget.dvb_frontend->ops.tuner_ops.set_params = philips_su1278_tt_tuner_set_params;
1004 break; 1004 break;
@@ -1008,7 +1008,7 @@ static void frontend_init(struct budget_ci *budget_ci)
1008 case 0x1010: // TT DVB-C CI budget (stv0297/Philips tdm1316l(tda6651tt)) 1008 case 0x1010: // TT DVB-C CI budget (stv0297/Philips tdm1316l(tda6651tt))
1009 budget_ci->tuner_pll_address = 0x61; 1009 budget_ci->tuner_pll_address = 0x61;
1010 budget_ci->budget.dvb_frontend = 1010 budget_ci->budget.dvb_frontend =
1011 stv0297_attach(&dvbc_philips_tdm1316l_config, &budget_ci->budget.i2c_adap); 1011 dvb_attach(stv0297_attach, &dvbc_philips_tdm1316l_config, &budget_ci->budget.i2c_adap);
1012 if (budget_ci->budget.dvb_frontend) { 1012 if (budget_ci->budget.dvb_frontend) {
1013 budget_ci->budget.dvb_frontend->ops.tuner_ops.set_params = dvbc_philips_tdm1316l_tuner_set_params; 1013 budget_ci->budget.dvb_frontend->ops.tuner_ops.set_params = dvbc_philips_tdm1316l_tuner_set_params;
1014 break; 1014 break;
@@ -1018,7 +1018,7 @@ static void frontend_init(struct budget_ci *budget_ci)
1018 case 0x1011: // Hauppauge/TT Nova-T budget (tda10045/Philips tdm1316l(tda6651tt) + TDA9889) 1018 case 0x1011: // Hauppauge/TT Nova-T budget (tda10045/Philips tdm1316l(tda6651tt) + TDA9889)
1019 budget_ci->tuner_pll_address = 0x63; 1019 budget_ci->tuner_pll_address = 0x63;
1020 budget_ci->budget.dvb_frontend = 1020 budget_ci->budget.dvb_frontend =
1021 tda10045_attach(&philips_tdm1316l_config, &budget_ci->budget.i2c_adap); 1021 dvb_attach(tda10045_attach, &philips_tdm1316l_config, &budget_ci->budget.i2c_adap);
1022 if (budget_ci->budget.dvb_frontend) { 1022 if (budget_ci->budget.dvb_frontend) {
1023 budget_ci->budget.dvb_frontend->ops.tuner_ops.init = philips_tdm1316l_tuner_init; 1023 budget_ci->budget.dvb_frontend->ops.tuner_ops.init = philips_tdm1316l_tuner_init;
1024 budget_ci->budget.dvb_frontend->ops.tuner_ops.set_params = philips_tdm1316l_tuner_set_params; 1024 budget_ci->budget.dvb_frontend->ops.tuner_ops.set_params = philips_tdm1316l_tuner_set_params;
@@ -1029,7 +1029,7 @@ static void frontend_init(struct budget_ci *budget_ci)
1029 case 0x1012: // TT DVB-T CI budget (tda10046/Philips tdm1316l(tda6651tt)) 1029 case 0x1012: // TT DVB-T CI budget (tda10046/Philips tdm1316l(tda6651tt))
1030 budget_ci->tuner_pll_address = 0x60; 1030 budget_ci->tuner_pll_address = 0x60;
1031 budget_ci->budget.dvb_frontend = 1031 budget_ci->budget.dvb_frontend =
1032 tda10046_attach(&philips_tdm1316l_config, &budget_ci->budget.i2c_adap); 1032 dvb_attach(tda10046_attach, &philips_tdm1316l_config, &budget_ci->budget.i2c_adap);
1033 if (budget_ci->budget.dvb_frontend) { 1033 if (budget_ci->budget.dvb_frontend) {
1034 budget_ci->budget.dvb_frontend->ops.tuner_ops.init = philips_tdm1316l_tuner_init; 1034 budget_ci->budget.dvb_frontend->ops.tuner_ops.init = philips_tdm1316l_tuner_init;
1035 budget_ci->budget.dvb_frontend->ops.tuner_ops.set_params = philips_tdm1316l_tuner_set_params; 1035 budget_ci->budget.dvb_frontend->ops.tuner_ops.set_params = philips_tdm1316l_tuner_set_params;
@@ -1038,13 +1038,13 @@ static void frontend_init(struct budget_ci *budget_ci)
1038 break; 1038 break;
1039 1039
1040 case 0x1017: // TT S-1500 PCI 1040 case 0x1017: // TT S-1500 PCI
1041 budget_ci->budget.dvb_frontend = stv0299_attach(&alps_bsbe1_config, &budget_ci->budget.i2c_adap); 1041 budget_ci->budget.dvb_frontend = dvb_attach(stv0299_attach, &alps_bsbe1_config, &budget_ci->budget.i2c_adap);
1042 if (budget_ci->budget.dvb_frontend) { 1042 if (budget_ci->budget.dvb_frontend) {
1043 budget_ci->budget.dvb_frontend->ops.tuner_ops.set_params = alps_bsbe1_tuner_set_params; 1043 budget_ci->budget.dvb_frontend->ops.tuner_ops.set_params = alps_bsbe1_tuner_set_params;
1044 budget_ci->budget.dvb_frontend->tuner_priv = &budget_ci->budget.i2c_adap; 1044 budget_ci->budget.dvb_frontend->tuner_priv = &budget_ci->budget.i2c_adap;
1045 1045
1046 budget_ci->budget.dvb_frontend->ops.dishnetwork_send_legacy_command = NULL; 1046 budget_ci->budget.dvb_frontend->ops.dishnetwork_send_legacy_command = NULL;
1047 if (lnbp21_attach(budget_ci->budget.dvb_frontend, &budget_ci->budget.i2c_adap, LNBP21_LLC, 0) == NULL) { 1047 if (dvb_attach(lnbp21_attach, budget_ci->budget.dvb_frontend, &budget_ci->budget.i2c_adap, LNBP21_LLC, 0) == NULL) {
1048 printk("%s: No LNBP21 found!\n", __FUNCTION__); 1048 printk("%s: No LNBP21 found!\n", __FUNCTION__);
1049 if (budget_ci->budget.dvb_frontend->ops.release) 1049 if (budget_ci->budget.dvb_frontend->ops.release)
1050 budget_ci->budget.dvb_frontend->ops.release(budget_ci->budget.dvb_frontend); 1050 budget_ci->budget.dvb_frontend->ops.release(budget_ci->budget.dvb_frontend);
@@ -1065,8 +1065,9 @@ static void frontend_init(struct budget_ci *budget_ci)
1065 if (dvb_register_frontend 1065 if (dvb_register_frontend
1066 (&budget_ci->budget.dvb_adapter, budget_ci->budget.dvb_frontend)) { 1066 (&budget_ci->budget.dvb_adapter, budget_ci->budget.dvb_frontend)) {
1067 printk("budget-ci: Frontend registration failed!\n"); 1067 printk("budget-ci: Frontend registration failed!\n");
1068 if (budget_ci->budget.dvb_frontend->ops.release) 1068 dvb_detach(budget_ci->budget.dvb_frontend->ops.release_sec, budget_ci->budget.dvb_frontend);
1069 budget_ci->budget.dvb_frontend->ops.release(budget_ci->budget.dvb_frontend); 1069 dvb_detach(budget_ci->budget.dvb_frontend->ops.tuner_ops.release, budget_ci->budget.dvb_frontend);
1070 dvb_detach(budget_ci->budget.dvb_frontend->ops.release, budget_ci->budget.dvb_frontend);
1070 budget_ci->budget.dvb_frontend = NULL; 1071 budget_ci->budget.dvb_frontend = NULL;
1071 } 1072 }
1072 } 1073 }
@@ -1114,8 +1115,12 @@ static int budget_ci_detach(struct saa7146_dev *dev)
1114 1115
1115 if (budget_ci->budget.ci_present) 1116 if (budget_ci->budget.ci_present)
1116 ciintf_deinit(budget_ci); 1117 ciintf_deinit(budget_ci);
1117 if (budget_ci->budget.dvb_frontend) 1118 if (budget_ci->budget.dvb_frontend) {
1118 dvb_unregister_frontend(budget_ci->budget.dvb_frontend); 1119 dvb_unregister_frontend(budget_ci->budget.dvb_frontend);
1120 dvb_detach(budget_ci->budget.dvb_frontend->ops.release_sec, budget_ci->budget.dvb_frontend);
1121 dvb_detach(budget_ci->budget.dvb_frontend->ops.tuner_ops.release, budget_ci->budget.dvb_frontend);
1122 dvb_detach(budget_ci->budget.dvb_frontend->ops.release, budget_ci->budget.dvb_frontend);
1123 }
1119 err = ttpci_budget_deinit(&budget_ci->budget); 1124 err = ttpci_budget_deinit(&budget_ci->budget);
1120 1125
1121 tasklet_kill(&budget_ci->msp430_irq_tasklet); 1126 tasklet_kill(&budget_ci->msp430_irq_tasklet);
diff --git a/drivers/media/dvb/ttpci/budget-patch.c b/drivers/media/dvb/ttpci/budget-patch.c
index 57227441891e..82dbef863e51 100644
--- a/drivers/media/dvb/ttpci/budget-patch.c
+++ b/drivers/media/dvb/ttpci/budget-patch.c
@@ -325,7 +325,7 @@ static void frontend_init(struct budget_patch* budget)
325 case 0x1013: // SATELCO Multimedia PCI 325 case 0x1013: // SATELCO Multimedia PCI
326 326
327 // try the ALPS BSRV2 first of all 327 // try the ALPS BSRV2 first of all
328 budget->dvb_frontend = ves1x93_attach(&alps_bsrv2_config, &budget->i2c_adap); 328 budget->dvb_frontend = dvb_attach(ves1x93_attach, &alps_bsrv2_config, &budget->i2c_adap);
329 if (budget->dvb_frontend) { 329 if (budget->dvb_frontend) {
330 budget->dvb_frontend->ops.tuner_ops.set_params = alps_bsrv2_tuner_set_params; 330 budget->dvb_frontend->ops.tuner_ops.set_params = alps_bsrv2_tuner_set_params;
331 budget->dvb_frontend->ops.diseqc_send_master_cmd = budget_patch_diseqc_send_master_cmd; 331 budget->dvb_frontend->ops.diseqc_send_master_cmd = budget_patch_diseqc_send_master_cmd;
@@ -335,7 +335,7 @@ static void frontend_init(struct budget_patch* budget)
335 } 335 }
336 336
337 // try the ALPS BSRU6 now 337 // try the ALPS BSRU6 now
338 budget->dvb_frontend = stv0299_attach(&alps_bsru6_config, &budget->i2c_adap); 338 budget->dvb_frontend = dvb_attach(stv0299_attach, &alps_bsru6_config, &budget->i2c_adap);
339 if (budget->dvb_frontend) { 339 if (budget->dvb_frontend) {
340 budget->dvb_frontend->ops.tuner_ops.set_params = alps_bsru6_tuner_set_params; 340 budget->dvb_frontend->ops.tuner_ops.set_params = alps_bsru6_tuner_set_params;
341 budget->dvb_frontend->tuner_priv = &budget->i2c_adap; 341 budget->dvb_frontend->tuner_priv = &budget->i2c_adap;
@@ -347,7 +347,7 @@ static void frontend_init(struct budget_patch* budget)
347 } 347 }
348 348
349 // Try the grundig 29504-451 349 // Try the grundig 29504-451
350 budget->dvb_frontend = tda8083_attach(&grundig_29504_451_config, &budget->i2c_adap); 350 budget->dvb_frontend = dvb_attach(tda8083_attach, &grundig_29504_451_config, &budget->i2c_adap);
351 if (budget->dvb_frontend) { 351 if (budget->dvb_frontend) {
352 budget->dvb_frontend->ops.tuner_ops.set_params = grundig_29504_451_tuner_set_params; 352 budget->dvb_frontend->ops.tuner_ops.set_params = grundig_29504_451_tuner_set_params;
353 budget->dvb_frontend->ops.diseqc_send_master_cmd = budget_diseqc_send_master_cmd; 353 budget->dvb_frontend->ops.diseqc_send_master_cmd = budget_diseqc_send_master_cmd;
@@ -367,8 +367,9 @@ static void frontend_init(struct budget_patch* budget)
367 } else { 367 } else {
368 if (dvb_register_frontend(&budget->dvb_adapter, budget->dvb_frontend)) { 368 if (dvb_register_frontend(&budget->dvb_adapter, budget->dvb_frontend)) {
369 printk("budget-av: Frontend registration failed!\n"); 369 printk("budget-av: Frontend registration failed!\n");
370 if (budget->dvb_frontend->ops.release) 370 dvb_detach(budget->dvb_frontend->ops.release_sec, budget->dvb_frontend);
371 budget->dvb_frontend->ops.release(budget->dvb_frontend); 371 dvb_detach(budget->dvb_frontend->ops.tuner_ops.release, budget->dvb_frontend);
372 dvb_detach(budget->dvb_frontend->ops.release, budget->dvb_frontend);
372 budget->dvb_frontend = NULL; 373 budget->dvb_frontend = NULL;
373 } 374 }
374 } 375 }
@@ -627,8 +628,12 @@ static int budget_patch_detach (struct saa7146_dev* dev)
627 struct budget_patch *budget = (struct budget_patch*) dev->ext_priv; 628 struct budget_patch *budget = (struct budget_patch*) dev->ext_priv;
628 int err; 629 int err;
629 630
630 if (budget->dvb_frontend) dvb_unregister_frontend(budget->dvb_frontend); 631 if (budget->dvb_frontend) {
631 632 dvb_unregister_frontend(budget->dvb_frontend);
633 dvb_detach(budget->dvb_frontend->ops.release_sec, budget->dvb_frontend);
634 dvb_detach(budget->dvb_frontend->ops.tuner_ops.release, budget->dvb_frontend);
635 dvb_detach(budget->dvb_frontend->ops.release, budget->dvb_frontend);
636 }
632 err = ttpci_budget_deinit (budget); 637 err = ttpci_budget_deinit (budget);
633 638
634 kfree (budget); 639 kfree (budget);
diff --git a/drivers/media/dvb/ttpci/budget.c b/drivers/media/dvb/ttpci/budget.c
index c21ee5a05fe8..19beb11f9664 100644
--- a/drivers/media/dvb/ttpci/budget.c
+++ b/drivers/media/dvb/ttpci/budget.c
@@ -361,7 +361,7 @@ static void frontend_init(struct budget *budget)
361 case 0x1003: // Hauppauge/TT Nova budget (stv0299/ALPS BSRU6(tsa5059) OR ves1893/ALPS BSRV2(sp5659)) 361 case 0x1003: // Hauppauge/TT Nova budget (stv0299/ALPS BSRU6(tsa5059) OR ves1893/ALPS BSRV2(sp5659))
362 case 0x1013: 362 case 0x1013:
363 // try the ALPS BSRV2 first of all 363 // try the ALPS BSRV2 first of all
364 budget->dvb_frontend = ves1x93_attach(&alps_bsrv2_config, &budget->i2c_adap); 364 budget->dvb_frontend = dvb_attach(ves1x93_attach, &alps_bsrv2_config, &budget->i2c_adap);
365 if (budget->dvb_frontend) { 365 if (budget->dvb_frontend) {
366 budget->dvb_frontend->ops.tuner_ops.set_params = alps_bsrv2_tuner_set_params; 366 budget->dvb_frontend->ops.tuner_ops.set_params = alps_bsrv2_tuner_set_params;
367 budget->dvb_frontend->ops.diseqc_send_master_cmd = budget_diseqc_send_master_cmd; 367 budget->dvb_frontend->ops.diseqc_send_master_cmd = budget_diseqc_send_master_cmd;
@@ -371,7 +371,7 @@ static void frontend_init(struct budget *budget)
371 } 371 }
372 372
373 // try the ALPS BSRU6 now 373 // try the ALPS BSRU6 now
374 budget->dvb_frontend = stv0299_attach(&alps_bsru6_config, &budget->i2c_adap); 374 budget->dvb_frontend = dvb_attach(stv0299_attach, &alps_bsru6_config, &budget->i2c_adap);
375 if (budget->dvb_frontend) { 375 if (budget->dvb_frontend) {
376 budget->dvb_frontend->ops.tuner_ops.set_params = alps_bsru6_tuner_set_params; 376 budget->dvb_frontend->ops.tuner_ops.set_params = alps_bsru6_tuner_set_params;
377 budget->dvb_frontend->tuner_priv = &budget->i2c_adap; 377 budget->dvb_frontend->tuner_priv = &budget->i2c_adap;
@@ -381,7 +381,7 @@ static void frontend_init(struct budget *budget)
381 381
382 case 0x1004: // Hauppauge/TT DVB-C budget (ves1820/ALPS TDBE2(sp5659)) 382 case 0x1004: // Hauppauge/TT DVB-C budget (ves1820/ALPS TDBE2(sp5659))
383 383
384 budget->dvb_frontend = ves1820_attach(&alps_tdbe2_config, &budget->i2c_adap, read_pwm(budget)); 384 budget->dvb_frontend = dvb_attach(ves1820_attach, &alps_tdbe2_config, &budget->i2c_adap, read_pwm(budget));
385 if (budget->dvb_frontend) { 385 if (budget->dvb_frontend) {
386 budget->dvb_frontend->ops.tuner_ops.set_params = alps_tdbe2_tuner_set_params; 386 budget->dvb_frontend->ops.tuner_ops.set_params = alps_tdbe2_tuner_set_params;
387 break; 387 break;
@@ -390,7 +390,7 @@ static void frontend_init(struct budget *budget)
390 390
391 case 0x1005: // Hauppauge/TT Nova-T budget (L64781/Grundig 29504-401(tsa5060)) 391 case 0x1005: // Hauppauge/TT Nova-T budget (L64781/Grundig 29504-401(tsa5060))
392 392
393 budget->dvb_frontend = l64781_attach(&grundig_29504_401_config, &budget->i2c_adap); 393 budget->dvb_frontend = dvb_attach(l64781_attach, &grundig_29504_401_config, &budget->i2c_adap);
394 if (budget->dvb_frontend) { 394 if (budget->dvb_frontend) {
395 budget->dvb_frontend->ops.tuner_ops.set_params = grundig_29504_401_tuner_set_params; 395 budget->dvb_frontend->ops.tuner_ops.set_params = grundig_29504_401_tuner_set_params;
396 break; 396 break;
@@ -398,7 +398,7 @@ static void frontend_init(struct budget *budget)
398 break; 398 break;
399 399
400 case 0x4f60: // Fujitsu Siemens Activy Budget-S PCI rev AL (stv0299/ALPS BSRU6(tsa5059)) 400 case 0x4f60: // Fujitsu Siemens Activy Budget-S PCI rev AL (stv0299/ALPS BSRU6(tsa5059))
401 budget->dvb_frontend = stv0299_attach(&alps_bsru6_config, &budget->i2c_adap); 401 budget->dvb_frontend = dvb_attach(stv0299_attach, &alps_bsru6_config, &budget->i2c_adap);
402 if (budget->dvb_frontend) { 402 if (budget->dvb_frontend) {
403 budget->dvb_frontend->ops.tuner_ops.set_params = alps_bsru6_tuner_set_params; 403 budget->dvb_frontend->ops.tuner_ops.set_params = alps_bsru6_tuner_set_params;
404 budget->dvb_frontend->tuner_priv = &budget->i2c_adap; 404 budget->dvb_frontend->tuner_priv = &budget->i2c_adap;
@@ -408,7 +408,7 @@ static void frontend_init(struct budget *budget)
408 break; 408 break;
409 409
410 case 0x4f61: // Fujitsu Siemens Activy Budget-S PCI rev GR (tda8083/Grundig 29504-451(tsa5522)) 410 case 0x4f61: // Fujitsu Siemens Activy Budget-S PCI rev GR (tda8083/Grundig 29504-451(tsa5522))
411 budget->dvb_frontend = tda8083_attach(&grundig_29504_451_config, &budget->i2c_adap); 411 budget->dvb_frontend = dvb_attach(tda8083_attach, &grundig_29504_451_config, &budget->i2c_adap);
412 if (budget->dvb_frontend) { 412 if (budget->dvb_frontend) {
413 budget->dvb_frontend->ops.tuner_ops.set_params = grundig_29504_451_tuner_set_params; 413 budget->dvb_frontend->ops.tuner_ops.set_params = grundig_29504_451_tuner_set_params;
414 budget->dvb_frontend->ops.set_voltage = siemens_budget_set_voltage; 414 budget->dvb_frontend->ops.set_voltage = siemens_budget_set_voltage;
@@ -417,7 +417,7 @@ static void frontend_init(struct budget *budget)
417 break; 417 break;
418 418
419 case 0x1016: // Hauppauge/TT Nova-S SE (samsung s5h1420/????(tda8260)) 419 case 0x1016: // Hauppauge/TT Nova-S SE (samsung s5h1420/????(tda8260))
420 budget->dvb_frontend = s5h1420_attach(&s5h1420_config, &budget->i2c_adap); 420 budget->dvb_frontend = dvb_attach(s5h1420_attach, &s5h1420_config, &budget->i2c_adap);
421 if (budget->dvb_frontend) { 421 if (budget->dvb_frontend) {
422 budget->dvb_frontend->ops.tuner_ops.set_params = s5h1420_tuner_set_params; 422 budget->dvb_frontend->ops.tuner_ops.set_params = s5h1420_tuner_set_params;
423 if (lnbp21_attach(budget->dvb_frontend, &budget->i2c_adap, 0, 0) == NULL) { 423 if (lnbp21_attach(budget->dvb_frontend, &budget->i2c_adap, 0, 0) == NULL) {
@@ -442,8 +442,9 @@ static void frontend_init(struct budget *budget)
442 442
443error_out: 443error_out:
444 printk("budget: Frontend registration failed!\n"); 444 printk("budget: Frontend registration failed!\n");
445 if (budget->dvb_frontend->ops.release) 445 dvb_detach(budget->dvb_frontend->ops.release_sec, budget->dvb_frontend);
446 budget->dvb_frontend->ops.release(budget->dvb_frontend); 446 dvb_detach(budget->dvb_frontend->ops.tuner_ops.release, budget->dvb_frontend);
447 dvb_detach(budget->dvb_frontend->ops.release, budget->dvb_frontend);
447 budget->dvb_frontend = NULL; 448 budget->dvb_frontend = NULL;
448 return; 449 return;
449} 450}
@@ -481,7 +482,12 @@ static int budget_detach (struct saa7146_dev* dev)
481 struct budget *budget = (struct budget*) dev->ext_priv; 482 struct budget *budget = (struct budget*) dev->ext_priv;
482 int err; 483 int err;
483 484
484 if (budget->dvb_frontend) dvb_unregister_frontend(budget->dvb_frontend); 485 if (budget->dvb_frontend) {
486 dvb_unregister_frontend(budget->dvb_frontend);
487 dvb_detach(budget->dvb_frontend->ops.release_sec, budget->dvb_frontend);
488 dvb_detach(budget->dvb_frontend->ops.tuner_ops.release, budget->dvb_frontend);
489 dvb_detach(budget->dvb_frontend->ops.release, budget->dvb_frontend);
490 }
485 491
486 err = ttpci_budget_deinit (budget); 492 err = ttpci_budget_deinit (budget);
487 493
diff --git a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
index 3c299df89410..6f58c66d6ef9 100644
--- a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
+++ b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
@@ -1564,13 +1564,13 @@ static void frontend_init(struct ttusb* ttusb)
1564 switch(le16_to_cpu(ttusb->dev->descriptor.idProduct)) { 1564 switch(le16_to_cpu(ttusb->dev->descriptor.idProduct)) {
1565 case 0x1003: // Hauppauge/TT Nova-USB-S budget (stv0299/ALPS BSRU6|BSBE1(tsa5059)) 1565 case 0x1003: // Hauppauge/TT Nova-USB-S budget (stv0299/ALPS BSRU6|BSBE1(tsa5059))
1566 // try the stv0299 based first 1566 // try the stv0299 based first
1567 ttusb->fe = stv0299_attach(&alps_stv0299_config, &ttusb->i2c_adap); 1567 ttusb->fe = dvb_attach(stv0299_attach, &alps_stv0299_config, &ttusb->i2c_adap);
1568 if (ttusb->fe != NULL) { 1568 if (ttusb->fe != NULL) {
1569 ttusb->fe->ops.tuner_ops.set_params = philips_tsa5059_tuner_set_params; 1569 ttusb->fe->ops.tuner_ops.set_params = philips_tsa5059_tuner_set_params;
1570 1570
1571 if(ttusb->revision == TTUSB_REV_2_2) { // ALPS BSBE1 1571 if(ttusb->revision == TTUSB_REV_2_2) { // ALPS BSBE1
1572 alps_stv0299_config.inittab = alps_bsbe1_inittab; 1572 alps_stv0299_config.inittab = alps_bsbe1_inittab;
1573 lnbp21_attach(ttusb->fe, &ttusb->i2c_adap, 0, 0); 1573 dvb_attach(lnbp21_attach, ttusb->fe, &ttusb->i2c_adap, 0, 0);
1574 } else { // ALPS BSRU6 1574 } else { // ALPS BSRU6
1575 ttusb->fe->ops.set_voltage = ttusb_set_voltage; 1575 ttusb->fe->ops.set_voltage = ttusb_set_voltage;
1576 } 1576 }
@@ -1578,7 +1578,7 @@ static void frontend_init(struct ttusb* ttusb)
1578 } 1578 }
1579 1579
1580 // Grundig 29504-491 1580 // Grundig 29504-491
1581 ttusb->fe = tda8083_attach(&ttusb_novas_grundig_29504_491_config, &ttusb->i2c_adap); 1581 ttusb->fe = dvb_attach(tda8083_attach, &ttusb_novas_grundig_29504_491_config, &ttusb->i2c_adap);
1582 if (ttusb->fe != NULL) { 1582 if (ttusb->fe != NULL) {
1583 ttusb->fe->ops.tuner_ops.set_params = ttusb_novas_grundig_29504_491_tuner_set_params; 1583 ttusb->fe->ops.tuner_ops.set_params = ttusb_novas_grundig_29504_491_tuner_set_params;
1584 ttusb->fe->ops.set_voltage = ttusb_set_voltage; 1584 ttusb->fe->ops.set_voltage = ttusb_set_voltage;
@@ -1587,13 +1587,13 @@ static void frontend_init(struct ttusb* ttusb)
1587 break; 1587 break;
1588 1588
1589 case 0x1004: // Hauppauge/TT DVB-C budget (ves1820/ALPS TDBE2(sp5659)) 1589 case 0x1004: // Hauppauge/TT DVB-C budget (ves1820/ALPS TDBE2(sp5659))
1590 ttusb->fe = ves1820_attach(&alps_tdbe2_config, &ttusb->i2c_adap, read_pwm(ttusb)); 1590 ttusb->fe = dvb_attach(ves1820_attach, &alps_tdbe2_config, &ttusb->i2c_adap, read_pwm(ttusb));
1591 if (ttusb->fe != NULL) { 1591 if (ttusb->fe != NULL) {
1592 ttusb->fe->ops.tuner_ops.set_params = alps_tdbe2_tuner_set_params; 1592 ttusb->fe->ops.tuner_ops.set_params = alps_tdbe2_tuner_set_params;
1593 break; 1593 break;
1594 } 1594 }
1595 1595
1596 ttusb->fe = stv0297_attach(&dvbc_philips_tdm1316l_config, &ttusb->i2c_adap); 1596 ttusb->fe = dvb_attach(stv0297_attach, &dvbc_philips_tdm1316l_config, &ttusb->i2c_adap);
1597 if (ttusb->fe != NULL) { 1597 if (ttusb->fe != NULL) {
1598 ttusb->fe->ops.tuner_ops.set_params = dvbc_philips_tdm1316l_tuner_set_params; 1598 ttusb->fe->ops.tuner_ops.set_params = dvbc_philips_tdm1316l_tuner_set_params;
1599 break; 1599 break;
@@ -1602,14 +1602,14 @@ static void frontend_init(struct ttusb* ttusb)
1602 1602
1603 case 0x1005: // Hauppauge/TT Nova-USB-t budget (tda10046/Philips td1316(tda6651tt) OR cx22700/ALPS TDMB7(??)) 1603 case 0x1005: // Hauppauge/TT Nova-USB-t budget (tda10046/Philips td1316(tda6651tt) OR cx22700/ALPS TDMB7(??))
1604 // try the ALPS TDMB7 first 1604 // try the ALPS TDMB7 first
1605 ttusb->fe = cx22700_attach(&alps_tdmb7_config, &ttusb->i2c_adap); 1605 ttusb->fe = dvb_attach(cx22700_attach, &alps_tdmb7_config, &ttusb->i2c_adap);
1606 if (ttusb->fe != NULL) { 1606 if (ttusb->fe != NULL) {
1607 ttusb->fe->ops.tuner_ops.set_params = alps_tdmb7_tuner_set_params; 1607 ttusb->fe->ops.tuner_ops.set_params = alps_tdmb7_tuner_set_params;
1608 break; 1608 break;
1609 } 1609 }
1610 1610
1611 // Philips td1316 1611 // Philips td1316
1612 ttusb->fe = tda10046_attach(&philips_tdm1316l_config, &ttusb->i2c_adap); 1612 ttusb->fe = dvb_attach(tda10046_attach, &philips_tdm1316l_config, &ttusb->i2c_adap);
1613 if (ttusb->fe != NULL) { 1613 if (ttusb->fe != NULL) {
1614 ttusb->fe->ops.tuner_ops.init = philips_tdm1316l_tuner_init; 1614 ttusb->fe->ops.tuner_ops.init = philips_tdm1316l_tuner_init;
1615 ttusb->fe->ops.tuner_ops.set_params = philips_tdm1316l_tuner_set_params; 1615 ttusb->fe->ops.tuner_ops.set_params = philips_tdm1316l_tuner_set_params;
@@ -1625,8 +1625,9 @@ static void frontend_init(struct ttusb* ttusb)
1625 } else { 1625 } else {
1626 if (dvb_register_frontend(&ttusb->adapter, ttusb->fe)) { 1626 if (dvb_register_frontend(&ttusb->adapter, ttusb->fe)) {
1627 printk("dvb-ttusb-budget: Frontend registration failed!\n"); 1627 printk("dvb-ttusb-budget: Frontend registration failed!\n");
1628 if (ttusb->fe->ops.release) 1628 dvb_detach(ttusb->fe->ops.release_sec, ttusb->fe);
1629 ttusb->fe->ops.release(ttusb->fe); 1629 dvb_detach(ttusb->fe->ops.tuner_ops.release, ttusb->fe);
1630 dvb_detach(ttusb->fe->ops.release, ttusb->fe);
1630 ttusb->fe = NULL; 1631 ttusb->fe = NULL;
1631 } 1632 }
1632 } 1633 }
@@ -1763,7 +1764,12 @@ static void ttusb_disconnect(struct usb_interface *intf)
1763 dvb_net_release(&ttusb->dvbnet); 1764 dvb_net_release(&ttusb->dvbnet);
1764 dvb_dmxdev_release(&ttusb->dmxdev); 1765 dvb_dmxdev_release(&ttusb->dmxdev);
1765 dvb_dmx_release(&ttusb->dvb_demux); 1766 dvb_dmx_release(&ttusb->dvb_demux);
1766 if (ttusb->fe != NULL) dvb_unregister_frontend(ttusb->fe); 1767 if (ttusb->fe != NULL) {
1768 dvb_unregister_frontend(ttusb->fe);
1769 dvb_detach(ttusb->fe->ops.release_sec, ttusb->fe);
1770 dvb_detach(ttusb->fe->ops.tuner_ops.release, ttusb->fe);
1771 dvb_detach(ttusb->fe->ops.release, ttusb->fe);
1772 }
1767 i2c_del_adapter(&ttusb->i2c_adap); 1773 i2c_del_adapter(&ttusb->i2c_adap);
1768 dvb_unregister_adapter(&ttusb->adapter); 1774 dvb_unregister_adapter(&ttusb->adapter);
1769 1775
diff --git a/drivers/media/dvb/ttusb-dec/ttusb_dec.c b/drivers/media/dvb/ttusb-dec/ttusb_dec.c
index 6c1cb770bcf5..02651998f8db 100644
--- a/drivers/media/dvb/ttusb-dec/ttusb_dec.c
+++ b/drivers/media/dvb/ttusb-dec/ttusb_dec.c
@@ -1512,7 +1512,11 @@ static void ttusb_dec_exit_dvb(struct ttusb_dec *dec)
1512 dec->demux.dmx.remove_frontend(&dec->demux.dmx, &dec->frontend); 1512 dec->demux.dmx.remove_frontend(&dec->demux.dmx, &dec->frontend);
1513 dvb_dmxdev_release(&dec->dmxdev); 1513 dvb_dmxdev_release(&dec->dmxdev);
1514 dvb_dmx_release(&dec->demux); 1514 dvb_dmx_release(&dec->demux);
1515 if (dec->fe) dvb_unregister_frontend(dec->fe); 1515 if (dec->fe) {
1516 dvb_unregister_frontend(dec->fe);
1517 if (dec->fe->ops.release)
1518 dec->fe->ops.release(dec->fe);
1519 }
1516 dvb_unregister_adapter(&dec->adapter); 1520 dvb_unregister_adapter(&dec->adapter);
1517} 1521}
1518 1522
diff --git a/drivers/media/video/cx88/cx88-dvb.c b/drivers/media/video/cx88/cx88-dvb.c
index afde3789d702..6afa3fba1f4f 100644
--- a/drivers/media/video/cx88/cx88-dvb.c
+++ b/drivers/media/video/cx88/cx88-dvb.c
@@ -537,10 +537,10 @@ static int dvb_register(struct cx8802_dev *dev)
537 switch (dev->core->board) { 537 switch (dev->core->board) {
538#ifdef HAVE_CX22702 538#ifdef HAVE_CX22702
539 case CX88_BOARD_HAUPPAUGE_DVB_T1: 539 case CX88_BOARD_HAUPPAUGE_DVB_T1:
540 dev->dvb.frontend = cx22702_attach(&hauppauge_novat_config, 540 dev->dvb.frontend = dvb_attach(cx22702_attach, &hauppauge_novat_config,
541 &dev->core->i2c_adap); 541 &dev->core->i2c_adap);
542 if (dev->dvb.frontend != NULL) { 542 if (dev->dvb.frontend != NULL) {
543 dvb_pll_attach(dev->dvb.frontend, 0x61, 543 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
544 &dev->core->i2c_adap, 544 &dev->core->i2c_adap,
545 &dvb_pll_thomson_dtt759x); 545 &dvb_pll_thomson_dtt759x);
546 } 546 }
@@ -549,10 +549,10 @@ static int dvb_register(struct cx8802_dev *dev)
549 case CX88_BOARD_CONEXANT_DVB_T1: 549 case CX88_BOARD_CONEXANT_DVB_T1:
550 case CX88_BOARD_KWORLD_DVB_T_CX22702: 550 case CX88_BOARD_KWORLD_DVB_T_CX22702:
551 case CX88_BOARD_WINFAST_DTV1000: 551 case CX88_BOARD_WINFAST_DTV1000:
552 dev->dvb.frontend = cx22702_attach(&connexant_refboard_config, 552 dev->dvb.frontend = dvb_attach(cx22702_attach, &connexant_refboard_config,
553 &dev->core->i2c_adap); 553 &dev->core->i2c_adap);
554 if (dev->dvb.frontend != NULL) { 554 if (dev->dvb.frontend != NULL) {
555 dvb_pll_attach(dev->dvb.frontend, 0x60, 555 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x60,
556 &dev->core->i2c_adap, 556 &dev->core->i2c_adap,
557 &dvb_pll_thomson_dtt7579); 557 &dvb_pll_thomson_dtt7579);
558 } 558 }
@@ -560,10 +560,10 @@ static int dvb_register(struct cx8802_dev *dev)
560 case CX88_BOARD_WINFAST_DTV2000H: 560 case CX88_BOARD_WINFAST_DTV2000H:
561 case CX88_BOARD_HAUPPAUGE_HVR1100: 561 case CX88_BOARD_HAUPPAUGE_HVR1100:
562 case CX88_BOARD_HAUPPAUGE_HVR1100LP: 562 case CX88_BOARD_HAUPPAUGE_HVR1100LP:
563 dev->dvb.frontend = cx22702_attach(&hauppauge_hvr1100_config, 563 dev->dvb.frontend = dvb_attach(cx22702_attach, &hauppauge_hvr1100_config,
564 &dev->core->i2c_adap); 564 &dev->core->i2c_adap);
565 if (dev->dvb.frontend != NULL) { 565 if (dev->dvb.frontend != NULL) {
566 dvb_pll_attach(dev->dvb.frontend, 0x61, 566 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
567 &dev->core->i2c_adap, 567 &dev->core->i2c_adap,
568 &dvb_pll_fmd1216me); 568 &dvb_pll_fmd1216me);
569 } 569 }
@@ -572,10 +572,10 @@ static int dvb_register(struct cx8802_dev *dev)
572#if defined(HAVE_MT352) || defined(HAVE_ZL10353) 572#if defined(HAVE_MT352) || defined(HAVE_ZL10353)
573 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS: 573 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS:
574#ifdef HAVE_MT352 574#ifdef HAVE_MT352
575 dev->dvb.frontend = mt352_attach(&dvico_fusionhdtv, 575 dev->dvb.frontend = dvb_attach(mt352_attach, &dvico_fusionhdtv,
576 &dev->core->i2c_adap); 576 &dev->core->i2c_adap);
577 if (dev->dvb.frontend != NULL) { 577 if (dev->dvb.frontend != NULL) {
578 dvb_pll_attach(dev->dvb.frontend, 0x60, 578 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x60,
579 &dev->core->i2c_adap, 579 &dev->core->i2c_adap,
580 &dvb_pll_thomson_dtt7579); 580 &dvb_pll_thomson_dtt7579);
581 break; 581 break;
@@ -583,10 +583,10 @@ static int dvb_register(struct cx8802_dev *dev)
583#endif 583#endif
584#ifdef HAVE_ZL10353 584#ifdef HAVE_ZL10353
585 /* ZL10353 replaces MT352 on later cards */ 585 /* ZL10353 replaces MT352 on later cards */
586 dev->dvb.frontend = zl10353_attach(&dvico_fusionhdtv_plus_v1_1, 586 dev->dvb.frontend = dvb_attach(zl10353_attach, &dvico_fusionhdtv_plus_v1_1,
587 &dev->core->i2c_adap); 587 &dev->core->i2c_adap);
588 if (dev->dvb.frontend != NULL) { 588 if (dev->dvb.frontend != NULL) {
589 dvb_pll_attach(dev->dvb.frontend, 0x60, 589 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x60,
590 &dev->core->i2c_adap, 590 &dev->core->i2c_adap,
591 &dvb_pll_thomson_dtt7579); 591 &dvb_pll_thomson_dtt7579);
592 } 592 }
@@ -596,10 +596,10 @@ static int dvb_register(struct cx8802_dev *dev)
596#ifdef HAVE_MT352 596#ifdef HAVE_MT352
597 /* The tin box says DEE1601, but it seems to be DTT7579 597 /* The tin box says DEE1601, but it seems to be DTT7579
598 * compatible, with a slightly different MT352 AGC gain. */ 598 * compatible, with a slightly different MT352 AGC gain. */
599 dev->dvb.frontend = mt352_attach(&dvico_fusionhdtv_dual, 599 dev->dvb.frontend = dvb_attach(mt352_attach, &dvico_fusionhdtv_dual,
600 &dev->core->i2c_adap); 600 &dev->core->i2c_adap);
601 if (dev->dvb.frontend != NULL) { 601 if (dev->dvb.frontend != NULL) {
602 dvb_pll_attach(dev->dvb.frontend, 0x61, 602 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
603 &dev->core->i2c_adap, 603 &dev->core->i2c_adap,
604 &dvb_pll_thomson_dtt7579); 604 &dvb_pll_thomson_dtt7579);
605 break; 605 break;
@@ -607,10 +607,10 @@ static int dvb_register(struct cx8802_dev *dev)
607#endif 607#endif
608#ifdef HAVE_ZL10353 608#ifdef HAVE_ZL10353
609 /* ZL10353 replaces MT352 on later cards */ 609 /* ZL10353 replaces MT352 on later cards */
610 dev->dvb.frontend = zl10353_attach(&dvico_fusionhdtv_plus_v1_1, 610 dev->dvb.frontend = dvb_attach(zl10353_attach, &dvico_fusionhdtv_plus_v1_1,
611 &dev->core->i2c_adap); 611 &dev->core->i2c_adap);
612 if (dev->dvb.frontend != NULL) { 612 if (dev->dvb.frontend != NULL) {
613 dvb_pll_attach(dev->dvb.frontend, 0x61, 613 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
614 &dev->core->i2c_adap, 614 &dev->core->i2c_adap,
615 &dvb_pll_thomson_dtt7579); 615 &dvb_pll_thomson_dtt7579);
616 } 616 }
@@ -619,10 +619,10 @@ static int dvb_register(struct cx8802_dev *dev)
619#endif /* HAVE_MT352 || HAVE_ZL10353 */ 619#endif /* HAVE_MT352 || HAVE_ZL10353 */
620#ifdef HAVE_MT352 620#ifdef HAVE_MT352
621 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1: 621 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1:
622 dev->dvb.frontend = mt352_attach(&dvico_fusionhdtv, 622 dev->dvb.frontend = dvb_attach(mt352_attach, &dvico_fusionhdtv,
623 &dev->core->i2c_adap); 623 &dev->core->i2c_adap);
624 if (dev->dvb.frontend != NULL) { 624 if (dev->dvb.frontend != NULL) {
625 dvb_pll_attach(dev->dvb.frontend, 0x61, 625 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
626 &dev->core->i2c_adap, 626 &dev->core->i2c_adap,
627 &dvb_pll_lg_z201); 627 &dvb_pll_lg_z201);
628 } 628 }
@@ -630,10 +630,10 @@ static int dvb_register(struct cx8802_dev *dev)
630 case CX88_BOARD_KWORLD_DVB_T: 630 case CX88_BOARD_KWORLD_DVB_T:
631 case CX88_BOARD_DNTV_LIVE_DVB_T: 631 case CX88_BOARD_DNTV_LIVE_DVB_T:
632 case CX88_BOARD_ADSTECH_DVB_T_PCI: 632 case CX88_BOARD_ADSTECH_DVB_T_PCI:
633 dev->dvb.frontend = mt352_attach(&dntv_live_dvbt_config, 633 dev->dvb.frontend = dvb_attach(mt352_attach, &dntv_live_dvbt_config,
634 &dev->core->i2c_adap); 634 &dev->core->i2c_adap);
635 if (dev->dvb.frontend != NULL) { 635 if (dev->dvb.frontend != NULL) {
636 dvb_pll_attach(dev->dvb.frontend, 0x61, 636 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
637 &dev->core->i2c_adap, 637 &dev->core->i2c_adap,
638 &dvb_pll_unknown_1); 638 &dvb_pll_unknown_1);
639 } 639 }
@@ -642,7 +642,7 @@ static int dvb_register(struct cx8802_dev *dev)
642#ifdef HAVE_VP3054_I2C 642#ifdef HAVE_VP3054_I2C
643 dev->core->pll_addr = 0x61; 643 dev->core->pll_addr = 0x61;
644 dev->core->pll_desc = &dvb_pll_fmd1216me; 644 dev->core->pll_desc = &dvb_pll_fmd1216me;
645 dev->dvb.frontend = mt352_attach(&dntv_live_dvbt_pro_config, 645 dev->dvb.frontend = dvb_attach(mt352_attach, &dntv_live_dvbt_pro_config,
646 &((struct vp3054_i2c_state *)dev->card_priv)->adap); 646 &((struct vp3054_i2c_state *)dev->card_priv)->adap);
647 if (dev->dvb.frontend != NULL) { 647 if (dev->dvb.frontend != NULL) {
648 dev->dvb.frontend->ops.tuner_ops.set_params = dntv_live_dvbt_pro_tuner_set_params; 648 dev->dvb.frontend->ops.tuner_ops.set_params = dntv_live_dvbt_pro_tuner_set_params;
@@ -656,7 +656,7 @@ static int dvb_register(struct cx8802_dev *dev)
656 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID: 656 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID:
657 dev->core->pll_addr = 0x61; 657 dev->core->pll_addr = 0x61;
658 dev->core->pll_desc = &dvb_pll_thomson_fe6600; 658 dev->core->pll_desc = &dvb_pll_thomson_fe6600;
659 dev->dvb.frontend = zl10353_attach(&dvico_fusionhdtv_hybrid, 659 dev->dvb.frontend = dvb_attach(zl10353_attach, &dvico_fusionhdtv_hybrid,
660 &dev->core->i2c_adap); 660 &dev->core->i2c_adap);
661 if (dev->dvb.frontend != NULL) { 661 if (dev->dvb.frontend != NULL) {
662 dev->dvb.frontend->ops.tuner_ops.set_params = dvico_hybrid_tuner_set_params; 662 dev->dvb.frontend->ops.tuner_ops.set_params = dvico_hybrid_tuner_set_params;
@@ -665,10 +665,10 @@ static int dvb_register(struct cx8802_dev *dev)
665#endif 665#endif
666#ifdef HAVE_OR51132 666#ifdef HAVE_OR51132
667 case CX88_BOARD_PCHDTV_HD3000: 667 case CX88_BOARD_PCHDTV_HD3000:
668 dev->dvb.frontend = or51132_attach(&pchdtv_hd3000, 668 dev->dvb.frontend = dvb_attach(or51132_attach, &pchdtv_hd3000,
669 &dev->core->i2c_adap); 669 &dev->core->i2c_adap);
670 if (dev->dvb.frontend != NULL) { 670 if (dev->dvb.frontend != NULL) {
671 dvb_pll_attach(dev->dvb.frontend, 0x61, 671 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
672 &dev->core->i2c_adap, 672 &dev->core->i2c_adap,
673 &dvb_pll_thomson_dtt761x); 673 &dvb_pll_thomson_dtt761x);
674 } 674 }
@@ -690,7 +690,7 @@ static int dvb_register(struct cx8802_dev *dev)
690 fusionhdtv_3_gold.pll_rf_set = lgdt330x_pll_rf_set; 690 fusionhdtv_3_gold.pll_rf_set = lgdt330x_pll_rf_set;
691 dev->core->pll_addr = 0x61; 691 dev->core->pll_addr = 0x61;
692 dev->core->pll_desc = &dvb_pll_microtune_4042; 692 dev->core->pll_desc = &dvb_pll_microtune_4042;
693 dev->dvb.frontend = lgdt330x_attach(&fusionhdtv_3_gold, 693 dev->dvb.frontend = dvb_attach(lgdt330x_attach, &fusionhdtv_3_gold,
694 &dev->core->i2c_adap); 694 &dev->core->i2c_adap);
695 if (dev->dvb.frontend != NULL) { 695 if (dev->dvb.frontend != NULL) {
696 dev->dvb.frontend->ops.tuner_ops.set_params = lgdt3302_tuner_set_params; 696 dev->dvb.frontend->ops.tuner_ops.set_params = lgdt3302_tuner_set_params;
@@ -709,7 +709,7 @@ static int dvb_register(struct cx8802_dev *dev)
709 mdelay(200); 709 mdelay(200);
710 dev->core->pll_addr = 0x61; 710 dev->core->pll_addr = 0x61;
711 dev->core->pll_desc = &dvb_pll_thomson_dtt761x; 711 dev->core->pll_desc = &dvb_pll_thomson_dtt761x;
712 dev->dvb.frontend = lgdt330x_attach(&fusionhdtv_3_gold, 712 dev->dvb.frontend = dvb_attach(lgdt330x_attach, &fusionhdtv_3_gold,
713 &dev->core->i2c_adap); 713 &dev->core->i2c_adap);
714 if (dev->dvb.frontend != NULL) { 714 if (dev->dvb.frontend != NULL) {
715 dev->dvb.frontend->ops.tuner_ops.set_params = lgdt3302_tuner_set_params; 715 dev->dvb.frontend->ops.tuner_ops.set_params = lgdt3302_tuner_set_params;
@@ -726,7 +726,7 @@ static int dvb_register(struct cx8802_dev *dev)
726 mdelay(100); 726 mdelay(100);
727 cx_set(MO_GP0_IO, 1); 727 cx_set(MO_GP0_IO, 1);
728 mdelay(200); 728 mdelay(200);
729 dev->dvb.frontend = lgdt330x_attach(&fusionhdtv_5_gold, 729 dev->dvb.frontend = dvb_attach(lgdt330x_attach, &fusionhdtv_5_gold,
730 &dev->core->i2c_adap); 730 &dev->core->i2c_adap);
731 if (dev->dvb.frontend != NULL) { 731 if (dev->dvb.frontend != NULL) {
732 dev->dvb.frontend->ops.tuner_ops.set_params = lgdt3303_tuner_set_params; 732 dev->dvb.frontend->ops.tuner_ops.set_params = lgdt3303_tuner_set_params;
@@ -743,7 +743,7 @@ static int dvb_register(struct cx8802_dev *dev)
743 mdelay(100); 743 mdelay(100);
744 cx_set(MO_GP0_IO, 1); 744 cx_set(MO_GP0_IO, 1);
745 mdelay(200); 745 mdelay(200);
746 dev->dvb.frontend = lgdt330x_attach(&pchdtv_hd5500, 746 dev->dvb.frontend = dvb_attach(lgdt330x_attach, &pchdtv_hd5500,
747 &dev->core->i2c_adap); 747 &dev->core->i2c_adap);
748 if (dev->dvb.frontend != NULL) { 748 if (dev->dvb.frontend != NULL) {
749 dev->dvb.frontend->ops.tuner_ops.set_params = lgdt3303_tuner_set_params; 749 dev->dvb.frontend->ops.tuner_ops.set_params = lgdt3303_tuner_set_params;
@@ -753,10 +753,10 @@ static int dvb_register(struct cx8802_dev *dev)
753#endif 753#endif
754#ifdef HAVE_NXT200X 754#ifdef HAVE_NXT200X
755 case CX88_BOARD_ATI_HDTVWONDER: 755 case CX88_BOARD_ATI_HDTVWONDER:
756 dev->dvb.frontend = nxt200x_attach(&ati_hdtvwonder, 756 dev->dvb.frontend = dvb_attach(nxt200x_attach, &ati_hdtvwonder,
757 &dev->core->i2c_adap); 757 &dev->core->i2c_adap);
758 if (dev->dvb.frontend != NULL) { 758 if (dev->dvb.frontend != NULL) {
759 dvb_pll_attach(dev->dvb.frontend, 0x61, 759 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
760 &dev->core->i2c_adap, 760 &dev->core->i2c_adap,
761 &dvb_pll_tuv1236d); 761 &dvb_pll_tuv1236d);
762 } 762 }
@@ -765,15 +765,15 @@ static int dvb_register(struct cx8802_dev *dev)
765#ifdef HAVE_CX24123 765#ifdef HAVE_CX24123
766 case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1: 766 case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1:
767 case CX88_BOARD_HAUPPAUGE_NOVASE2_S1: 767 case CX88_BOARD_HAUPPAUGE_NOVASE2_S1:
768 dev->dvb.frontend = cx24123_attach(&hauppauge_novas_config, 768 dev->dvb.frontend = dvb_attach(cx24123_attach, &hauppauge_novas_config,
769 &dev->core->i2c_adap); 769 &dev->core->i2c_adap);
770 if (dev->dvb.frontend) { 770 if (dev->dvb.frontend) {
771 isl6421_attach(dev->dvb.frontend, &dev->core->i2c_adap, 771 dvb_attach(isl6421_attach, dev->dvb.frontend, &dev->core->i2c_adap,
772 0x08, 0x00, 0x00); 772 0x08, 0x00, 0x00);
773 } 773 }
774 break; 774 break;
775 case CX88_BOARD_KWORLD_DVBS_100: 775 case CX88_BOARD_KWORLD_DVBS_100:
776 dev->dvb.frontend = cx24123_attach(&kworld_dvbs_100_config, 776 dev->dvb.frontend = dvb_attach(cx24123_attach, &kworld_dvbs_100_config,
777 &dev->core->i2c_adap); 777 &dev->core->i2c_adap);
778 if (dev->dvb.frontend) { 778 if (dev->dvb.frontend) {
779 dev->core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage; 779 dev->core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage;
@@ -781,7 +781,7 @@ static int dvb_register(struct cx8802_dev *dev)
781 } 781 }
782 break; 782 break;
783 case CX88_BOARD_GENIATECH_DVBS: 783 case CX88_BOARD_GENIATECH_DVBS:
784 dev->dvb.frontend = cx24123_attach(&geniatech_dvbs_config, 784 dev->dvb.frontend = dvb_attach(cx24123_attach, &geniatech_dvbs_config,
785 &dev->core->i2c_adap); 785 &dev->core->i2c_adap);
786 if (dev->dvb.frontend) { 786 if (dev->dvb.frontend) {
787 dev->core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage; 787 dev->core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage;
diff --git a/drivers/media/video/saa7134/saa7134-dvb.c b/drivers/media/video/saa7134/saa7134-dvb.c
index 2ffa5b5790ae..7bc3af7af50c 100644
--- a/drivers/media/video/saa7134/saa7134-dvb.c
+++ b/drivers/media/video/saa7134/saa7134-dvb.c
@@ -1057,7 +1057,7 @@ static int dvb_init(struct saa7134_dev *dev)
1057#ifdef HAVE_MT352 1057#ifdef HAVE_MT352
1058 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL: 1058 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
1059 printk("%s: pinnacle 300i dvb setup\n",dev->name); 1059 printk("%s: pinnacle 300i dvb setup\n",dev->name);
1060 dev->dvb.frontend = mt352_attach(&pinnacle_300i, 1060 dev->dvb.frontend = dvb_attach(mt352_attach, &pinnacle_300i,
1061 &dev->i2c_adap); 1061 &dev->i2c_adap);
1062 if (dev->dvb.frontend) { 1062 if (dev->dvb.frontend) {
1063 dev->dvb.frontend->ops.tuner_ops.set_params = mt352_pinnacle_tuner_set_params; 1063 dev->dvb.frontend->ops.tuner_ops.set_params = mt352_pinnacle_tuner_set_params;
@@ -1066,7 +1066,7 @@ static int dvb_init(struct saa7134_dev *dev)
1066 1066
1067 case SAA7134_BOARD_AVERMEDIA_777: 1067 case SAA7134_BOARD_AVERMEDIA_777:
1068 printk("%s: avertv 777 dvb setup\n",dev->name); 1068 printk("%s: avertv 777 dvb setup\n",dev->name);
1069 dev->dvb.frontend = mt352_attach(&avermedia_777, 1069 dev->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777,
1070 &dev->i2c_adap); 1070 &dev->i2c_adap);
1071 if (dev->dvb.frontend) { 1071 if (dev->dvb.frontend) {
1072 dev->dvb.frontend->ops.tuner_ops.calc_regs = mt352_aver777_tuner_calc_regs; 1072 dev->dvb.frontend->ops.tuner_ops.calc_regs = mt352_aver777_tuner_calc_regs;
@@ -1075,7 +1075,7 @@ static int dvb_init(struct saa7134_dev *dev)
1075#endif 1075#endif
1076#ifdef HAVE_TDA1004X 1076#ifdef HAVE_TDA1004X
1077 case SAA7134_BOARD_MD7134: 1077 case SAA7134_BOARD_MD7134:
1078 dev->dvb.frontend = tda10046_attach(&medion_cardbus, 1078 dev->dvb.frontend = dvb_attach(tda10046_attach, &medion_cardbus,
1079 &dev->i2c_adap); 1079 &dev->i2c_adap);
1080 if (dev->dvb.frontend) { 1080 if (dev->dvb.frontend) {
1081 dev->dvb.frontend->ops.tuner_ops.init = philips_fmd1216_tuner_init; 1081 dev->dvb.frontend->ops.tuner_ops.init = philips_fmd1216_tuner_init;
@@ -1084,7 +1084,7 @@ static int dvb_init(struct saa7134_dev *dev)
1084 } 1084 }
1085 break; 1085 break;
1086 case SAA7134_BOARD_PHILIPS_TOUGH: 1086 case SAA7134_BOARD_PHILIPS_TOUGH:
1087 dev->dvb.frontend = tda10046_attach(&philips_tu1216_60_config, 1087 dev->dvb.frontend = dvb_attach(tda10046_attach, &philips_tu1216_60_config,
1088 &dev->i2c_adap); 1088 &dev->i2c_adap);
1089 if (dev->dvb.frontend) { 1089 if (dev->dvb.frontend) {
1090 dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_tuner_60_init; 1090 dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_tuner_60_init;
@@ -1092,7 +1092,7 @@ static int dvb_init(struct saa7134_dev *dev)
1092 } 1092 }
1093 break; 1093 break;
1094 case SAA7134_BOARD_FLYDVBTDUO: 1094 case SAA7134_BOARD_FLYDVBTDUO:
1095 dev->dvb.frontend = tda10046_attach(&tda827x_lifeview_config, 1095 dev->dvb.frontend = dvb_attach(tda10046_attach, &tda827x_lifeview_config,
1096 &dev->i2c_adap); 1096 &dev->i2c_adap);
1097 if (dev->dvb.frontend) { 1097 if (dev->dvb.frontend) {
1098 dev->dvb.frontend->ops.tuner_ops.init = philips_tda827x_tuner_init; 1098 dev->dvb.frontend->ops.tuner_ops.init = philips_tda827x_tuner_init;
@@ -1101,7 +1101,7 @@ static int dvb_init(struct saa7134_dev *dev)
1101 } 1101 }
1102 break; 1102 break;
1103 case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS: 1103 case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS:
1104 dev->dvb.frontend = tda10046_attach(&tda827x_lifeview_config, 1104 dev->dvb.frontend = dvb_attach(tda10046_attach, &tda827x_lifeview_config,
1105 &dev->i2c_adap); 1105 &dev->i2c_adap);
1106 if (dev->dvb.frontend) { 1106 if (dev->dvb.frontend) {
1107 dev->dvb.frontend->ops.tuner_ops.init = philips_tda827x_tuner_init; 1107 dev->dvb.frontend->ops.tuner_ops.init = philips_tda827x_tuner_init;
@@ -1110,7 +1110,7 @@ static int dvb_init(struct saa7134_dev *dev)
1110 } 1110 }
1111 break; 1111 break;
1112 case SAA7134_BOARD_PHILIPS_EUROPA: 1112 case SAA7134_BOARD_PHILIPS_EUROPA:
1113 dev->dvb.frontend = tda10046_attach(&philips_europa_config, 1113 dev->dvb.frontend = dvb_attach(tda10046_attach, &philips_europa_config,
1114 &dev->i2c_adap); 1114 &dev->i2c_adap);
1115 if (dev->dvb.frontend) { 1115 if (dev->dvb.frontend) {
1116 dev->original_demod_sleep = dev->dvb.frontend->ops.sleep; 1116 dev->original_demod_sleep = dev->dvb.frontend->ops.sleep;
@@ -1121,7 +1121,7 @@ static int dvb_init(struct saa7134_dev *dev)
1121 } 1121 }
1122 break; 1122 break;
1123 case SAA7134_BOARD_VIDEOMATE_DVBT_300: 1123 case SAA7134_BOARD_VIDEOMATE_DVBT_300:
1124 dev->dvb.frontend = tda10046_attach(&philips_europa_config, 1124 dev->dvb.frontend = dvb_attach(tda10046_attach, &philips_europa_config,
1125 &dev->i2c_adap); 1125 &dev->i2c_adap);
1126 if (dev->dvb.frontend) { 1126 if (dev->dvb.frontend) {
1127 dev->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init; 1127 dev->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
@@ -1130,7 +1130,7 @@ static int dvb_init(struct saa7134_dev *dev)
1130 } 1130 }
1131 break; 1131 break;
1132 case SAA7134_BOARD_VIDEOMATE_DVBT_200: 1132 case SAA7134_BOARD_VIDEOMATE_DVBT_200:
1133 dev->dvb.frontend = tda10046_attach(&philips_tu1216_61_config, 1133 dev->dvb.frontend = dvb_attach(tda10046_attach, &philips_tu1216_61_config,
1134 &dev->i2c_adap); 1134 &dev->i2c_adap);
1135 if (dev->dvb.frontend) { 1135 if (dev->dvb.frontend) {
1136 dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_tuner_61_init; 1136 dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_tuner_61_init;
@@ -1138,7 +1138,7 @@ static int dvb_init(struct saa7134_dev *dev)
1138 } 1138 }
1139 break; 1139 break;
1140 case SAA7134_BOARD_PHILIPS_TIGER: 1140 case SAA7134_BOARD_PHILIPS_TIGER:
1141 dev->dvb.frontend = tda10046_attach(&philips_tiger_config, 1141 dev->dvb.frontend = dvb_attach(tda10046_attach, &philips_tiger_config,
1142 &dev->i2c_adap); 1142 &dev->i2c_adap);
1143 if (dev->dvb.frontend) { 1143 if (dev->dvb.frontend) {
1144 dev->dvb.frontend->ops.tuner_ops.init = philips_tiger_tuner_init; 1144 dev->dvb.frontend->ops.tuner_ops.init = philips_tiger_tuner_init;
@@ -1147,7 +1147,7 @@ static int dvb_init(struct saa7134_dev *dev)
1147 } 1147 }
1148 break; 1148 break;
1149 case SAA7134_BOARD_ASUSTeK_P7131_DUAL: 1149 case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
1150 dev->dvb.frontend = tda10046_attach(&philips_tiger_config, 1150 dev->dvb.frontend = dvb_attach(tda10046_attach, &philips_tiger_config,
1151 &dev->i2c_adap); 1151 &dev->i2c_adap);
1152 if (dev->dvb.frontend) { 1152 if (dev->dvb.frontend) {
1153 dev->dvb.frontend->ops.tuner_ops.init = philips_tiger_tuner_init; 1153 dev->dvb.frontend->ops.tuner_ops.init = philips_tiger_tuner_init;
@@ -1156,7 +1156,7 @@ static int dvb_init(struct saa7134_dev *dev)
1156 } 1156 }
1157 break; 1157 break;
1158 case SAA7134_BOARD_FLYDVBT_LR301: 1158 case SAA7134_BOARD_FLYDVBT_LR301:
1159 dev->dvb.frontend = tda10046_attach(&tda827x_lifeview_config, 1159 dev->dvb.frontend = dvb_attach(tda10046_attach, &tda827x_lifeview_config,
1160 &dev->i2c_adap); 1160 &dev->i2c_adap);
1161 if (dev->dvb.frontend) { 1161 if (dev->dvb.frontend) {
1162 dev->dvb.frontend->ops.tuner_ops.init = philips_tda827x_tuner_init; 1162 dev->dvb.frontend->ops.tuner_ops.init = philips_tda827x_tuner_init;
@@ -1165,7 +1165,7 @@ static int dvb_init(struct saa7134_dev *dev)
1165 } 1165 }
1166 break; 1166 break;
1167 case SAA7134_BOARD_FLYDVB_TRIO: 1167 case SAA7134_BOARD_FLYDVB_TRIO:
1168 dev->dvb.frontend = tda10046_attach(&lifeview_trio_config, 1168 dev->dvb.frontend = dvb_attach(tda10046_attach, &lifeview_trio_config,
1169 &dev->i2c_adap); 1169 &dev->i2c_adap);
1170 if (dev->dvb.frontend) { 1170 if (dev->dvb.frontend) {
1171 dev->dvb.frontend->ops.tuner_ops.sleep = lifeview_trio_tuner_sleep; 1171 dev->dvb.frontend->ops.tuner_ops.sleep = lifeview_trio_tuner_sleep;
@@ -1173,7 +1173,7 @@ static int dvb_init(struct saa7134_dev *dev)
1173 } 1173 }
1174 break; 1174 break;
1175 case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331: 1175 case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331:
1176 dev->dvb.frontend = tda10046_attach(&ads_tech_duo_config, 1176 dev->dvb.frontend = dvb_attach(tda10046_attach, &ads_tech_duo_config,
1177 &dev->i2c_adap); 1177 &dev->i2c_adap);
1178 if (dev->dvb.frontend) { 1178 if (dev->dvb.frontend) {
1179 dev->dvb.frontend->ops.tuner_ops.init = ads_duo_tuner_init; 1179 dev->dvb.frontend->ops.tuner_ops.init = ads_duo_tuner_init;
@@ -1182,7 +1182,7 @@ static int dvb_init(struct saa7134_dev *dev)
1182 } 1182 }
1183 break; 1183 break;
1184 case SAA7134_BOARD_TEVION_DVBT_220RF: 1184 case SAA7134_BOARD_TEVION_DVBT_220RF:
1185 dev->dvb.frontend = tda10046_attach(&tevion_dvbt220rf_config, 1185 dev->dvb.frontend = dvb_attach(tda10046_attach, &tevion_dvbt220rf_config,
1186 &dev->i2c_adap); 1186 &dev->i2c_adap);
1187 if (dev->dvb.frontend) { 1187 if (dev->dvb.frontend) {
1188 dev->dvb.frontend->ops.tuner_ops.sleep = tevion_dvb220rf_tuner_sleep; 1188 dev->dvb.frontend->ops.tuner_ops.sleep = tevion_dvb220rf_tuner_sleep;
@@ -1190,7 +1190,7 @@ static int dvb_init(struct saa7134_dev *dev)
1190 } 1190 }
1191 break; 1191 break;
1192 case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS: 1192 case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS:
1193 dev->dvb.frontend = tda10046_attach(&ads_tech_duo_config, 1193 dev->dvb.frontend = dvb_attach(tda10046_attach, &ads_tech_duo_config,
1194 &dev->i2c_adap); 1194 &dev->i2c_adap);
1195 if (dev->dvb.frontend) { 1195 if (dev->dvb.frontend) {
1196 dev->dvb.frontend->ops.tuner_ops.init = ads_duo_tuner_init; 1196 dev->dvb.frontend->ops.tuner_ops.init = ads_duo_tuner_init;
@@ -1210,15 +1210,15 @@ static int dvb_init(struct saa7134_dev *dev)
1210#endif 1210#endif
1211#ifdef HAVE_NXT200X 1211#ifdef HAVE_NXT200X
1212 case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180: 1212 case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180:
1213 dev->dvb.frontend = nxt200x_attach(&avertvhda180, &dev->i2c_adap); 1213 dev->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180, &dev->i2c_adap);
1214 if (dev->dvb.frontend) { 1214 if (dev->dvb.frontend) {
1215 dvb_pll_attach(dev->dvb.frontend, 0x61, &dev->i2c_adap, &dvb_pll_tdhu2); 1215 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61, &dev->i2c_adap, &dvb_pll_tdhu2);
1216 } 1216 }
1217 break; 1217 break;
1218 case SAA7134_BOARD_KWORLD_ATSC110: 1218 case SAA7134_BOARD_KWORLD_ATSC110:
1219 dev->dvb.frontend = nxt200x_attach(&kworldatsc110, &dev->i2c_adap); 1219 dev->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110, &dev->i2c_adap);
1220 if (dev->dvb.frontend) { 1220 if (dev->dvb.frontend) {
1221 dvb_pll_attach(dev->dvb.frontend, 0x61, &dev->i2c_adap, &dvb_pll_tuv1236d); 1221 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61, &dev->i2c_adap, &dvb_pll_tuv1236d);
1222 } 1222 }
1223 break; 1223 break;
1224#endif 1224#endif
diff --git a/drivers/media/video/video-buf-dvb.c b/drivers/media/video/video-buf-dvb.c
index 7ee8a53cd336..376d354b27f6 100644
--- a/drivers/media/video/video-buf-dvb.c
+++ b/drivers/media/video/video-buf-dvb.c
@@ -223,6 +223,9 @@ fail_dmxdev:
223fail_dmx: 223fail_dmx:
224 dvb_unregister_frontend(dvb->frontend); 224 dvb_unregister_frontend(dvb->frontend);
225fail_frontend: 225fail_frontend:
226 dvb_detach(dvb->frontend->ops.release_sec, dvb->frontend);
227 dvb_detach(dvb->frontend->ops.tuner_ops.release, dvb->frontend);
228 dvb_detach(dvb->frontend->ops.release, dvb->frontend);
226 dvb_unregister_adapter(&dvb->adapter); 229 dvb_unregister_adapter(&dvb->adapter);
227fail_adapter: 230fail_adapter:
228 return result; 231 return result;
@@ -236,6 +239,9 @@ void videobuf_dvb_unregister(struct videobuf_dvb *dvb)
236 dvb_dmxdev_release(&dvb->dmxdev); 239 dvb_dmxdev_release(&dvb->dmxdev);
237 dvb_dmx_release(&dvb->demux); 240 dvb_dmx_release(&dvb->demux);
238 dvb_unregister_frontend(dvb->frontend); 241 dvb_unregister_frontend(dvb->frontend);
242 dvb_detach(dvb->frontend->ops.release_sec, dvb->frontend);
243 dvb_detach(dvb->frontend->ops.tuner_ops.release, dvb->frontend);
244 dvb_detach(dvb->frontend->ops.release, dvb->frontend);
239 dvb_unregister_adapter(&dvb->adapter); 245 dvb_unregister_adapter(&dvb->adapter);
240} 246}
241 247