Change to hold media tuner token exclusive mode in dvb_frontend_start() before starting the dvb thread and release from dvb_frontend_thread() when thread exits. dvb frontend thread is started only when the dvb device is opened in Read/Write mode. Signed-off-by: Shuah Khan <shuahkh@xxxxxxxxxxxxxxx> --- drivers/media/dvb-core/dvb_frontend.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/media/dvb-core/dvb_frontend.c b/drivers/media/dvb-core/dvb_frontend.c index c862ad7..22833c6 100644 --- a/drivers/media/dvb-core/dvb_frontend.c +++ b/drivers/media/dvb-core/dvb_frontend.c @@ -41,6 +41,7 @@ #include <linux/jiffies.h> #include <linux/kthread.h> #include <asm/processor.h> +#include <linux/media_tknres.h> #include "dvb_frontend.h" #include "dvbdev.h" @@ -742,6 +743,7 @@ restart: if (semheld) up(&fepriv->sem); dvb_frontend_wakeup(fe); + media_put_tuner_tkn(fe->dvb->device, MEDIA_MODE_DVB); return 0; } @@ -836,6 +838,13 @@ static int dvb_frontend_start(struct dvb_frontend *fe) fepriv->state = FESTATE_IDLE; fe->exit = DVB_FE_NO_EXIT; fepriv->thread = NULL; + + ret = media_get_tuner_tkn(fe->dvb->device, MEDIA_MODE_DVB); + if (ret == -EBUSY) { + dev_info(fe->dvb->device, "dvb: Tuner is busy\n"); + return ret; + } + mb(); fe_thread = kthread_run(dvb_frontend_thread, fe, @@ -846,6 +855,7 @@ static int dvb_frontend_start(struct dvb_frontend *fe) "dvb_frontend_start: failed to start kthread (%d)\n", ret); up(&fepriv->sem); + media_put_tuner_tkn(fe->dvb->device, MEDIA_MODE_DVB); return ret; } fepriv->thread = fe_thread; -- 1.7.10.4 -- 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