From 0912ad0b0fdee374f1f49d75fee341980f0868b6 Mon Sep 17 00:00:00 2001
From: Andrew de Quincey <adq_dvb@lidskialf.net>
Date: Tue, 8 Aug 2006 09:10:09 -0300
Subject: [PATCH] V4L/DVB (4392): Fix dst_ca attach

Move the call to dst_attach into the dst_attach function to eliminate
problems caused with dvb_attach.

Signed-off-by: Andrew de Quincey <adq_dvb@lidskialf.net>
Acked-by: Manu Abraham <manu@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
---
 drivers/media/dvb/bt8xx/dst.c        | 11 +++++------
 drivers/media/dvb/bt8xx/dst_ca.c     |  3 +--
 drivers/media/dvb/bt8xx/dst_common.h |  2 +-
 drivers/media/dvb/bt8xx/dvb-bt8xx.c  |  5 -----
 4 files changed, 7 insertions(+), 14 deletions(-)

diff --git a/drivers/media/dvb/bt8xx/dst.c b/drivers/media/dvb/bt8xx/dst.c
index a853c14c61d3..52b6fb2455f9 100644
--- a/drivers/media/dvb/bt8xx/dst.c
+++ b/drivers/media/dvb/bt8xx/dst.c
@@ -1715,12 +1715,6 @@ static int dst_get_frontend(struct dvb_frontend *fe, struct dvb_frontend_paramet
 static void dst_release(struct dvb_frontend *fe)
 {
 	struct dst_state *state = fe->demodulator_priv;
-
-#ifdef CONFIG_DVB_CORE_ATTACH
-	if (state->dst_hw_cap & DST_TYPE_HAS_CA)
-		symbol_put(dst_ca_attach);
-#endif
-
 	kfree(state);
 }
 
@@ -1758,6 +1752,11 @@ struct dst_state *dst_attach(struct dst_state *state, struct dvb_adapter *dvb_ad
 	}
 	state->frontend.demodulator_priv = state;
 
+	/*	Attach other DST peripherals if any		*/
+	/*	Conditional Access device			*/
+	if (state->dst_hw_cap & DST_TYPE_HAS_CA)
+		dst_ca_attach(state, dvb_adapter);
+
 	return state;				/*	Manu (DST is a card not a frontend)	*/
 }
 
diff --git a/drivers/media/dvb/bt8xx/dst_ca.c b/drivers/media/dvb/bt8xx/dst_ca.c
index c4ff1abc15c3..df0f68fbf24b 100644
--- a/drivers/media/dvb/bt8xx/dst_ca.c
+++ b/drivers/media/dvb/bt8xx/dst_ca.c
@@ -699,12 +699,11 @@ static struct dvb_device dvbdev_ca = {
 	.fops = &dst_ca_fops
 };
 
-ssize_t dst_ca_attach(struct dst_state *dst, struct dvb_adapter *dvb_adapter)
+void dst_ca_attach(struct dst_state *dst, struct dvb_adapter *dvb_adapter)
 {
 	struct dvb_device *dvbdev;
 	dprintk(verbose, DST_CA_ERROR, 1, "registering DST-CA device");
 	dvb_register_device(dvb_adapter, &dvbdev, &dvbdev_ca, dst, DVB_DEVICE_CA);
-	return 1; // must return non-zero for dvb_attach() to work
 }
 
 EXPORT_SYMBOL(dst_ca_attach);
diff --git a/drivers/media/dvb/bt8xx/dst_common.h b/drivers/media/dvb/bt8xx/dst_common.h
index 383452f9e497..66bc082824ad 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);
 int read_dst(struct dst_state *state, u8 * ret, u8 len);
 u8 dst_check_sum(u8 * buf, u32 len);
 struct dst_state* dst_attach(struct dst_state* state, struct dvb_adapter *dvb_adapter);
-ssize_t dst_ca_attach(struct dst_state *state, struct dvb_adapter *dvb_adapter);
+void dst_ca_attach(struct dst_state *state, struct dvb_adapter *dvb_adapter);
 int dst_gpio_outb(struct dst_state* state, u32 mask, u32 enbb, u32 outhigh, int delay);
 
 int 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 db1eba9a5c36..a19991f7af47 100644
--- a/drivers/media/dvb/bt8xx/dvb-bt8xx.c
+++ b/drivers/media/dvb/bt8xx/dvb-bt8xx.c
@@ -676,11 +676,6 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type)
 			break;
 		}
 		card->fe = &state->frontend;
-
-		/*	Attach other DST peripherals if any		*/
-		/*	Conditional Access device			*/
-		if (state->dst_hw_cap & DST_TYPE_HAS_CA)
-			dvb_attach(dst_ca_attach, state, &card->dvb_adapter);
 		break;
 
 	case BTTV_BOARD_PINNACLESAT:
-- 
2.20.1