From patchwork Wed Jul 28 23:40:49 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Levitsky X-Patchwork-Id: 3937 Return-path: Envelope-to: mchehab@infradead.org Delivery-date: Wed, 28 Jul 2010 23:41:26 +0000 Received: from bombadil.infradead.org [18.85.46.34] by pedra with IMAP (fetchmail-6.3.17) for (single-drop); Wed, 28 Jul 2010 20:41:48 -0300 (BRT) Received: from vger.kernel.org ([209.132.180.67]) by bombadil.infradead.org with esmtp (Exim 4.72 #1 (Red Hat Linux)) id 1OeGFa-0007uO-GN; Wed, 28 Jul 2010 23:41:26 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755891Ab0G1XlW (ORCPT + 1 other); Wed, 28 Jul 2010 19:41:22 -0400 Received: from mail-bw0-f46.google.com ([209.85.214.46]:56704 "EHLO mail-bw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752387Ab0G1XlK (ORCPT ); Wed, 28 Jul 2010 19:41:10 -0400 Received: by mail-bw0-f46.google.com with SMTP id 1so18022bwz.19 for ; Wed, 28 Jul 2010 16:41:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer:in-reply-to:references; bh=Hz0s68ZTGwmciccGVcrq6XVcBQdXH7f4xput/ydhKdA=; b=bHH8WSONx9hI/Lln9dcY6Cg5aEXC6dGk0fLlpN/bOIqtHccA5c3Ck7V9PdB4oejX4H hA09DtCYcLSe0C2ypqUi8G29Oo3v8+0DV+d7117Zn6N4jqA6n5OD7NgO21V2rKrDASJf 8X6G9vVwsVUhwA+QGKIwJY9XCBAVINNjrYrr0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=fVrWHOH1g6Bg8Uyymucj1ZfaQ/EWVGBuT7MLR6aExSeQfXCkm5QAnv3363tRUynU/x sbjh4FMSTU7Sr1hSM+Qe8nqyo14fQJbaD1PqWSzvzXoUgavDxWPIg1patolB3gbxAQ3N nQ3ixkbAp+zAZ60lkP3JY6mQfGCzuxbpIAv24= Received: by 10.204.49.196 with SMTP id w4mr8301987bkf.73.1280360469668; Wed, 28 Jul 2010 16:41:09 -0700 (PDT) Received: from localhost.localdomain (IGLD-84-229-112-176.inter.net.il [84.229.112.176]) by mx.google.com with ESMTPS id bq20sm104935bkb.16.2010.07.28.16.41.08 (version=SSLv3 cipher=RC4-MD5); Wed, 28 Jul 2010 16:41:09 -0700 (PDT) From: Maxim Levitsky To: lirc-list@lists.sourceforge.net Cc: Jarod Wilson , linux-input@vger.kernel.org, linux-media@vger.kernel.org, Mauro Carvalho Chehab , Christoph Bartelmus , Maxim Levitsky Subject: [PATCH 6/9] IR: Allow not to compile keymaps in. Date: Thu, 29 Jul 2010 02:40:49 +0300 Message-Id: <1280360452-8852-7-git-send-email-maximlevitsky@gmail.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1280360452-8852-1-git-send-email-maximlevitsky@gmail.com> References: <1280360452-8852-1-git-send-email-maximlevitsky@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Currently, ir device registration fails if keymap requested by driver is not found. Fix that by always compiling in the empty keymap, and using it as a failback. Signed-off-by: Maxim Levitsky --- drivers/media/IR/ir-core-priv.h | 3 +- drivers/media/IR/ir-sysfs.c | 2 + drivers/media/IR/keymaps/Makefile | 1 - drivers/media/IR/keymaps/rc-empty.c | 44 ----------------------------------- drivers/media/IR/rc-map.c | 23 ++++++++++++++++++ include/media/ir-core.h | 8 ++++- 6 files changed, 33 insertions(+), 48 deletions(-) delete mode 100644 drivers/media/IR/keymaps/rc-empty.c diff --git a/drivers/media/IR/ir-core-priv.h b/drivers/media/IR/ir-core-priv.h index 9c594af..78106a0 100644 --- a/drivers/media/IR/ir-core-priv.h +++ b/drivers/media/IR/ir-core-priv.h @@ -127,7 +127,8 @@ 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); - +int ir_rcmap_init(void); +void ir_rcmap_cleanup(void); /* * Decoder initialization code * diff --git a/drivers/media/IR/ir-sysfs.c b/drivers/media/IR/ir-sysfs.c index a841e51..936dff8 100644 --- a/drivers/media/IR/ir-sysfs.c +++ b/drivers/media/IR/ir-sysfs.c @@ -341,6 +341,7 @@ static int __init ir_core_init(void) /* Initialize/load the decoders/keymap code that will be used */ ir_raw_init(); + ir_rcmap_init(); return 0; } @@ -348,6 +349,7 @@ static int __init ir_core_init(void) static void __exit ir_core_exit(void) { class_unregister(&ir_input_class); + ir_rcmap_cleanup(); } module_init(ir_core_init); diff --git a/drivers/media/IR/keymaps/Makefile b/drivers/media/IR/keymaps/Makefile index 86d3d1f..24992cd 100644 --- a/drivers/media/IR/keymaps/Makefile +++ b/drivers/media/IR/keymaps/Makefile @@ -17,7 +17,6 @@ obj-$(CONFIG_RC_MAP) += rc-adstech-dvb-t-pci.o \ rc-dm1105-nec.o \ rc-dntv-live-dvb-t.o \ rc-dntv-live-dvbt-pro.o \ - rc-empty.o \ rc-em-terratec.o \ rc-encore-enltv2.o \ rc-encore-enltv.o \ diff --git a/drivers/media/IR/keymaps/rc-empty.c b/drivers/media/IR/keymaps/rc-empty.c deleted file mode 100644 index 3b338d8..0000000 --- a/drivers/media/IR/keymaps/rc-empty.c +++ /dev/null @@ -1,44 +0,0 @@ -/* empty.h - Keytable for empty Remote Controller - * - * keymap imported from ir-keymaps.c - * - * Copyright (c) 2010 by Mauro Carvalho Chehab - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ - -#include - -/* empty keytable, can be used as placeholder for not-yet created keytables */ - -static struct ir_scancode empty[] = { - { 0x2a, KEY_COFFEE }, -}; - -static struct rc_keymap empty_map = { - .map = { - .scan = empty, - .size = ARRAY_SIZE(empty), - .ir_type = IR_TYPE_UNKNOWN, /* Legacy IR type */ - .name = RC_MAP_EMPTY, - } -}; - -static int __init init_rc_map_empty(void) -{ - return ir_register_map(&empty_map); -} - -static void __exit exit_rc_map_empty(void) -{ - ir_unregister_map(&empty_map); -} - -module_init(init_rc_map_empty) -module_exit(exit_rc_map_empty) - -MODULE_LICENSE("GPL"); -MODULE_AUTHOR("Mauro Carvalho Chehab "); diff --git a/drivers/media/IR/rc-map.c b/drivers/media/IR/rc-map.c index 46a8f15..689143f 100644 --- a/drivers/media/IR/rc-map.c +++ b/drivers/media/IR/rc-map.c @@ -82,3 +82,26 @@ void ir_unregister_map(struct rc_keymap *map) } EXPORT_SYMBOL_GPL(ir_unregister_map); + +static struct ir_scancode empty[] = { + { 0x2a, KEY_COFFEE }, +}; + +static struct rc_keymap empty_map = { + .map = { + .scan = empty, + .size = ARRAY_SIZE(empty), + .ir_type = IR_TYPE_UNKNOWN, /* Legacy IR type */ + .name = RC_MAP_EMPTY, + } +}; + +int ir_rcmap_init(void) +{ + return ir_register_map(&empty_map); +} + +void ir_rcmap_cleanup(void) +{ + ir_unregister_map(&empty_map); +} diff --git a/include/media/ir-core.h b/include/media/ir-core.h index 7299e7a..cf17be3 100644 --- a/include/media/ir-core.h +++ b/include/media/ir-core.h @@ -134,8 +134,12 @@ static inline int ir_input_register(struct input_dev *dev, return -EINVAL; ir_codes = get_rc_map(map_name); - if (!ir_codes) - return -EINVAL; + if (!ir_codes) { + ir_codes = get_rc_map(RC_MAP_EMPTY); + + if (!ir_codes) + return -EINVAL; + } rc = __ir_input_register(dev, ir_codes, props, driver_name); if (rc < 0)