diff options
Diffstat (limited to 'drivers/input/mouse/vsxxxaa.c')
-rw-r--r-- | drivers/input/mouse/vsxxxaa.c | 84 |
1 files changed, 40 insertions, 44 deletions
diff --git a/drivers/input/mouse/vsxxxaa.c b/drivers/input/mouse/vsxxxaa.c index f024be9b44d2..36e9442a16b2 100644 --- a/drivers/input/mouse/vsxxxaa.c +++ b/drivers/input/mouse/vsxxxaa.c | |||
@@ -112,7 +112,7 @@ MODULE_LICENSE ("GPL"); | |||
112 | 112 | ||
113 | 113 | ||
114 | struct vsxxxaa { | 114 | struct vsxxxaa { |
115 | struct input_dev dev; | 115 | struct input_dev *dev; |
116 | struct serio *serio; | 116 | struct serio *serio; |
117 | #define BUFLEN 15 /* At least 5 is needed for a full tablet packet */ | 117 | #define BUFLEN 15 /* At least 5 is needed for a full tablet packet */ |
118 | unsigned char buf[BUFLEN]; | 118 | unsigned char buf[BUFLEN]; |
@@ -211,7 +211,7 @@ vsxxxaa_smells_like_packet (struct vsxxxaa *mouse, unsigned char type, size_t le | |||
211 | static void | 211 | static void |
212 | vsxxxaa_handle_REL_packet (struct vsxxxaa *mouse, struct pt_regs *regs) | 212 | vsxxxaa_handle_REL_packet (struct vsxxxaa *mouse, struct pt_regs *regs) |
213 | { | 213 | { |
214 | struct input_dev *dev = &mouse->dev; | 214 | struct input_dev *dev = mouse->dev; |
215 | unsigned char *buf = mouse->buf; | 215 | unsigned char *buf = mouse->buf; |
216 | int left, middle, right; | 216 | int left, middle, right; |
217 | int dx, dy; | 217 | int dx, dy; |
@@ -269,7 +269,7 @@ vsxxxaa_handle_REL_packet (struct vsxxxaa *mouse, struct pt_regs *regs) | |||
269 | static void | 269 | static void |
270 | vsxxxaa_handle_ABS_packet (struct vsxxxaa *mouse, struct pt_regs *regs) | 270 | vsxxxaa_handle_ABS_packet (struct vsxxxaa *mouse, struct pt_regs *regs) |
271 | { | 271 | { |
272 | struct input_dev *dev = &mouse->dev; | 272 | struct input_dev *dev = mouse->dev; |
273 | unsigned char *buf = mouse->buf; | 273 | unsigned char *buf = mouse->buf; |
274 | int left, middle, right, touch; | 274 | int left, middle, right, touch; |
275 | int x, y; | 275 | int x, y; |
@@ -323,7 +323,7 @@ vsxxxaa_handle_ABS_packet (struct vsxxxaa *mouse, struct pt_regs *regs) | |||
323 | static void | 323 | static void |
324 | vsxxxaa_handle_POR_packet (struct vsxxxaa *mouse, struct pt_regs *regs) | 324 | vsxxxaa_handle_POR_packet (struct vsxxxaa *mouse, struct pt_regs *regs) |
325 | { | 325 | { |
326 | struct input_dev *dev = &mouse->dev; | 326 | struct input_dev *dev = mouse->dev; |
327 | unsigned char *buf = mouse->buf; | 327 | unsigned char *buf = mouse->buf; |
328 | int left, middle, right; | 328 | int left, middle, right; |
329 | unsigned char error; | 329 | unsigned char error; |
@@ -483,9 +483,9 @@ vsxxxaa_disconnect (struct serio *serio) | |||
483 | { | 483 | { |
484 | struct vsxxxaa *mouse = serio_get_drvdata (serio); | 484 | struct vsxxxaa *mouse = serio_get_drvdata (serio); |
485 | 485 | ||
486 | input_unregister_device (&mouse->dev); | ||
487 | serio_close (serio); | 486 | serio_close (serio); |
488 | serio_set_drvdata (serio, NULL); | 487 | serio_set_drvdata (serio, NULL); |
488 | input_unregister_device (mouse->dev); | ||
489 | kfree (mouse); | 489 | kfree (mouse); |
490 | } | 490 | } |
491 | 491 | ||
@@ -493,61 +493,57 @@ static int | |||
493 | vsxxxaa_connect (struct serio *serio, struct serio_driver *drv) | 493 | vsxxxaa_connect (struct serio *serio, struct serio_driver *drv) |
494 | { | 494 | { |
495 | struct vsxxxaa *mouse; | 495 | struct vsxxxaa *mouse; |
496 | int err; | 496 | struct input_dev *input_dev; |
497 | int err = -ENOMEM; | ||
497 | 498 | ||
498 | if (!(mouse = kmalloc (sizeof (struct vsxxxaa), GFP_KERNEL))) | 499 | mouse = kzalloc (sizeof (struct vsxxxaa), GFP_KERNEL); |
499 | return -ENOMEM; | 500 | input_dev = input_allocate_device (); |
500 | 501 | if (!mouse || !input_dev) | |
501 | memset (mouse, 0, sizeof (struct vsxxxaa)); | 502 | goto fail; |
502 | |||
503 | init_input_dev (&mouse->dev); | ||
504 | set_bit (EV_KEY, mouse->dev.evbit); /* We have buttons */ | ||
505 | set_bit (EV_REL, mouse->dev.evbit); | ||
506 | set_bit (EV_ABS, mouse->dev.evbit); | ||
507 | set_bit (BTN_LEFT, mouse->dev.keybit); /* We have 3 buttons */ | ||
508 | set_bit (BTN_MIDDLE, mouse->dev.keybit); | ||
509 | set_bit (BTN_RIGHT, mouse->dev.keybit); | ||
510 | set_bit (BTN_TOUCH, mouse->dev.keybit); /* ...and Tablet */ | ||
511 | set_bit (REL_X, mouse->dev.relbit); | ||
512 | set_bit (REL_Y, mouse->dev.relbit); | ||
513 | set_bit (ABS_X, mouse->dev.absbit); | ||
514 | set_bit (ABS_Y, mouse->dev.absbit); | ||
515 | |||
516 | mouse->dev.absmin[ABS_X] = 0; | ||
517 | mouse->dev.absmax[ABS_X] = 1023; | ||
518 | mouse->dev.absmin[ABS_Y] = 0; | ||
519 | mouse->dev.absmax[ABS_Y] = 1023; | ||
520 | |||
521 | mouse->dev.private = mouse; | ||
522 | 503 | ||
504 | mouse->dev = input_dev; | ||
505 | mouse->serio = serio; | ||
523 | sprintf (mouse->name, "DEC VSXXX-AA/-GA mouse or VSXXX-AB digitizer"); | 506 | sprintf (mouse->name, "DEC VSXXX-AA/-GA mouse or VSXXX-AB digitizer"); |
524 | sprintf (mouse->phys, "%s/input0", serio->phys); | 507 | sprintf (mouse->phys, "%s/input0", serio->phys); |
525 | mouse->dev.name = mouse->name; | 508 | |
526 | mouse->dev.phys = mouse->phys; | 509 | input_dev->name = mouse->name; |
527 | mouse->dev.id.bustype = BUS_RS232; | 510 | input_dev->phys = mouse->phys; |
528 | mouse->dev.dev = &serio->dev; | 511 | input_dev->id.bustype = BUS_RS232; |
529 | mouse->serio = serio; | 512 | input_dev->cdev.dev = &serio->dev; |
513 | input_dev->private = mouse; | ||
514 | |||
515 | set_bit (EV_KEY, input_dev->evbit); /* We have buttons */ | ||
516 | set_bit (EV_REL, input_dev->evbit); | ||
517 | set_bit (EV_ABS, input_dev->evbit); | ||
518 | set_bit (BTN_LEFT, input_dev->keybit); /* We have 3 buttons */ | ||
519 | set_bit (BTN_MIDDLE, input_dev->keybit); | ||
520 | set_bit (BTN_RIGHT, input_dev->keybit); | ||
521 | set_bit (BTN_TOUCH, input_dev->keybit); /* ...and Tablet */ | ||
522 | set_bit (REL_X, input_dev->relbit); | ||
523 | set_bit (REL_Y, input_dev->relbit); | ||
524 | input_set_abs_params (input_dev, ABS_X, 0, 1023, 0, 0); | ||
525 | input_set_abs_params (input_dev, ABS_Y, 0, 1023, 0, 0); | ||
530 | 526 | ||
531 | serio_set_drvdata (serio, mouse); | 527 | serio_set_drvdata (serio, mouse); |
532 | 528 | ||
533 | err = serio_open (serio, drv); | 529 | err = serio_open (serio, drv); |
534 | if (err) { | 530 | if (err) |
535 | serio_set_drvdata (serio, NULL); | 531 | goto fail; |
536 | kfree (mouse); | ||
537 | return err; | ||
538 | } | ||
539 | 532 | ||
540 | /* | 533 | /* |
541 | * Request selftest. Standard packet format and differential | 534 | * Request selftest. Standard packet format and differential |
542 | * mode will be requested after the device ID'ed successfully. | 535 | * mode will be requested after the device ID'ed successfully. |
543 | */ | 536 | */ |
544 | mouse->serio->write (mouse->serio, 'T'); /* Test */ | 537 | serio->write (serio, 'T'); /* Test */ |
545 | |||
546 | input_register_device (&mouse->dev); | ||
547 | 538 | ||
548 | printk (KERN_INFO "input: %s on %s\n", mouse->name, mouse->phys); | 539 | input_register_device (input_dev); |
549 | 540 | ||
550 | return 0; | 541 | return 0; |
542 | |||
543 | fail: serio_set_drvdata (serio, NULL); | ||
544 | input_free_device (input_dev); | ||
545 | kfree (mouse); | ||
546 | return err; | ||
551 | } | 547 | } |
552 | 548 | ||
553 | static struct serio_device_id vsxxaa_serio_ids[] = { | 549 | static struct serio_device_id vsxxaa_serio_ids[] = { |