Change dvb_frontend_open() to hold tuner and audio tokens when frontend is opened in R/W mode. Tuner and audio tokens are released when frontend is released in frontend exit state. This change allows main dvb application process to hold the tokens for all threads it creates and be able to handle channel change requests without releasing the tokens thereby risking loosing tokens to another application.
Note that media_get_tuner_tkn() will do a get on audio token and return with both tuner and audio tokens locked. When tuner token released using media_put_tuner_tkn() , audio token is released. Initialize dev_parent field struct video_device to enable media tuner token lookup from v4l2-core.
Signed-off-by: Shuah Khan shuahkh@osg.samsung.com --- drivers/media/dvb-core/dvb_frontend.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/drivers/media/dvb-core/dvb_frontend.c b/drivers/media/dvb-core/dvb_frontend.c index b8579ee..fcf5f08 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" @@ -2499,9 +2500,15 @@ static int dvb_frontend_open(struct inode *inode, struct file *file) fepriv->tone = -1; fepriv->voltage = -1;
+ /* get tuner and audio tokens - device is opened in R/W */ + ret = media_get_tuner_tkn(fe->dvb->device); + if (ret == -EBUSY) { + dev_info(fe->dvb->device, "dvb: Tuner is busy\n"); + goto err2; + } ret = dvb_frontend_start (fe); if (ret) - goto err2; + goto start_err;
/* empty event queue */ fepriv->events.eventr = fepriv->events.eventw = 0; @@ -2511,6 +2518,8 @@ static int dvb_frontend_open(struct inode *inode, struct file *file) mutex_unlock (&adapter->mfe_lock); return ret;
+start_err: + media_put_tuner_tkn(fe->dvb->device); err2: dvb_generic_release(inode, file); err1: @@ -2542,6 +2551,9 @@ static int dvb_frontend_release(struct inode *inode, struct file *file) wake_up(&fepriv->wait_queue); if (fe->exit != DVB_FE_NO_EXIT) wake_up(&dvbdev->wait_queue); + /* release token if fe is in exit state */ + else + media_put_tuner_tkn(fe->dvb->device); if (fe->ops.ts_bus_ctrl) fe->ops.ts_bus_ctrl(fe, 0); }