aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Torokhov <dtor_core@ameritech.net>2005-12-28 01:25:11 -0500
committerDmitry Torokhov <dtor_core@ameritech.net>2005-12-28 01:25:11 -0500
commit87fd6318a6c381ba1e10a4f56907d11ae4a987b9 (patch)
tree84585314facc63e6320d34a70b65983b59b66761
parent8ea3694fcb7e5471cf84313a10e012b48e33c892 (diff)
Input: i8042 - convert to the new platform device interface
Do not use platform_device_register_simple() as it is going away, implement ->probe() and ->remove() functions so manual binding and unbinding will work with this driver. Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
-rw-r--r--drivers/input/serio/i8042.c116
1 files changed, 67 insertions, 49 deletions
diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c
index ac86c1d1d83e..a7d91d5356a5 100644
--- a/drivers/input/serio/i8042.c
+++ b/drivers/input/serio/i8042.c
@@ -572,7 +572,7 @@ static int i8042_enable_mux_ports(void)
572 * LCS/Telegraphics. 572 * LCS/Telegraphics.
573 */ 573 */
574 574
575static int __init i8042_check_mux(void) 575static int __devinit i8042_check_mux(void)
576{ 576{
577 unsigned char mux_version; 577 unsigned char mux_version;
578 578
@@ -600,7 +600,7 @@ static int __init i8042_check_mux(void)
600 * the presence of an AUX interface. 600 * the presence of an AUX interface.
601 */ 601 */
602 602
603static int __init i8042_check_aux(void) 603static int __devinit i8042_check_aux(void)
604{ 604{
605 unsigned char param; 605 unsigned char param;
606 static int i8042_check_aux_cookie; 606 static int i8042_check_aux_cookie;
@@ -678,7 +678,7 @@ static int __init i8042_check_aux(void)
678 * registers it, and reports to the user. 678 * registers it, and reports to the user.
679 */ 679 */
680 680
681static int __init i8042_port_register(struct i8042_port *port) 681static int __devinit i8042_port_register(struct i8042_port *port)
682{ 682{
683 i8042_ctr &= ~port->disable; 683 i8042_ctr &= ~port->disable;
684 684
@@ -956,7 +956,6 @@ static int i8042_resume(struct platform_device *dev)
956 panic_blink = i8042_panic_blink; 956 panic_blink = i8042_panic_blink;
957 957
958 return 0; 958 return 0;
959
960} 959}
961 960
962/* 961/*
@@ -969,16 +968,7 @@ static void i8042_shutdown(struct platform_device *dev)
969 i8042_controller_cleanup(); 968 i8042_controller_cleanup();
970} 969}
971 970
972static struct platform_driver i8042_driver = { 971static int __devinit i8042_create_kbd_port(void)
973 .suspend = i8042_suspend,
974 .resume = i8042_resume,
975 .shutdown = i8042_shutdown,
976 .driver = {
977 .name = "i8042",
978 },
979};
980
981static int __init i8042_create_kbd_port(void)
982{ 972{
983 struct serio *serio; 973 struct serio *serio;
984 struct i8042_port *port = &i8042_ports[I8042_KBD_PORT_NO]; 974 struct i8042_port *port = &i8042_ports[I8042_KBD_PORT_NO];
@@ -1003,7 +993,7 @@ static int __init i8042_create_kbd_port(void)
1003 return i8042_port_register(port); 993 return i8042_port_register(port);
1004} 994}
1005 995
1006static int __init i8042_create_aux_port(void) 996static int __devinit i8042_create_aux_port(void)
1007{ 997{
1008 struct serio *serio; 998 struct serio *serio;
1009 struct i8042_port *port = &i8042_ports[I8042_AUX_PORT_NO]; 999 struct i8042_port *port = &i8042_ports[I8042_AUX_PORT_NO];
@@ -1028,7 +1018,7 @@ static int __init i8042_create_aux_port(void)
1028 return i8042_port_register(port); 1018 return i8042_port_register(port);
1029} 1019}
1030 1020
1031static int __init i8042_create_mux_port(int index) 1021static int __devinit i8042_create_mux_port(int index)
1032{ 1022{
1033 struct serio *serio; 1023 struct serio *serio;
1034 struct i8042_port *port = &i8042_ports[I8042_MUX_PORT_NO + index]; 1024 struct i8042_port *port = &i8042_ports[I8042_MUX_PORT_NO + index];
@@ -1057,37 +1047,16 @@ static int __init i8042_create_mux_port(int index)
1057 return i8042_port_register(port); 1047 return i8042_port_register(port);
1058} 1048}
1059 1049
1060static int __init i8042_init(void) 1050static int __devinit i8042_probe(struct platform_device *dev)
1061{ 1051{
1062 int i, have_ports = 0; 1052 int i, have_ports = 0;
1063 int err; 1053 int err;
1064 1054
1065 dbg_init();
1066
1067 init_timer(&i8042_timer); 1055 init_timer(&i8042_timer);
1068 i8042_timer.function = i8042_timer_func; 1056 i8042_timer.function = i8042_timer_func;
1069 1057
1070 err = i8042_platform_init(); 1058 if (i8042_controller_init())
1071 if (err) 1059 return -ENODEV;
1072 return err;
1073
1074 i8042_ports[I8042_AUX_PORT_NO].irq = I8042_AUX_IRQ;
1075 i8042_ports[I8042_KBD_PORT_NO].irq = I8042_KBD_IRQ;
1076
1077 if (i8042_controller_init()) {
1078 err = -ENODEV;
1079 goto err_platform_exit;
1080 }
1081
1082 err = platform_driver_register(&i8042_driver);
1083 if (err)
1084 goto err_controller_cleanup;
1085
1086 i8042_platform_device = platform_device_register_simple("i8042", -1, NULL, 0);
1087 if (IS_ERR(i8042_platform_device)) {
1088 err = PTR_ERR(i8042_platform_device);
1089 goto err_unregister_driver;
1090 }
1091 1060
1092 if (!i8042_noaux && !i8042_check_aux()) { 1061 if (!i8042_noaux && !i8042_check_aux()) {
1093 if (!i8042_nomux && !i8042_check_mux()) { 1062 if (!i8042_nomux && !i8042_check_mux()) {
@@ -1113,30 +1082,23 @@ static int __init i8042_init(void)
1113 1082
1114 if (!have_ports) { 1083 if (!have_ports) {
1115 err = -ENODEV; 1084 err = -ENODEV;
1116 goto err_unregister_device; 1085 goto err_controller_cleanup;
1117 } 1086 }
1118 1087
1119 mod_timer(&i8042_timer, jiffies + I8042_POLL_PERIOD); 1088 mod_timer(&i8042_timer, jiffies + I8042_POLL_PERIOD);
1120
1121 return 0; 1089 return 0;
1122 1090
1123 err_unregister_ports: 1091 err_unregister_ports:
1124 for (i = 0; i < I8042_NUM_PORTS; i++) 1092 for (i = 0; i < I8042_NUM_PORTS; i++)
1125 if (i8042_ports[i].serio) 1093 if (i8042_ports[i].serio)
1126 serio_unregister_port(i8042_ports[i].serio); 1094 serio_unregister_port(i8042_ports[i].serio);
1127 err_unregister_device:
1128 platform_device_unregister(i8042_platform_device);
1129 err_unregister_driver:
1130 platform_driver_unregister(&i8042_driver);
1131 err_controller_cleanup: 1095 err_controller_cleanup:
1132 i8042_controller_cleanup(); 1096 i8042_controller_cleanup();
1133 err_platform_exit:
1134 i8042_platform_exit();
1135 1097
1136 return err; 1098 return err;
1137} 1099}
1138 1100
1139static void __exit i8042_exit(void) 1101static int __devexit i8042_remove(struct platform_device *dev)
1140{ 1102{
1141 int i; 1103 int i;
1142 1104
@@ -1148,6 +1110,62 @@ static void __exit i8042_exit(void)
1148 1110
1149 del_timer_sync(&i8042_timer); 1111 del_timer_sync(&i8042_timer);
1150 1112
1113 return 0;
1114}
1115
1116static struct platform_driver i8042_driver = {
1117 .driver = {
1118 .name = "i8042",
1119 .owner = THIS_MODULE,
1120 },
1121 .probe = i8042_probe,
1122 .remove = __devexit_p(i8042_remove),
1123 .suspend = i8042_suspend,
1124 .resume = i8042_resume,
1125 .shutdown = i8042_shutdown,
1126};
1127
1128static int __init i8042_init(void)
1129{
1130 int err;
1131
1132 dbg_init();
1133
1134 err = i8042_platform_init();
1135 if (err)
1136 return err;
1137
1138 i8042_ports[I8042_AUX_PORT_NO].irq = I8042_AUX_IRQ;
1139 i8042_ports[I8042_KBD_PORT_NO].irq = I8042_KBD_IRQ;
1140
1141 err = platform_driver_register(&i8042_driver);
1142 if (err)
1143 goto err_platform_exit;
1144
1145 i8042_platform_device = platform_device_alloc("i8042", -1);
1146 if (!i8042_platform_device) {
1147 err = -ENOMEM;
1148 goto err_unregister_driver;
1149 }
1150
1151 err = platform_device_add(i8042_platform_device);
1152 if (err)
1153 goto err_free_device;
1154
1155 return 0;
1156
1157 err_free_device:
1158 platform_device_put(i8042_platform_device);
1159 err_unregister_driver:
1160 platform_driver_unregister(&i8042_driver);
1161 err_platform_exit:
1162 i8042_platform_exit();
1163
1164 return err;
1165}
1166
1167static void __exit i8042_exit(void)
1168{
1151 platform_device_unregister(i8042_platform_device); 1169 platform_device_unregister(i8042_platform_device);
1152 platform_driver_unregister(&i8042_driver); 1170 platform_driver_unregister(&i8042_driver);
1153 1171