aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2012-10-08 12:07:23 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2012-10-08 12:37:38 -0400
commita2cb1191f4733134b21918b6098512a2e2e48e61 (patch)
treea40cd0b338c11c6a9bebac215c8a1f0224ebe3a5 /drivers/input
parentaba828cee24f48bc93a661aaa18caea301786f3e (diff)
Input: mousedev - factor out psaux code to reduce #ifdefery
Reviewed-by: David Herrmann <dh.herrmann@googlemail.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Diffstat (limited to 'drivers/input')
-rw-r--r--drivers/input/mousedev.c47
1 files changed, 30 insertions, 17 deletions
diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
index 964e43d81e29..8d3942fe1c39 100644
--- a/drivers/input/mousedev.c
+++ b/drivers/input/mousedev.c
@@ -25,9 +25,6 @@
25#include <linux/major.h> 25#include <linux/major.h>
26#include <linux/device.h> 26#include <linux/device.h>
27#include <linux/kernel.h> 27#include <linux/kernel.h>
28#ifdef CONFIG_INPUT_MOUSEDEV_PSAUX
29#include <linux/miscdevice.h>
30#endif
31 28
32MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>"); 29MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
33MODULE_DESCRIPTION("Mouse (ExplorerPS/2) device interfaces"); 30MODULE_DESCRIPTION("Mouse (ExplorerPS/2) device interfaces");
@@ -1064,10 +1061,36 @@ static struct input_handler mousedev_handler = {
1064}; 1061};
1065 1062
1066#ifdef CONFIG_INPUT_MOUSEDEV_PSAUX 1063#ifdef CONFIG_INPUT_MOUSEDEV_PSAUX
1064#include <linux/miscdevice.h>
1065
1067static struct miscdevice psaux_mouse = { 1066static struct miscdevice psaux_mouse = {
1068 PSMOUSE_MINOR, "psaux", &mousedev_fops 1067 .minor = PSMOUSE_MINOR,
1068 .name = "psaux",
1069 .fops = &mousedev_fops,
1069}; 1070};
1070static int psaux_registered; 1071
1072static bool psaux_registered;
1073
1074static void __init mousedev_psaux_register(void)
1075{
1076 int error;
1077
1078 error = misc_register(&psaux_mouse);
1079 if (error)
1080 pr_warn("could not register psaux device, error: %d\n",
1081 error);
1082 else
1083 psaux_registered = true;
1084}
1085
1086static void __exit mousedev_psaux_unregister(void)
1087{
1088 if (psaux_registered)
1089 misc_deregister(&psaux_mouse);
1090}
1091#else
1092static inline void mousedev_psaux_register(void) { }
1093static inline void mousedev_psaux_unregister(void) { }
1071#endif 1094#endif
1072 1095
1073static int __init mousedev_init(void) 1096static int __init mousedev_init(void)
@@ -1084,14 +1107,7 @@ static int __init mousedev_init(void)
1084 return error; 1107 return error;
1085 } 1108 }
1086 1109
1087#ifdef CONFIG_INPUT_MOUSEDEV_PSAUX 1110 mousedev_psaux_register();
1088 error = misc_register(&psaux_mouse);
1089 if (error)
1090 pr_warn("could not register psaux device, error: %d\n",
1091 error);
1092 else
1093 psaux_registered = 1;
1094#endif
1095 1111
1096 pr_info("PS/2 mouse device common for all mice\n"); 1112 pr_info("PS/2 mouse device common for all mice\n");
1097 1113
@@ -1100,10 +1116,7 @@ static int __init mousedev_init(void)
1100 1116
1101static void __exit mousedev_exit(void) 1117static void __exit mousedev_exit(void)
1102{ 1118{
1103#ifdef CONFIG_INPUT_MOUSEDEV_PSAUX 1119 mousedev_psaux_unregister();
1104 if (psaux_registered)
1105 misc_deregister(&psaux_mouse);
1106#endif
1107 input_unregister_handler(&mousedev_handler); 1120 input_unregister_handler(&mousedev_handler);
1108 mousedev_destroy(mousedev_mix); 1121 mousedev_destroy(mousedev_mix);
1109} 1122}