diff options
Diffstat (limited to 'drivers/input/evdev.c')
-rw-r--r-- | drivers/input/evdev.c | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c index 4bf48188cc91..6439f378f6cc 100644 --- a/drivers/input/evdev.c +++ b/drivers/input/evdev.c | |||
@@ -391,8 +391,10 @@ static long evdev_ioctl_handler(struct file *file, unsigned int cmd, | |||
391 | struct evdev *evdev = list->evdev; | 391 | struct evdev *evdev = list->evdev; |
392 | struct input_dev *dev = evdev->handle.dev; | 392 | struct input_dev *dev = evdev->handle.dev; |
393 | struct input_absinfo abs; | 393 | struct input_absinfo abs; |
394 | struct ff_effect effect; | ||
394 | int __user *ip = (int __user *)p; | 395 | int __user *ip = (int __user *)p; |
395 | int i, t, u, v; | 396 | int i, t, u, v; |
397 | int error; | ||
396 | 398 | ||
397 | if (!evdev->exist) | 399 | if (!evdev->exist) |
398 | return -ENODEV; | 400 | return -ENODEV; |
@@ -460,27 +462,22 @@ static long evdev_ioctl_handler(struct file *file, unsigned int cmd, | |||
460 | return 0; | 462 | return 0; |
461 | 463 | ||
462 | case EVIOCSFF: | 464 | case EVIOCSFF: |
463 | if (dev->upload_effect) { | 465 | if (copy_from_user(&effect, p, sizeof(effect))) |
464 | struct ff_effect effect; | 466 | return -EFAULT; |
465 | int err; | ||
466 | |||
467 | if (copy_from_user(&effect, p, sizeof(effect))) | ||
468 | return -EFAULT; | ||
469 | err = dev->upload_effect(dev, &effect); | ||
470 | if (put_user(effect.id, &(((struct ff_effect __user *)p)->id))) | ||
471 | return -EFAULT; | ||
472 | return err; | ||
473 | } else | ||
474 | return -ENOSYS; | ||
475 | 467 | ||
476 | case EVIOCRMFF: | 468 | error = input_ff_upload(dev, &effect, file); |
477 | if (!dev->erase_effect) | ||
478 | return -ENOSYS; | ||
479 | 469 | ||
480 | return dev->erase_effect(dev, (int)(unsigned long) p); | 470 | if (put_user(effect.id, &(((struct ff_effect __user *)p)->id))) |
471 | return -EFAULT; | ||
472 | |||
473 | return error; | ||
474 | |||
475 | case EVIOCRMFF: | ||
476 | return input_ff_erase(dev, (int)(unsigned long) p, file); | ||
481 | 477 | ||
482 | case EVIOCGEFFECTS: | 478 | case EVIOCGEFFECTS: |
483 | if (put_user(dev->ff_effects_max, ip)) | 479 | i = test_bit(EV_FF, dev->evbit) ? dev->ff->max_effects : 0; |
480 | if (put_user(i, ip)) | ||
484 | return -EFAULT; | 481 | return -EFAULT; |
485 | return 0; | 482 | return 0; |
486 | 483 | ||
@@ -604,7 +601,7 @@ static long evdev_ioctl_compat(struct file *file, unsigned int cmd, unsigned lon | |||
604 | } | 601 | } |
605 | #endif | 602 | #endif |
606 | 603 | ||
607 | static struct file_operations evdev_fops = { | 604 | static const struct file_operations evdev_fops = { |
608 | .owner = THIS_MODULE, | 605 | .owner = THIS_MODULE, |
609 | .read = evdev_read, | 606 | .read = evdev_read, |
610 | .write = evdev_write, | 607 | .write = evdev_write, |
@@ -619,7 +616,8 @@ static struct file_operations evdev_fops = { | |||
619 | .flush = evdev_flush | 616 | .flush = evdev_flush |
620 | }; | 617 | }; |
621 | 618 | ||
622 | static struct input_handle *evdev_connect(struct input_handler *handler, struct input_dev *dev, struct input_device_id *id) | 619 | static struct input_handle *evdev_connect(struct input_handler *handler, struct input_dev *dev, |
620 | const struct input_device_id *id) | ||
623 | { | 621 | { |
624 | struct evdev *evdev; | 622 | struct evdev *evdev; |
625 | struct class_device *cdev; | 623 | struct class_device *cdev; |
@@ -669,6 +667,7 @@ static void evdev_disconnect(struct input_handle *handle) | |||
669 | evdev->exist = 0; | 667 | evdev->exist = 0; |
670 | 668 | ||
671 | if (evdev->open) { | 669 | if (evdev->open) { |
670 | input_flush_device(handle, NULL); | ||
672 | input_close_device(handle); | 671 | input_close_device(handle); |
673 | wake_up_interruptible(&evdev->wait); | 672 | wake_up_interruptible(&evdev->wait); |
674 | list_for_each_entry(list, &evdev->list, node) | 673 | list_for_each_entry(list, &evdev->list, node) |
@@ -677,7 +676,7 @@ static void evdev_disconnect(struct input_handle *handle) | |||
677 | evdev_free(evdev); | 676 | evdev_free(evdev); |
678 | } | 677 | } |
679 | 678 | ||
680 | static struct input_device_id evdev_ids[] = { | 679 | static const struct input_device_id evdev_ids[] = { |
681 | { .driver_info = 1 }, /* Matches all devices */ | 680 | { .driver_info = 1 }, /* Matches all devices */ |
682 | { }, /* Terminating zero entry */ | 681 | { }, /* Terminating zero entry */ |
683 | }; | 682 | }; |
@@ -696,8 +695,7 @@ static struct input_handler evdev_handler = { | |||
696 | 695 | ||
697 | static int __init evdev_init(void) | 696 | static int __init evdev_init(void) |
698 | { | 697 | { |
699 | input_register_handler(&evdev_handler); | 698 | return input_register_handler(&evdev_handler); |
700 | return 0; | ||
701 | } | 699 | } |
702 | 700 | ||
703 | static void __exit evdev_exit(void) | 701 | static void __exit evdev_exit(void) |