diff options
Diffstat (limited to 'drivers/input')
-rw-r--r-- | drivers/input/serio/ct82c710.c | 89 |
1 files changed, 63 insertions, 26 deletions
diff --git a/drivers/input/serio/ct82c710.c b/drivers/input/serio/ct82c710.c index 4da6c86b5d76..096b6a0b5cca 100644 --- a/drivers/input/serio/ct82c710.c +++ b/drivers/input/serio/ct82c710.c | |||
@@ -154,7 +154,7 @@ static int ct82c710_write(struct serio *port, unsigned char c) | |||
154 | * See if we can find a 82C710 device. Read mouse address. | 154 | * See if we can find a 82C710 device. Read mouse address. |
155 | */ | 155 | */ |
156 | 156 | ||
157 | static int __init ct82c710_probe(void) | 157 | static int __init ct82c710_detect(void) |
158 | { | 158 | { |
159 | outb_p(0x55, 0x2fa); /* Any value except 9, ff or 36 */ | 159 | outb_p(0x55, 0x2fa); /* Any value except 9, ff or 36 */ |
160 | outb_p(0xaa, 0x3fa); /* Inverse of 55 */ | 160 | outb_p(0xaa, 0x3fa); /* Inverse of 55 */ |
@@ -163,7 +163,7 @@ static int __init ct82c710_probe(void) | |||
163 | outb_p(0x1b, 0x2fa); /* Inverse of e4 */ | 163 | outb_p(0x1b, 0x2fa); /* Inverse of e4 */ |
164 | outb_p(0x0f, 0x390); /* Write index */ | 164 | outb_p(0x0f, 0x390); /* Write index */ |
165 | if (inb_p(0x391) != 0xe4) /* Config address found? */ | 165 | if (inb_p(0x391) != 0xe4) /* Config address found? */ |
166 | return -1; /* No: no 82C710 here */ | 166 | return -ENODEV; /* No: no 82C710 here */ |
167 | 167 | ||
168 | outb_p(0x0d, 0x390); /* Write index */ | 168 | outb_p(0x0d, 0x390); /* Write index */ |
169 | ct82c710_iores.start = inb_p(0x391) << 2; /* Get mouse I/O address */ | 169 | ct82c710_iores.start = inb_p(0x391) << 2; /* Get mouse I/O address */ |
@@ -175,51 +175,88 @@ static int __init ct82c710_probe(void) | |||
175 | return 0; | 175 | return 0; |
176 | } | 176 | } |
177 | 177 | ||
178 | static struct serio * __init ct82c710_allocate_port(void) | 178 | static int __devinit ct82c710_probe(struct platform_device *dev) |
179 | { | 179 | { |
180 | struct serio *serio; | 180 | ct82c710_port = kzalloc(sizeof(struct serio), GFP_KERNEL); |
181 | 181 | if (!ct82c710_port) | |
182 | serio = kmalloc(sizeof(struct serio), GFP_KERNEL); | 182 | return -ENOMEM; |
183 | if (serio) { | 183 | |
184 | memset(serio, 0, sizeof(struct serio)); | 184 | ct82c710_port->id.type = SERIO_8042; |
185 | serio->id.type = SERIO_8042; | 185 | ct82c710_port->dev.parent = &dev->dev; |
186 | serio->open = ct82c710_open; | 186 | ct82c710_port->open = ct82c710_open; |
187 | serio->close = ct82c710_close; | 187 | ct82c710_port->close = ct82c710_close; |
188 | serio->write = ct82c710_write; | 188 | ct82c710_port->write = ct82c710_write; |
189 | serio->dev.parent = &ct82c710_device->dev; | 189 | strlcpy(ct82c710_port->name, "C&T 82c710 mouse port", |
190 | strlcpy(serio->name, "C&T 82c710 mouse port", sizeof(serio->name)); | 190 | sizeof(ct82c710_port->name)); |
191 | snprintf(serio->phys, sizeof(serio->phys), "isa%04lx/serio0", CT82C710_DATA); | 191 | snprintf(ct82c710_port->phys, sizeof(ct82c710_port->phys), |
192 | } | 192 | "isa%04lx/serio0", CT82C710_DATA); |
193 | |||
194 | serio_register_port(ct82c710_port); | ||
195 | |||
196 | return 0; | ||
197 | } | ||
198 | |||
199 | static int __devexit ct82c710_remove(struct platform_device *dev) | ||
200 | { | ||
201 | serio_unregister_port(ct82c710_port); | ||
193 | 202 | ||
194 | return serio; | 203 | return 0; |
195 | } | 204 | } |
196 | 205 | ||
206 | static struct platform_driver ct82c710_driver = { | ||
207 | .driver = { | ||
208 | .name = "ct82c710", | ||
209 | .owner = THIS_MODULE, | ||
210 | }, | ||
211 | .probe = ct82c710_probe, | ||
212 | .remove = __devexit_p(ct82c710_remove), | ||
213 | }; | ||
214 | |||
215 | |||
197 | static int __init ct82c710_init(void) | 216 | static int __init ct82c710_init(void) |
198 | { | 217 | { |
199 | if (ct82c710_probe()) | 218 | int error; |
200 | return -ENODEV; | ||
201 | 219 | ||
202 | ct82c710_device = platform_device_register_simple("ct82c710", -1, &ct82c710_iores, 1); | 220 | error = ct82c710_detect(); |
203 | if (IS_ERR(ct82c710_device)) | 221 | if (error) |
204 | return PTR_ERR(ct82c710_device); | 222 | return error; |
205 | 223 | ||
206 | if (!(ct82c710_port = ct82c710_allocate_port())) { | 224 | error = platform_driver_register(&ct82c710_driver); |
207 | platform_device_unregister(ct82c710_device); | 225 | if (error) |
208 | return -ENOMEM; | 226 | return error; |
227 | |||
228 | ct82c710_device = platform_device_alloc("ct82c710", -1); | ||
229 | if (!ct82c710_device) { | ||
230 | error = -ENOMEM; | ||
231 | goto err_unregister_driver; | ||
209 | } | 232 | } |
210 | 233 | ||
234 | error = platform_device_add_resources(ct82c710_device, &ct82c710_iores, 1); | ||
235 | if (error) | ||
236 | goto err_free_device; | ||
237 | |||
238 | error = platform_device_add(ct82c710_device); | ||
239 | if (error) | ||
240 | goto err_free_device; | ||
241 | |||
211 | serio_register_port(ct82c710_port); | 242 | serio_register_port(ct82c710_port); |
212 | 243 | ||
213 | printk(KERN_INFO "serio: C&T 82c710 mouse port at %#lx irq %d\n", | 244 | printk(KERN_INFO "serio: C&T 82c710 mouse port at %#lx irq %d\n", |
214 | CT82C710_DATA, CT82C710_IRQ); | 245 | CT82C710_DATA, CT82C710_IRQ); |
215 | 246 | ||
216 | return 0; | 247 | return 0; |
248 | |||
249 | err_free_device: | ||
250 | platform_device_put(ct82c710_device); | ||
251 | err_unregister_driver: | ||
252 | platform_driver_unregister(&ct82c710_driver); | ||
253 | return error; | ||
217 | } | 254 | } |
218 | 255 | ||
219 | static void __exit ct82c710_exit(void) | 256 | static void __exit ct82c710_exit(void) |
220 | { | 257 | { |
221 | serio_unregister_port(ct82c710_port); | ||
222 | platform_device_unregister(ct82c710_device); | 258 | platform_device_unregister(ct82c710_device); |
259 | platform_driver_unregister(&ct82c710_driver); | ||
223 | } | 260 | } |
224 | 261 | ||
225 | module_init(ct82c710_init); | 262 | module_init(ct82c710_init); |