next: input: Fix build error seen if input-core is built as module
Subsystems (2)
PATCH 1/1 next: input: Fix build error seen if input-core is built as module
The following build error may be seen if input-core is built as module:
drivers/input/leds.o: In function `init_module':
leds.c:(.init.text+0x0): multiple definition of init_module' drivers/input/input.o:input.c:(.init.text+0x0): first defined here drivers/input/leds.o: In function cleanup_module':
leds.c:(.exit.text+0x0): multiple definition of `cleanup_module' drivers/input/input.o:input.c:(.exit.text+0x0): first defined here make[2]: *** [drivers/input/input-core.o] Error 1
leds.c is now part of input-core and can therefore not have its own module initialization code. Initialize it from input.c instead.
---
Problem is seen in linux-next and mmotm.
I am perfectly fine if the patch is merged into the original patch, or if a different fix for the problem is implemented, as long as it gets fixed.
drivers/input/input.c | 4 ++++ drivers/input/leds.c | 9 +++------ drivers/input/leds.h | 7 +++++++ 3 files changed, 14 insertions(+), 6 deletions(-) create mode 100644 drivers/input/leds.h
drivers/input/input.c +4 -0
@@ -28,6 +28,7 @@#include <linux/mutex.h> #include <linux/rcupdate.h> #include "input-compat.h" +#include "leds.h" MODULE_AUTHOR ("Vojtech Pavlik <[email protected]>" );MODULE_DESCRIPTION ("Input core" );
@@ -2428,6 +2429,8 @@ static int __init input_init(void) goto fail2; } +input_led_init (); +return 0 ; fail2:input_proc_exit ();
@@ -2437,6 +2440,7 @@ static int __init input_init(void) static void __exit input_exit(void) { +input_led_exit ();input_proc_exit ();unregister_chrdev_region (MKDEV (INPUT_MAJOR ,0 ),INPUT_MAX_CHAR_DEVICES );
drivers/input/leds.c +3 -6
@@ -14,6 +14,7 @@#include <linux/init.h> #include <linux/leds.h> #include <linux/input.h> +#include "leds.h" /* * Keyboard LEDs are propagated by default like the following example:
@@ -255,22 +256,18 @@ void input_led_disconnect(struct input_dev *dev)mutex_unlock (&vt_led_registered_lock); } -static int __init input_led_init (void ) +void __init input_led_init (void ) {unsigned i;for (i =0 ; i <LED_CNT ; i++)INIT_WORK (&vt_led_work[i], vt_led_cb); - -return 0 ; } -static void __exit input_led_exit(void) +void __exit input_led_exit(void) { }MODULE_LICENSE ("GPL" );MODULE_DESCRIPTION ("User LED support for input layer" );MODULE_AUTHOR ("Samuel Thibault <[email protected]>" ); -module_init (input_led_init); -module_exit (input_led_exit);
drivers/input/leds.h new file +7 -0
@@ -0,0 +1,7 @@ +#ifndef INPUT_LEDS_H +#define INPUT_LEDS_H + +void input_led_init (void ); +void input_led_exit (void ); + +#endif /* INPUT_LEDS_H */
Signature · 1 line
1.9.1
Hello,
Quoted 9 lines · Guenter Roeck, le Sun 02 Nov 2014 21:53:17 -0800, a écrit :
The following build error may be seen if input-core is built as module:
drivers/input/leds.o: In function `init_module':
leds.c:(.init.text+0x0): multiple definition ofinit_module' drivers/input/input.o:input.c:(.init.text+0x0): first defined here drivers/input/leds.o: In functioncleanup_module':
leds.c:(.exit.text+0x0): multiple definition of `cleanup_module' drivers/input/input.o:input.c:(.exit.text+0x0): first defined here make[2]: *** [drivers/input/input-core.o] Error 1
I have already submitted a patch to fix it, here it is again:
Now that input/leds.c is compiled into the input.ko module in the mm tree, its init and exit function must be called by input.ko's init and exit functions, instead of duplicating the module init/exit hooks, which leads to the following build error when input is built as a module:
leds.c:(.init.text+0x0): multiple definition of init_module' leds.c:(.exit.text+0x0): multiple definition of cleanup_module'
This also adds a proper clean of the vt_led_work queues in the exit function.
---
This is a follow-up to the following reports:
Re: [next:master 9776/10302] leds.c:(.init.text+0x0): multiple definition of `init_module'
Re: [next:master 9391/10970] leds.c:(.exit.text+0x0): multiple definition of `cleanup_module'
and to be applied over the existing input-route-kbd-leds-through-the-generic-leds-layer-fix-2 please.
Thanks!
Samuel
drivers/input/input.c +3 -0
@@ -2427,6 +2427,8 @@ static int __init input_init(void) goto fail2; } +input_led_init (); +return 0 ; fail2:input_proc_exit ();
@@ -2436,6 +2438,7 @@ static int __init input_init(void) static void __exit input_exit(void) { +input_led_exit ();input_proc_exit ();unregister_chrdev_region (MKDEV (INPUT_MAJOR ,0 ),INPUT_MAX_CHAR_DEVICES );
drivers/input/leds.c +6 -10
@@ -255,22 +255,18 @@ void input_led_disconnect(struct input_dmutex_unlock (&vt_led_registered_lock); } -static int __init input_led_init (void ) +void __init input_led_init (void ) {unsigned i;for (i =0 ; i <LED_CNT ; i++)INIT_WORK (&vt_led_work[i], vt_led_cb); - -return 0 ; } -static void __exit input_led_exit(void) +void __exit input_led_exit(void) { -} +unsigned i; -MODULE_LICENSE ("GPL" ); -MODULE_DESCRIPTION ("User LED support for input layer" ); -MODULE_AUTHOR ("Samuel Thibault <[email protected]>" ); -module_init (input_led_init); -module_exit (input_led_exit); +for (i =0 ; i <LED_CNT ; i++) +cancel_work_sync (&vt_led_work[i]); +}
include/linux/input.h +7 -0
@@ -536,11 +536,18 @@ int input_ff_create_memless(struct input#ifdef CONFIG_INPUT_LEDS +void input_led_init (void ); +void input_led_exit (void ); +int input_led_connect (struct input_dev *dev);void input_led_disconnect (struct input_dev *dev);#else +static inline void input_led_init (void ) { } + +static inline void input_led_exit (void ) { } +static inline int input_led_connect (struct input_dev *dev) {return 0 ;