Commit 8a484719 authored by Oliver Endriss's avatar Oliver Endriss Committed by Mauro Carvalho Chehab

[media] ngene: Clean-up driver initialisation (part 1)

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: default avatarOliver Endriss <o.endriss@gmx.de>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 5fec1857
...@@ -113,6 +113,7 @@ static int demod_attach_stv0900(struct ngene_channel *chan) ...@@ -113,6 +113,7 @@ static int demod_attach_stv0900(struct ngene_channel *chan)
0, chan->dev->card_info->lnb[chan->number])) { 0, chan->dev->card_info->lnb[chan->number])) {
printk(KERN_ERR DEVICE_NAME ": No LNBH24 found!\n"); printk(KERN_ERR DEVICE_NAME ": No LNBH24 found!\n");
dvb_frontend_detach(chan->fe); dvb_frontend_detach(chan->fe);
chan->fe = NULL;
return -ENODEV; return -ENODEV;
} }
......
...@@ -1482,23 +1482,32 @@ static int init_channel(struct ngene_channel *chan) ...@@ -1482,23 +1482,32 @@ static int init_channel(struct ngene_channel *chan)
if (io & NGENE_IO_TSIN) { if (io & NGENE_IO_TSIN) {
chan->fe = NULL; chan->fe = NULL;
if (ni->demod_attach[nr]) if (ni->demod_attach[nr]) {
ni->demod_attach[nr](chan); ret = ni->demod_attach[nr](chan);
if (chan->fe) { if (ret < 0)
if (dvb_register_frontend(adapter, chan->fe) < 0) { goto err_fe;
if (chan->fe->ops.release)
chan->fe->ops.release(chan->fe);
chan->fe = NULL;
} }
if (chan->fe && ni->tuner_attach[nr]) {
ret = ni->tuner_attach[nr](chan);
if (ret < 0)
goto err_fe;
} }
if (chan->fe && ni->tuner_attach[nr]) if (chan->fe) {
if (ni->tuner_attach[nr] (chan) < 0) { if (dvb_register_frontend(adapter, chan->fe) < 0)
printk(KERN_ERR DEVICE_NAME goto err_fe;
": Tuner attach failed on channel %d!\n",
nr);
} }
} }
return ret; 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) static int init_channels(struct ngene *dev)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment