From patchwork Fri Jul 19 08:39:27 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas KANDAGATLA X-Patchwork-Id: 2830401 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 B1DB49F4D4 for ; Fri, 19 Jul 2013 08:48:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B0AE1204B0 for ; Fri, 19 Jul 2013 08:48:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 881C420497 for ; Fri, 19 Jul 2013 08:48:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760031Ab3GSIsl (ORCPT ); Fri, 19 Jul 2013 04:48:41 -0400 Received: from eu1sys200aog107.obsmtp.com ([207.126.144.123]:33614 "EHLO eu1sys200aog107.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759869Ab3GSIsi (ORCPT ); Fri, 19 Jul 2013 04:48:38 -0400 Received: from beta.dmz-eu.st.com ([164.129.1.35]) (using TLSv1) by eu1sys200aob107.postini.com ([207.126.147.11]) with SMTP ID DSNKUej9YVjzvOPvFueADuyShZx25y26fXE+@postini.com; Fri, 19 Jul 2013 08:48:38 UTC Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 357761A5; Fri, 19 Jul 2013 08:48:29 +0000 (GMT) Received: from mail7.sgp.st.com (unknown [164.129.223.81]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 234064655; Fri, 19 Jul 2013 08:48:02 +0000 (GMT) Received: from localhost (king.bri.st.com [10.65.51.59]) by mail7.sgp.st.com (MOS 4.3.3-GA) with ESMTP id BIB19081 (AUTH srinivak); Fri, 19 Jul 2013 10:48:31 +0200 From: Srinivas KANDAGATLA To: linux-media@vger.kernel.org Cc: alipowski@interia.pl, Mauro Carvalho Chehab , linux-kernel@vger.kernel.org, srinivas.kandagatla@gmail.com, srinivas.kandagatla@st.com, sean@mess.org Subject: [PATCH v1 1/2] media: rc: Add user count to rc dev. Date: Fri, 19 Jul 2013 09:39:27 +0100 Message-Id: <1374223167-4980-1-git-send-email-srinivas.kandagatla@st.com> X-Mailer: git-send-email 1.7.6.5 In-Reply-To: <1374223132-4924-1-git-send-email-srinivas.kandagatla@st.com> References: <1374223132-4924-1-git-send-email-srinivas.kandagatla@st.com> 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.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, 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 From: Srinivas Kandagatla This patch adds user count to rc_dev structure, the reason to add this new member is to allow other code like lirc to open rc device directly. In the existing code, rc device is only opened by input subsystem which works ok if we have any input drivers to match. But in case like lirc where there will be no input driver, rc device will be never opened. Having this user count variable will be useful to allow rc device to be opened from code other than rc-main. Signed-off-by: Srinivas Kandagatla --- drivers/media/rc/rc-main.c | 11 +++++++++-- include/media/rc-core.h | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c index 1cf382a..e800b96 100644 --- a/drivers/media/rc/rc-main.c +++ b/drivers/media/rc/rc-main.c @@ -702,15 +702,22 @@ EXPORT_SYMBOL_GPL(rc_keydown_notimeout); static int ir_open(struct input_dev *idev) { struct rc_dev *rdev = input_get_drvdata(idev); + int rval = 0; - return rdev->open(rdev); + if (!rdev->users++) + rval = rdev->open(rdev); + + if (rval) + rdev->users--; + + return rval; } static void ir_close(struct input_dev *idev) { struct rc_dev *rdev = input_get_drvdata(idev); - if (rdev) + if (rdev && !--rdev->users) rdev->close(rdev); } diff --git a/include/media/rc-core.h b/include/media/rc-core.h index 06a75de..b42016a 100644 --- a/include/media/rc-core.h +++ b/include/media/rc-core.h @@ -101,6 +101,7 @@ struct rc_dev { bool idle; u64 allowed_protos; u64 enabled_protocols; + u32 users; u32 scanmask; void *priv; spinlock_t keylock;