From patchwork Mon Nov 16 19:53:20 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 7630511 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 2E015BF90C for ; Mon, 16 Nov 2015 19:54:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2A6B2205B6 for ; Mon, 16 Nov 2015 19:54:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0E1972058C for ; Mon, 16 Nov 2015 19:54:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752040AbbKPTyY (ORCPT ); Mon, 16 Nov 2015 14:54:24 -0500 Received: from mail-wm0-f50.google.com ([74.125.82.50]:33621 "EHLO mail-wm0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752143AbbKPTyK (ORCPT ); Mon, 16 Nov 2015 14:54:10 -0500 Received: by wmec201 with SMTP id c201so194737448wme.0 for ; Mon, 16 Nov 2015 11:54:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:subject:to:cc:message-id:date:user-agent:mime-version :content-type:content-transfer-encoding; bh=RUjaqlpYq/Eo3afNREj04iR6qbghevWsw+v2Qs7hJ88=; b=AqWIH1Fa7CGtWNmcqGQpCExrv/JiiAbMubsXA1F9Zv3+kINpiU2jBg9nFw3VZB5wci DClAbYIxs7CXG9myxG5DYasVidkYyfEdzJuRWZ1JpK2TIbo0otvvcsApHWaU9R9OUDEG uDv9rqWkw5P1nylRHWSgLQcahNIB9cVjUMX6Qe/aivWQ6Sgr9wLaN14AfeKSHFqKnc+d 0EdSvATMW5hxDIh1oVpnpRbRETx9Q7kFdfHK4zhE3sSJzqb8fPmhC2dB3/Lx/T2H2q7I g0c4ieCzIQaFG6j13pm7FHl5EitqsFSWzI577DsbZ8nPz3DJC38elpkAu4BAqvAt3sx8 0Ogg== X-Received: by 10.28.224.7 with SMTP id x7mr19607748wmg.17.1447703649499; Mon, 16 Nov 2015 11:54:09 -0800 (PST) Received: from ?IPv6:2003:62:5f55:ba00:2914:ea82:f3d7:fe39? (p200300625F55BA002914EA82F3D7FE39.dip0.t-ipconnect.de. [2003:62:5f55:ba00:2914:ea82:f3d7:fe39]) by smtp.googlemail.com with ESMTPSA id l1sm20163219wmg.21.2015.11.16.11.54.08 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Nov 2015 11:54:08 -0800 (PST) From: Heiner Kallweit Subject: [PATCH 6/8] media: rc: treat lirc like any other protocol To: Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org, =?UTF-8?Q?David_H=c3=a4rdeman?= Message-ID: <564A3430.5020103@gmail.com> Date: Mon, 16 Nov 2015 20:53:20 +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.6 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 Introduce a protocol bit for lirc and treat it like any other protocol. This allows to get rid of all the lirc-specific code. Signed-off-by: Heiner Kallweit --- drivers/media/rc/ir-lirc-codec.c | 2 +- drivers/media/rc/rc-core-priv.h | 16 ++-------------- drivers/media/rc/rc-ir-raw.c | 13 +------------ drivers/media/rc/rc-main.c | 37 ++++--------------------------------- 4 files changed, 8 insertions(+), 60 deletions(-) diff --git a/drivers/media/rc/ir-lirc-codec.c b/drivers/media/rc/ir-lirc-codec.c index a32659f..40c66c8 100644 --- a/drivers/media/rc/ir-lirc-codec.c +++ b/drivers/media/rc/ir-lirc-codec.c @@ -421,7 +421,7 @@ static int ir_lirc_unregister(struct rc_dev *dev) } static struct ir_raw_handler lirc_handler = { - .protocols = 0, + .protocols = RC_BIT_LIRC, .decode = ir_lirc_decode, .raw_register = ir_lirc_register, .raw_unregister = ir_lirc_unregister, diff --git a/drivers/media/rc/rc-core-priv.h b/drivers/media/rc/rc-core-priv.h index 071651a..74f2f15 100644 --- a/drivers/media/rc/rc-core-priv.h +++ b/drivers/media/rc/rc-core-priv.h @@ -20,6 +20,8 @@ #include #include +#define RC_BIT_LIRC (1ULL << 63) + struct ir_raw_handler { struct list_head list; @@ -160,18 +162,4 @@ int ir_raw_handler_register(struct ir_raw_handler *ir_raw_handler); void ir_raw_handler_unregister(struct ir_raw_handler *ir_raw_handler); void ir_raw_init(void); -/* - * Decoder initialization code - * - * Those load logic are called during ir-core init, and automatically - * loads the compiled decoders for their usage with IR raw events - */ - -/* from ir-lirc-codec.c */ -#ifdef CONFIG_IR_LIRC_CODEC_MODULE -#define load_lirc_codec() request_module_nowait("ir-lirc-codec") -#else -static inline void load_lirc_codec(void) { } -#endif - #endif /* _RC_CORE_PRIV */ diff --git a/drivers/media/rc/rc-ir-raw.c b/drivers/media/rc/rc-ir-raw.c index c6433e8..dbd8db5 100644 --- a/drivers/media/rc/rc-ir-raw.c +++ b/drivers/media/rc/rc-ir-raw.c @@ -59,8 +59,7 @@ static int ir_raw_event_thread(void *data) mutex_lock(&ir_raw_handler_lock); list_for_each_entry(handler, &ir_raw_handler_list, list) - if (raw->dev->enabled_protocols & handler->protocols || - !handler->protocols) + if (raw->dev->enabled_protocols & handler->protocols) handler->decode(raw->dev, ev); raw->prev_ev = ev; mutex_unlock(&ir_raw_handler_lock); @@ -360,13 +359,3 @@ void ir_raw_handler_unregister(struct ir_raw_handler *ir_raw_handler) mutex_unlock(&ir_raw_handler_lock); } EXPORT_SYMBOL(ir_raw_handler_unregister); - -void ir_raw_init(void) -{ - /* Load the decoder modules */ - load_lirc_codec(); - - /* If needed, we may later add some init code. In this case, - it is needed to change the CONFIG_MODULE test at rc-core.h - */ -} diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c index f2d5c50..d1611f1 100644 --- a/drivers/media/rc/rc-main.c +++ b/drivers/media/rc/rc-main.c @@ -802,6 +802,7 @@ static const struct { { RC_BIT_SHARP, "sharp", "ir-sharp-decoder" }, { RC_BIT_MCE_KBD, "mce_kbd", "ir-mce_kbd-decoder" }, { RC_BIT_XMP, "xmp", "ir-xmp-decoder" }, + { RC_BIT_LIRC, "lirc", "ir-lirc-codec" }, }; /** @@ -829,23 +830,6 @@ struct rc_filter_attribute { .mask = (_mask), \ } -static 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 -} - /** * show_protocols() - shows the current/wakeup IR protocol(s) * @device: the device descriptor @@ -900,9 +884,6 @@ static ssize_t show_protocols(struct device *device, allowed &= ~proto_names[i].type; } - if (dev->driver_type == RC_DRIVER_IR_RAW && lirc_is_present()) - tmp += sprintf(tmp, "[lirc] "); - if (tmp != buf) tmp--; *tmp = '\n'; @@ -954,12 +935,8 @@ static int parse_protocol_change(u64 *protocols, const char *buf) } if (i == ARRAY_SIZE(proto_names)) { - if (!strcasecmp(tmp, "lirc")) - mask = 0; - else { - IR_dprintk(1, "Unknown protocol: '%s'\n", tmp); - return -EINVAL; - } + IR_dprintk(1, "Unknown protocol: '%s'\n", tmp); + return -EINVAL; } count++; @@ -1376,7 +1353,6 @@ EXPORT_SYMBOL_GPL(rc_free_device); int rc_register_device(struct rc_dev *dev) { - static bool raw_init = false; /* raw decoders loaded? */ struct rc_map *rc_map; const char *path; int attr = 0; @@ -1471,12 +1447,7 @@ int rc_register_device(struct rc_dev *dev) kfree(path); if (dev->driver_type == RC_DRIVER_IR_RAW) { - /* Load raw decoders, if they aren't already */ - if (!raw_init) { - IR_dprintk(1, "Loading raw decoders\n"); - ir_raw_init(); - raw_init = true; - } + dev->allowed_protocols |= RC_BIT_LIRC; /* calls ir_register_device so unlock mutex here*/ mutex_unlock(&dev->lock); rc = ir_raw_event_register(dev);