diff mbox

[4/5] media: dvb-core changes to use media tuner token api

Message ID cc4b6198b88277b2c0d56d288bde0e4c35e14d8b.1411397045.git.shuahkh@osg.samsung.com (mailing list archive)
State New, archived
Headers show

Commit Message

Shuah Khan Sept. 22, 2014, 3 p.m. UTC
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@osg.samsung.com>
---
 drivers/media/dvb-core/dvb_frontend.c |   10 ++++++++++
 1 file changed, 10 insertions(+)
diff mbox

Patch

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;