From patchwork Mon Sep 22 15:00:48 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shuah Khan X-Patchwork-Id: 4948351 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 36590BEEA5 for ; Mon, 22 Sep 2014 15:08:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E42832010E for ; Mon, 22 Sep 2014 15:08:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4A7D12010C for ; Mon, 22 Sep 2014 15:08:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754193AbaIVPHS (ORCPT ); Mon, 22 Sep 2014 11:07:18 -0400 Received: from resqmta-po-01v.sys.comcast.net ([96.114.154.160]:55667 "EHLO resqmta-po-01v.sys.comcast.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754145AbaIVPHO (ORCPT ); Mon, 22 Sep 2014 11:07:14 -0400 Received: from resomta-po-20v.sys.comcast.net ([96.114.154.244]) by resqmta-po-01v.sys.comcast.net with comcast id uF191o0055Geu2801F19Yp; Mon, 22 Sep 2014 15:01:09 +0000 Received: from mail.gonehiking.org ([50.134.149.16]) by resomta-po-20v.sys.comcast.net with comcast id uF181o0010MU7Qa01F18lA; Mon, 22 Sep 2014 15:01:09 +0000 Received: from lorien.internal (lorien-wl.internal [192.168.1.40]) by mail.gonehiking.org (Postfix) with ESMTP id D60FD40270; Mon, 22 Sep 2014 09:01:07 -0600 (MDT) From: Shuah Khan To: m.chehab@samsung.com, akpm@linux-foundation.org, gregkh@linuxfoundation.org, crope@iki.fi, olebowle@gmx.com, dheitmueller@kernellabs.co, hverkuil@xs4all.nl, ramakrmu@cisco.com, sakari.ailus@linux.intel.com, laurent.pinchart@ideasonboard.com Cc: Shuah Khan , linux-kernel@vger.kernel.org, linux-media@vger.kernel.org Subject: [PATCH 4/5] media: dvb-core changes to use media tuner token api Date: Mon, 22 Sep 2014 09:00:48 -0600 Message-Id: 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=1411398069; bh=Po/tv3GU1C48vg8bHfjVfOqFk0+qlvmWiPEJUdVd8zY=; h=Received:Received:Received:From:To:Subject:Date:Message-Id; b=LEnASg9rgzA05HEqC2OG1Le/VvshzYoxMr/EttTnQDNB4Aq+1fmX9zXG6zrwKJo1b KdvaXm/Dy52/MN8rnU3GD75RWmCdx0nyykl4weMbeSQWrE1gRgTNAet+MTJq3+diID BZTRvuv68zWc4/WpQt3Vb1H2GP/IoYzIAWLr8Pf8cAVouH1rnk4ozvwJgyoM71Ecsm ROlDHlWQluuaj7RUZ+SjwW1Hn+LXGzqp+HQS5oONkiaWWRbnBQJbRNHGEVHlbx4MV3 F53BUPSiYqXgPkBi42HYfHt+cK+V7NGsuVgZ2Kzooc9RWrA3paeh3UdlDB9lz0WbUp 7szHSSA9om5lg== 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.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham 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 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 --- 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 #include #include +#include #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;