Skip to content

Commit b378f43

Browse files
maximlevitskyMauro Carvalho Chehab
authored andcommitted
V4L/DVB: IR: Allow not to compile keymaps in
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>
1 parent 86ff071 commit b378f43

6 files changed

Lines changed: 33 additions & 48 deletions

File tree

‎drivers/media/IR/ir-core-priv.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ int ir_raw_handler_register(struct ir_raw_handler *ir_raw_handler);
126126
void ir_raw_handler_unregister(struct ir_raw_handler *ir_raw_handler);
127127
void ir_raw_init(void);
128128

129-
129+
int ir_rcmap_init(void);
130+
void ir_rcmap_cleanup(void);
130131
/*
131132
* Decoder initialization code
132133
*

‎drivers/media/IR/ir-sysfs.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,13 +325,15 @@ static int __init ir_core_init(void)
325325

326326
/* Initialize/load the decoders/keymap code that will be used */
327327
ir_raw_init();
328+
ir_rcmap_init();
328329

329330
return 0;
330331
}
331332

332333
static void __exit ir_core_exit(void)
333334
{
334335
class_unregister(&ir_input_class);
336+
ir_rcmap_cleanup();
335337
}
336338

337339
module_init(ir_core_init);

‎drivers/media/IR/keymaps/Makefile‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ obj-$(CONFIG_RC_MAP) += rc-adstech-dvb-t-pci.o \
1919
rc-dm1105-nec.o \
2020
rc-dntv-live-dvb-t.o \
2121
rc-dntv-live-dvbt-pro.o \
22-
rc-empty.o \
2322
rc-em-terratec.o \
2423
rc-encore-enltv2.o \
2524
rc-encore-enltv.o \

‎drivers/media/IR/keymaps/rc-empty.c‎

Lines changed: 0 additions & 44 deletions
This file was deleted.

‎drivers/media/IR/rc-map.c‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,26 @@ void ir_unregister_map(struct rc_keymap *map)
8282
}
8383
EXPORT_SYMBOL_GPL(ir_unregister_map);
8484

85+
86+
static struct ir_scancode empty[] = {
87+
{ 0x2a, KEY_COFFEE },
88+
};
89+
90+
static struct rc_keymap empty_map = {
91+
.map = {
92+
.scan = empty,
93+
.size = ARRAY_SIZE(empty),
94+
.ir_type = IR_TYPE_UNKNOWN, /* Legacy IR type */
95+
.name = RC_MAP_EMPTY,
96+
}
97+
};
98+
99+
int ir_rcmap_init(void)
100+
{
101+
return ir_register_map(&empty_map);
102+
}
103+
104+
void ir_rcmap_cleanup(void)
105+
{
106+
ir_unregister_map(&empty_map);
107+
}

‎include/media/ir-core.h‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,12 @@ static inline int ir_input_register(struct input_dev *dev,
110110
return -EINVAL;
111111

112112
ir_codes = get_rc_map(map_name);
113-
if (!ir_codes)
114-
return -EINVAL;
113+
if (!ir_codes) {
114+
ir_codes = get_rc_map(RC_MAP_EMPTY);
115+
116+
if (!ir_codes)
117+
return -EINVAL;
118+
}
115119

116120
rc = __ir_input_register(dev, ir_codes, props, driver_name);
117121
if (rc < 0)

0 commit comments

Comments
 (0)