Commit a2cb1191 authored by Dmitry Torokhov's avatar Dmitry Torokhov

Input: mousedev - factor out psaux code to reduce #ifdefery

Reviewed-by: default avatarDavid Herrmann <dh.herrmann@googlemail.com>
Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent aba828ce
...@@ -25,9 +25,6 @@ ...@@ -25,9 +25,6 @@
#include <linux/major.h> #include <linux/major.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#ifdef CONFIG_INPUT_MOUSEDEV_PSAUX
#include <linux/miscdevice.h>
#endif
MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>"); MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
MODULE_DESCRIPTION("Mouse (ExplorerPS/2) device interfaces"); MODULE_DESCRIPTION("Mouse (ExplorerPS/2) device interfaces");
...@@ -1064,10 +1061,36 @@ static struct input_handler mousedev_handler = { ...@@ -1064,10 +1061,36 @@ static struct input_handler mousedev_handler = {
}; };
#ifdef CONFIG_INPUT_MOUSEDEV_PSAUX #ifdef CONFIG_INPUT_MOUSEDEV_PSAUX
#include <linux/miscdevice.h>
static struct miscdevice psaux_mouse = { static struct miscdevice psaux_mouse = {
PSMOUSE_MINOR, "psaux", &mousedev_fops .minor = PSMOUSE_MINOR,
.name = "psaux",
.fops = &mousedev_fops,
}; };
static int psaux_registered;
static bool psaux_registered;
static void __init mousedev_psaux_register(void)
{
int error;
error = misc_register(&psaux_mouse);
if (error)
pr_warn("could not register psaux device, error: %d\n",
error);
else
psaux_registered = true;
}
static void __exit mousedev_psaux_unregister(void)
{
if (psaux_registered)
misc_deregister(&psaux_mouse);
}
#else
static inline void mousedev_psaux_register(void) { }
static inline void mousedev_psaux_unregister(void) { }
#endif #endif
static int __init mousedev_init(void) static int __init mousedev_init(void)
...@@ -1084,14 +1107,7 @@ static int __init mousedev_init(void) ...@@ -1084,14 +1107,7 @@ static int __init mousedev_init(void)
return error; return error;
} }
#ifdef CONFIG_INPUT_MOUSEDEV_PSAUX mousedev_psaux_register();
error = misc_register(&psaux_mouse);
if (error)
pr_warn("could not register psaux device, error: %d\n",
error);
else
psaux_registered = 1;
#endif
pr_info("PS/2 mouse device common for all mice\n"); pr_info("PS/2 mouse device common for all mice\n");
...@@ -1100,10 +1116,7 @@ static int __init mousedev_init(void) ...@@ -1100,10 +1116,7 @@ static int __init mousedev_init(void)
static void __exit mousedev_exit(void) static void __exit mousedev_exit(void)
{ {
#ifdef CONFIG_INPUT_MOUSEDEV_PSAUX mousedev_psaux_unregister();
if (psaux_registered)
misc_deregister(&psaux_mouse);
#endif
input_unregister_handler(&mousedev_handler); input_unregister_handler(&mousedev_handler);
mousedev_destroy(mousedev_mix); mousedev_destroy(mousedev_mix);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment