Skip to content

Commit 83ff4f6

Browse files
Hans Verkuilgregkh
authored andcommitted
media: rc: compile rc-cec.c into rc-core
commit f09f9f9 upstream. The rc-cec keymap is unusual in that it can't be built as a module, instead it is registered directly in rc-main.c if CONFIG_MEDIA_CEC_RC is set. This is because it can be called from drm_dp_cec_set_edid() via cec_register_adapter() in an asynchronous context, and it is not allowed to use request_module() to load rc-cec.ko in that case. Trying to do so results in a 'WARN_ON_ONCE(wait && current_is_async())'. Since this keymap is only used if CONFIG_MEDIA_CEC_RC is set, we just compile this keymap into the rc-core module and never as a separate module. Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Fixes: 2c6d1ff (drm: add support for DisplayPort CEC-Tunneling-over-AUX) Reported-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sean Young <sean@mess.org> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent db2ae26 commit 83ff4f6

5 files changed

Lines changed: 25 additions & 18 deletions

File tree

‎drivers/media/rc/Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ obj-y += keymaps/
55
obj-$(CONFIG_RC_CORE) += rc-core.o
66
rc-core-y := rc-main.o rc-ir-raw.o
77
rc-core-$(CONFIG_LIRC) += lirc_dev.o
8+
rc-core-$(CONFIG_MEDIA_CEC_RC) += keymaps/rc-cec.o
89
rc-core-$(CONFIG_BPF_LIRC_MODE2) += bpf-lirc.o
910
obj-$(CONFIG_IR_NEC_DECODER) += ir-nec-decoder.o
1011
obj-$(CONFIG_IR_RC5_DECODER) += ir-rc5-decoder.o

‎drivers/media/rc/keymaps/Makefile‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ obj-$(CONFIG_RC_MAP) += rc-adstech-dvb-t-pci.o \
2121
rc-behold.o \
2222
rc-behold-columbus.o \
2323
rc-budget-ci-old.o \
24-
rc-cec.o \
2524
rc-cinergy-1400.o \
2625
rc-cinergy.o \
2726
rc-d680-dmb.o \

‎drivers/media/rc/keymaps/rc-cec.c‎

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
// SPDX-License-Identifier: GPL-2.0-or-later
22
/* Keytable for the CEC remote control
3+
*
4+
* This keymap is unusual in that it can't be built as a module,
5+
* instead it is registered directly in rc-main.c if CONFIG_MEDIA_CEC_RC
6+
* is set. This is because it can be called from drm_dp_cec_set_edid() via
7+
* cec_register_adapter() in an asynchronous context, and it is not
8+
* allowed to use request_module() to load rc-cec.ko in that case.
9+
*
10+
* Since this keymap is only used if CONFIG_MEDIA_CEC_RC is set, we
11+
* just compile this keymap into the rc-core module and never as a
12+
* separate module.
313
*
414
* Copyright (c) 2015 by Kamil Debski
515
*/
@@ -152,27 +162,11 @@ static struct rc_map_table cec[] = {
152162
/* 0x77-0xff: Reserved */
153163
};
154164

155-
static struct rc_map_list cec_map = {
165+
struct rc_map_list cec_map = {
156166
.map = {
157167
.scan = cec,
158168
.size = ARRAY_SIZE(cec),
159169
.rc_proto = RC_PROTO_CEC,
160170
.name = RC_MAP_CEC,
161171
}
162172
};
163-
164-
static int __init init_rc_map_cec(void)
165-
{
166-
return rc_map_register(&cec_map);
167-
}
168-
169-
static void __exit exit_rc_map_cec(void)
170-
{
171-
rc_map_unregister(&cec_map);
172-
}
173-
174-
module_init(init_rc_map_cec);
175-
module_exit(exit_rc_map_cec);
176-
177-
MODULE_LICENSE("GPL");
178-
MODULE_AUTHOR("Kamil Debski");

‎drivers/media/rc/rc-main.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2069,6 +2069,9 @@ static int __init rc_core_init(void)
20692069

20702070
led_trigger_register_simple("rc-feedback", &led_feedback);
20712071
rc_map_register(&empty_map);
2072+
#ifdef CONFIG_MEDIA_CEC_RC
2073+
rc_map_register(&cec_map);
2074+
#endif
20722075

20732076
return 0;
20742077
}
@@ -2078,6 +2081,9 @@ static void __exit rc_core_exit(void)
20782081
lirc_dev_exit();
20792082
class_unregister(&rc_class);
20802083
led_trigger_unregister_simple(led_feedback);
2084+
#ifdef CONFIG_MEDIA_CEC_RC
2085+
rc_map_unregister(&cec_map);
2086+
#endif
20812087
rc_map_unregister(&empty_map);
20822088
}
20832089

‎include/media/rc-map.h‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,13 @@ struct rc_map_list {
175175
struct rc_map map;
176176
};
177177

178+
#ifdef CONFIG_MEDIA_CEC_RC
179+
/*
180+
* rc_map_list from rc-cec.c
181+
*/
182+
extern struct rc_map_list cec_map;
183+
#endif
184+
178185
/* Routines from rc-map.c */
179186

180187
/**

0 commit comments

Comments
 (0)