diff options
Diffstat (limited to 'drivers/input/serio/maceps2.c')
-rw-r--r-- | drivers/input/serio/maceps2.c | 68 |
1 files changed, 52 insertions, 16 deletions
diff --git a/drivers/input/serio/maceps2.c b/drivers/input/serio/maceps2.c index d857f7081adb..f08a5d0cd5fa 100644 --- a/drivers/input/serio/maceps2.c +++ b/drivers/input/serio/maceps2.c | |||
@@ -118,13 +118,12 @@ static void maceps2_close(struct serio *dev) | |||
118 | } | 118 | } |
119 | 119 | ||
120 | 120 | ||
121 | static struct serio * __init maceps2_allocate_port(int idx) | 121 | static struct serio * __devinit maceps2_allocate_port(int idx) |
122 | { | 122 | { |
123 | struct serio *serio; | 123 | struct serio *serio; |
124 | 124 | ||
125 | serio = kmalloc(sizeof(struct serio), GFP_KERNEL); | 125 | serio = kzalloc(sizeof(struct serio), GFP_KERNEL); |
126 | if (serio) { | 126 | if (serio) { |
127 | memset(serio, 0, sizeof(struct serio)); | ||
128 | serio->id.type = SERIO_8042; | 127 | serio->id.type = SERIO_8042; |
129 | serio->write = maceps2_write; | 128 | serio->write = maceps2_write; |
130 | serio->open = maceps2_open; | 129 | serio->open = maceps2_open; |
@@ -138,24 +137,13 @@ static struct serio * __init maceps2_allocate_port(int idx) | |||
138 | return serio; | 137 | return serio; |
139 | } | 138 | } |
140 | 139 | ||
141 | 140 | static int __devinit maceps2_probe(struct platform_device *dev) | |
142 | static int __init maceps2_init(void) | ||
143 | { | 141 | { |
144 | maceps2_device = platform_device_register_simple("maceps2", -1, NULL, 0); | ||
145 | if (IS_ERR(maceps2_device)) | ||
146 | return PTR_ERR(maceps2_device); | ||
147 | |||
148 | port_data[0].port = &mace->perif.ps2.keyb; | ||
149 | port_data[0].irq = MACEISA_KEYB_IRQ; | ||
150 | port_data[1].port = &mace->perif.ps2.mouse; | ||
151 | port_data[1].irq = MACEISA_MOUSE_IRQ; | ||
152 | |||
153 | maceps2_port[0] = maceps2_allocate_port(0); | 142 | maceps2_port[0] = maceps2_allocate_port(0); |
154 | maceps2_port[1] = maceps2_allocate_port(1); | 143 | maceps2_port[1] = maceps2_allocate_port(1); |
155 | if (!maceps2_port[0] || !maceps2_port[1]) { | 144 | if (!maceps2_port[0] || !maceps2_port[1]) { |
156 | kfree(maceps2_port[0]); | 145 | kfree(maceps2_port[0]); |
157 | kfree(maceps2_port[1]); | 146 | kfree(maceps2_port[1]); |
158 | platform_device_unregister(maceps2_device); | ||
159 | return -ENOMEM; | 147 | return -ENOMEM; |
160 | } | 148 | } |
161 | 149 | ||
@@ -165,11 +153,59 @@ static int __init maceps2_init(void) | |||
165 | return 0; | 153 | return 0; |
166 | } | 154 | } |
167 | 155 | ||
168 | static void __exit maceps2_exit(void) | 156 | static int __devexit maceps2_remove(struct platform_device *dev) |
169 | { | 157 | { |
170 | serio_unregister_port(maceps2_port[0]); | 158 | serio_unregister_port(maceps2_port[0]); |
171 | serio_unregister_port(maceps2_port[1]); | 159 | serio_unregister_port(maceps2_port[1]); |
160 | |||
161 | return 0; | ||
162 | } | ||
163 | |||
164 | static struct platform_driver maceps2_driver = { | ||
165 | .driver = { | ||
166 | .name = "maceps2", | ||
167 | .owner = THIS_MODULE, | ||
168 | }, | ||
169 | .probe = maceps2_probe, | ||
170 | .remove = __devexit_p(maceps2_remove), | ||
171 | }; | ||
172 | |||
173 | static int __init maceps2_init(void) | ||
174 | { | ||
175 | int error; | ||
176 | |||
177 | error = platform_driver_register(&maceps2_driver); | ||
178 | if (error) | ||
179 | return error; | ||
180 | |||
181 | maceps2_device = platform_device_alloc("maceps2", -1); | ||
182 | if (!maceps2_device) { | ||
183 | error = -ENOMEM; | ||
184 | goto err_unregister_driver; | ||
185 | } | ||
186 | |||
187 | port_data[0].port = &mace->perif.ps2.keyb; | ||
188 | port_data[0].irq = MACEISA_KEYB_IRQ; | ||
189 | port_data[1].port = &mace->perif.ps2.mouse; | ||
190 | port_data[1].irq = MACEISA_MOUSE_IRQ; | ||
191 | |||
192 | error = platform_device_add(maceps2_device); | ||
193 | if (error) | ||
194 | goto err_free_device; | ||
195 | |||
196 | return 0; | ||
197 | |||
198 | err_free_device: | ||
199 | platform_device_put(maceps2_device); | ||
200 | err_unregister_driver: | ||
201 | platform_driver_unregister(&maceps2_driver); | ||
202 | return error; | ||
203 | } | ||
204 | |||
205 | static void __exit maceps2_exit(void) | ||
206 | { | ||
172 | platform_device_unregister(maceps2_device); | 207 | platform_device_unregister(maceps2_device); |
208 | platform_driver_unregister(&maceps2_driver); | ||
173 | } | 209 | } |
174 | 210 | ||
175 | module_init(maceps2_init); | 211 | module_init(maceps2_init); |