[PATCH 06/16] ngene: Clean-up driver initialisation (part 1)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If tuner initialisation failed, the frontend node was not removed.
When the frontend was opened, a kernel oops occurred...

This is the first step to improve error handling during initialisation.

Signed-off-by: Oliver Endriss <o.endriss@xxxxxx>
---
 drivers/media/dvb/ngene/ngene-cards.c |    1 +
 drivers/media/dvb/ngene/ngene-core.c  |   35 ++++++++++++++++++++------------
 2 files changed, 23 insertions(+), 13 deletions(-)

diff --git a/drivers/media/dvb/ngene/ngene-cards.c b/drivers/media/dvb/ngene/ngene-cards.c
index 5e6b85c..fc93d10 100644
--- a/drivers/media/dvb/ngene/ngene-cards.c
+++ b/drivers/media/dvb/ngene/ngene-cards.c
@@ -113,6 +113,7 @@ static int demod_attach_stv0900(struct ngene_channel *chan)
 			0, chan->dev->card_info->lnb[chan->number])) {
 		printk(KERN_ERR DEVICE_NAME ": No LNBH24 found!\n");
 		dvb_frontend_detach(chan->fe);
+		chan->fe = NULL;
 		return -ENODEV;
 	}
 
diff --git a/drivers/media/dvb/ngene/ngene-core.c b/drivers/media/dvb/ngene/ngene-core.c
index 83fd74e..7ce8737 100644
--- a/drivers/media/dvb/ngene/ngene-core.c
+++ b/drivers/media/dvb/ngene/ngene-core.c
@@ -1481,23 +1481,32 @@ static int init_channel(struct ngene_channel *chan)
 
 	if (io & NGENE_IO_TSIN) {
 		chan->fe = NULL;
-		if (ni->demod_attach[nr])
-			ni->demod_attach[nr](chan);
+		if (ni->demod_attach[nr]) {
+			ret = ni->demod_attach[nr](chan);
+			if (ret < 0)
+				goto err_fe;
+		}
+		if (chan->fe && ni->tuner_attach[nr]) {
+			ret = ni->tuner_attach[nr](chan);
+			if (ret < 0)
+				goto err_fe;
+		}
 		if (chan->fe) {
-			if (dvb_register_frontend(adapter, chan->fe) < 0) {
-				if (chan->fe->ops.release)
-					chan->fe->ops.release(chan->fe);
-				chan->fe = NULL;
-			}
+			if (dvb_register_frontend(adapter, chan->fe) < 0)
+				goto err_fe;
 		}
-		if (chan->fe && ni->tuner_attach[nr])
-			if (ni->tuner_attach[nr] (chan) < 0) {
-				printk(KERN_ERR DEVICE_NAME
-				       ": Tuner attach failed on channel %d!\n",
-				       nr);
-			}
 	}
 	return ret;
+
+err_fe:
+	if (chan->fe) {
+		dvb_frontend_detach(chan->fe);
+		chan->fe = NULL;
+	}
+/*	FIXME: this causes an oops... */
+/*	release_channel(chan);        */
+/*	return ret;                   */
+	return 0;
 }
 
 static int init_channels(struct ngene *dev)
-- 
1.6.5.3

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux