V4L/DVB: IR: Allow not to compile keymaps in
authorMaxim Levitsky <maximlevitsky@gmail.com>
Sat, 31 Jul 2010 14:59:21 +0000 (11:59 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Mon, 9 Aug 2010 02:43:00 +0000 (23:43 -0300)
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 <maximlevitsky@gmail.com>
Acked-by: Jarod Wilson <jarod@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/IR/ir-core-priv.h
drivers/media/IR/ir-sysfs.c
drivers/media/IR/keymaps/Makefile
drivers/media/IR/keymaps/rc-empty.c [deleted file]
drivers/media/IR/rc-map.c
include/media/ir-core.h

index 502d477b391cdd80cfe8606a866aa53e1bc46a64..be6817261c8feb2cca04188c0255c6d246ab50ac 100644 (file)
@@ -126,7 +126,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
  *
index 6273047e915b4b800527bb50f63463adcf83bbc4..96dafc425c8e61495cd662bf7f4c11182d674e79 100644 (file)
@@ -325,6 +325,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;
 }
@@ -332,6 +333,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);
index c9fcc41944e973b6653acac845ba5efe0c6c67f5..950e5d953c6f10e4835d7f76bd7bf2c98edebbe4 100644 (file)
@@ -19,7 +19,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 (file)
index 3b338d8..0000000
+++ /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 <mchehab@redhat.com>
- *
- * 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 <media/rc-map.h>
-
-/* 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 <mchehab@redhat.com>");
index 46a8f1524b5ba7e64e64aeb4bd72d978beb64ac7..689143f2fff07a0a6828547d4f01fc505b0e4fbf 100644 (file)
@@ -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);
+}
index 513e60dd101018f265622521fde93606aa8dbd12..197d05aa83dc47f9b5270830a2246ccb5b0d4261 100644 (file)
@@ -110,8 +110,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)