From patchwork Sat Nov 21 15:30:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 7674541 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 2FDEFBF90C for ; Sat, 21 Nov 2015 15:32:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6071720653 for ; Sat, 21 Nov 2015 15:32:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8480520654 for ; Sat, 21 Nov 2015 15:32:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760902AbbKUPci (ORCPT ); Sat, 21 Nov 2015 10:32:38 -0500 Received: from mail-wm0-f42.google.com ([74.125.82.42]:34708 "EHLO mail-wm0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760545AbbKUPch (ORCPT ); Sat, 21 Nov 2015 10:32:37 -0500 Received: by wmvv187 with SMTP id v187so108306591wmv.1 for ; Sat, 21 Nov 2015 07:32:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=to:cc:from:subject:message-id:date:user-agent:mime-version :content-type:content-transfer-encoding; bh=PUufRaO218yHnk+YLrjWpIPO603fbRp9ArR69f7SBJ4=; b=yFGyRU9/rrfm2AirF8XrVs/+zaAkKLIXXUTT77wcNQ3RodcAMd+F4/XnyN/vFuU/8z mwyZzsxK3iocaB+D4ww3wnVwA5j18JRwpQqJ8PaW//RcXyVl9A7IVaP0hHdRYaXLFNga j6aMmNkPDpTMLYKx1a+LzkGQR3NIm5oyf37DRXiGP1J0RxTJ3TB611jz/7kDEZeNORYM BVwAmmDnZ3gvGU40E677AW60dqpUAcxn5OdY25PIBpSD7GHwtKmiS8vrNr0CinVY/tIg Omzq8BPXGQbKw9Bi9L6BgOVZq8FAzWr72BxWFrx3s/epTYWTv+49VQYNs8upl2/z5cCv O+wA== X-Received: by 10.28.68.139 with SMTP id r133mr9366044wma.66.1448119956191; Sat, 21 Nov 2015 07:32:36 -0800 (PST) Received: from ?IPv6:2003:62:5f55:ba00:681b:1517:83c2:9e4a? (p200300625F55BA00681B151783C29E4A.dip0.t-ipconnect.de. [2003:62:5f55:ba00:681b:1517:83c2:9e4a]) by smtp.googlemail.com with ESMTPSA id s189sm4566928wmf.16.2015.11.21.07.32.35 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 21 Nov 2015 07:32:35 -0800 (PST) To: Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org From: Heiner Kallweit Subject: [PATCH 2/2] media: rc: improve lirc module detection Message-ID: <56508E30.8010205@gmail.com> Date: Sat, 21 Nov 2015 16:30:56 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 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_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, 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 Improve detection whether lirc codec is loaded and avoid dependency on config symbols and having to check for a specific module. This also fixes the bug that the current check checks for module lirc_dev instead of ir_lirc_codec (which depends on lirc_dev). If the ir_lirc_codec module is unloaded the check would still return OK. Signed-off-by: Heiner Kallweit --- drivers/media/rc/ir-lirc-codec.c | 4 ++++ drivers/media/rc/rc-main.c | 19 +++++-------------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/drivers/media/rc/ir-lirc-codec.c b/drivers/media/rc/ir-lirc-codec.c index a32659f..7fc5b3f 100644 --- a/drivers/media/rc/ir-lirc-codec.c +++ b/drivers/media/rc/ir-lirc-codec.c @@ -22,6 +22,8 @@ #define LIRCBUF_SIZE 256 +extern atomic_t ir_raw_lirc_available; + /** * ir_lirc_decode() - Send raw IR data to lirc_dev to be relayed to the * lircd userspace daemon for decoding. @@ -398,6 +400,7 @@ static int ir_lirc_register(struct rc_dev *dev) dev->raw->lirc.drv = drv; dev->raw->lirc.dev = dev; + atomic_set(&ir_raw_lirc_available, 1); return 0; lirc_register_failed: @@ -413,6 +416,7 @@ static int ir_lirc_unregister(struct rc_dev *dev) { struct lirc_codec *lirc = &dev->raw->lirc; + atomic_set(&ir_raw_lirc_available, 0); lirc_unregister_driver(lirc->drv->minor); lirc_buffer_free(lirc->drv->rbuf); kfree(lirc->drv); diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c index 1042fa3..0bd11b4 100644 --- a/drivers/media/rc/rc-main.c +++ b/drivers/media/rc/rc-main.c @@ -829,21 +829,12 @@ struct rc_filter_attribute { .mask = (_mask), \ } -static bool lirc_is_present(void) +atomic_t ir_raw_lirc_available = ATOMIC_INIT(0); +EXPORT_SYMBOL(ir_raw_lirc_available); + +static inline bool lirc_is_present(void) { -#if defined(CONFIG_LIRC_MODULE) - struct module *lirc; - - mutex_lock(&module_mutex); - lirc = find_module("lirc_dev"); - mutex_unlock(&module_mutex); - - return lirc ? true : false; -#elif defined(CONFIG_LIRC) - return true; -#else - return false; -#endif + return atomic_read(&ir_raw_lirc_available) != 0; } /**