All of lore.kernel.org
 help / color / mirror / Atom feed
From: Shuah Khan <shuah.kh@samsung.com>
To: gregkh@linuxfoundation.org, m.chehab@samsung.com, tj@kernel.org,
	olebowle@gmx.com
Cc: Shuah Khan <shuah.kh@samsung.com>,
	linux-kernel@vger.kernel.org, linux-media@vger.kernel.org
Subject: [PATCH 2/4] media: dvb-fe changes to use tuner token
Date: Tue, 29 Apr 2014 13:49:24 -0600	[thread overview]
Message-ID: <9a211011e470e91ce4367529ba74cddb7fdaee60.1398797955.git.shuah.kh@samsung.com> (raw)
In-Reply-To: <cover.1398797954.git.shuah.kh@samsung.com>
In-Reply-To: <cover.1398797954.git.shuah.kh@samsung.com>

Add a new field tuner_tkn to struct dvb_frontend. Drivers can
create tuner token using devm_token_create() and initialize
the tuner_tkn when frontend is registered with the dvb-core.
This change enables drivers to provide a token devres for tuner
access control.

Change dvb_frontend to lock tuner token for exclusive access to
tuner function for digital TV function use. When Tuner token is
present, dvb_frontend_start() calls devm_token_lock() to lock
the token. If token is busy, -EBUSY is returned to the user-space.
Tuner token is unlocked if kdvb adapter fe kthread fails to start.
This token is held in use as long as the kdvb adapter fe kthread
is running. Tuner token is unlocked in dvb_frontend_thread() when
kdvb adapter fe thread exits.

Signed-off-by: Shuah Khan <shuah.kh@samsung.com>
---
 drivers/media/dvb-core/dvb_frontend.c |   15 +++++++++++++++
 drivers/media/dvb-core/dvb_frontend.h |    1 +
 2 files changed, 16 insertions(+)

diff --git a/drivers/media/dvb-core/dvb_frontend.c b/drivers/media/dvb-core/dvb_frontend.c
index 6ce435a..2b35e3f 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/token_devres.h>
 
 #include "dvb_frontend.h"
 #include "dvbdev.h"
@@ -747,6 +748,9 @@ restart:
 	if (semheld)
 		up(&fepriv->sem);
 	dvb_frontend_wakeup(fe);
+
+	if (fe->tuner_tkn)
+		devm_token_unlock(fe->dvb->device, fe->tuner_tkn);
 	return 0;
 }
 
@@ -840,6 +844,15 @@ static int dvb_frontend_start(struct dvb_frontend *fe)
 	fepriv->state = FESTATE_IDLE;
 	fepriv->exit = DVB_FE_NO_EXIT;
 	fepriv->thread = NULL;
+
+	if (fe->tuner_tkn) {
+		ret = devm_token_lock(fe->dvb->device, fe->tuner_tkn);
+		if (ret) {
+			dev_info(fe->dvb->device, "Tuner is busy %d\n", ret);
+			return ret;
+		}
+	}
+
 	mb();
 
 	fe_thread = kthread_run(dvb_frontend_thread, fe,
@@ -850,6 +863,8 @@ static int dvb_frontend_start(struct dvb_frontend *fe)
 				"dvb_frontend_start: failed to start kthread (%d)\n",
 				ret);
 		up(&fepriv->sem);
+		if (fe->tuner_tkn)
+			devm_token_unlock(fe->dvb->device, fe->tuner_tkn);
 		return ret;
 	}
 	fepriv->thread = fe_thread;
diff --git a/drivers/media/dvb-core/dvb_frontend.h b/drivers/media/dvb-core/dvb_frontend.h
index 371b6ca..c9ba5fd 100644
--- a/drivers/media/dvb-core/dvb_frontend.h
+++ b/drivers/media/dvb-core/dvb_frontend.h
@@ -418,6 +418,7 @@ struct dvb_frontend {
 #define DVB_FRONTEND_COMPONENT_DEMOD 1
 	int (*callback)(void *adapter_priv, int component, int cmd, int arg);
 	int id;
+	char *tuner_tkn;
 };
 
 extern int dvb_register_frontend(struct dvb_adapter *dvb,
-- 
1.7.10.4


  parent reply	other threads:[~2014-04-29 19:50 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-29 19:49 [PATCH 0/4] Add managed token devres interfaces and change media drivers to use it Shuah Khan
2014-04-29 19:49 ` [PATCH 1/4] drivers/base: add managed token devres interfaces Shuah Khan
2014-05-01 14:53   ` Tejun Heo
2014-05-05 19:16     ` Shuah Khan
2014-05-05 19:26       ` Tejun Heo
2014-05-05 19:30         ` Devin Heitmueller
2014-05-05 19:36           ` Tejun Heo
2014-05-05 19:41             ` Devin Heitmueller
2014-05-05 19:42             ` Shuah Khan
2014-04-29 19:49 ` Shuah Khan [this message]
2014-04-29 19:49 ` [PATCH 3/4] media/em28xx: changes to create token for tuner access Shuah Khan
2014-04-29 19:49 ` [PATCH 4/4] media: em28xx dvb changes to initialze tuner token Shuah Khan
2014-06-24 23:57 [PATCH 0/4] media: tuner large grain locking Shuah Khan
2014-06-24 23:57 ` [PATCH 2/4] media: dvb-fe changes to use tuner token Shuah Khan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9a211011e470e91ce4367529ba74cddb7fdaee60.1398797955.git.shuah.kh@samsung.com \
    --to=shuah.kh@samsung.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=m.chehab@samsung.com \
    --cc=olebowle@gmx.com \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.