From patchwork Tue Apr 29 19:49:24 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shuah Khan X-Patchwork-Id: 4088861 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 3DD519F169 for ; Tue, 29 Apr 2014 19:51:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6E3B320218 for ; Tue, 29 Apr 2014 19:51:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 81613200D7 for ; Tue, 29 Apr 2014 19:51:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933315AbaD2Tu6 (ORCPT ); Tue, 29 Apr 2014 15:50:58 -0400 Received: from qmta08.emeryville.ca.mail.comcast.net ([76.96.30.80]:46737 "EHLO qmta08.emeryville.ca.mail.comcast.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965173AbaD2TuS (ORCPT ); Tue, 29 Apr 2014 15:50:18 -0400 Received: from omta03.emeryville.ca.mail.comcast.net ([76.96.30.27]) by qmta08.emeryville.ca.mail.comcast.net with comcast id vrAl1n0020b6N64A8vqJ09; Tue, 29 Apr 2014 19:50:18 +0000 Received: from mail.gonehiking.org ([50.134.149.16]) by omta03.emeryville.ca.mail.comcast.net with comcast id vvqF1n0050MU7Qa8PvqFpz; Tue, 29 Apr 2014 19:50:16 +0000 Received: from lorien.sisa.samsung.com (lorien-wl.internal [192.168.1.40]) by mail.gonehiking.org (Postfix) with ESMTP id E9B823FE13; Tue, 29 Apr 2014 13:50:14 -0600 (MDT) From: Shuah Khan To: gregkh@linuxfoundation.org, m.chehab@samsung.com, tj@kernel.org, olebowle@gmx.com Cc: Shuah Khan , 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 Message-Id: <9a211011e470e91ce4367529ba74cddb7fdaee60.1398797955.git.shuah.kh@samsung.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: References: In-Reply-To: References: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; s=q20140121; t=1398801018; bh=G72lNMppA3XyCw0Z68EQIVS8y925bNEZOsAqvX6B6iA=; h=Received:Received:Received:From:To:Subject:Date:Message-Id; b=RD6K00Xn0sXMOKT597Al1RWNzI2oSe/JKjCG0fKO4ZCm1+eXwPUIFdu5+c+STniRM pTfFv15Ci40RmWGB43X3LQgfEXGe//vOlJV5keQNope9CvVugeI+5LgDptTr/US70G cOnAZOXjaY4Mn6qk2DVDz6Z42KMIA3uxGMF2Jg9/SQ0DTL5VQVgM6XtKQR1YvMcmPX 0ndTo5Pbvd1pFDSgqK1BQNmYr8+oLPzgp2G7Pr+9pPJD2ozrlxl69VQRIYiila2pUT yF6F/5SsDEGeXAoXcCqNsfxJrRLA9nUxtdFyo/yp0EkqSMeroTtjuY0/g4VdTzm+mp EpE5c0ALWSJZw== Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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 #include #include +#include #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,