diff options
author | Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com> | 2009-05-09 19:08:04 -0400 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2009-05-11 03:11:43 -0400 |
commit | 3d5cb60ef3042ac479dab82e5a945966a0d54d53 (patch) | |
tree | 08793f3c88b8d218fc934b3769bcc4e2aee993c9 /drivers/input | |
parent | 7e044e056a6aa0dc695db50461d7b326fde15e8b (diff) |
Input: simplify name handling for certain input handles
For evdev, joydev and mousedev, instead of having a separate character array
holding name of the handle, use struct devce's name which is the same.
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input')
-rw-r--r-- | drivers/input/evdev.c | 9 | ||||
-rw-r--r-- | drivers/input/joydev.c | 14 | ||||
-rw-r--r-- | drivers/input/mousedev.c | 9 |
3 files changed, 14 insertions, 18 deletions
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c index 7a7a026ba712..c238116400b3 100644 --- a/drivers/input/evdev.c +++ b/drivers/input/evdev.c | |||
@@ -25,7 +25,6 @@ struct evdev { | |||
25 | int exist; | 25 | int exist; |
26 | int open; | 26 | int open; |
27 | int minor; | 27 | int minor; |
28 | char name[16]; | ||
29 | struct input_handle handle; | 28 | struct input_handle handle; |
30 | wait_queue_head_t wait; | 29 | wait_queue_head_t wait; |
31 | struct evdev_client *grab; | 30 | struct evdev_client *grab; |
@@ -609,7 +608,8 @@ static long evdev_do_ioctl(struct file *file, unsigned int cmd, | |||
609 | p, compat_mode); | 608 | p, compat_mode); |
610 | 609 | ||
611 | if (_IOC_NR(cmd) == _IOC_NR(EVIOCGNAME(0))) | 610 | if (_IOC_NR(cmd) == _IOC_NR(EVIOCGNAME(0))) |
612 | return str_to_user(dev->name, _IOC_SIZE(cmd), p); | 611 | return str_to_user(dev_name(&evdev->dev), |
612 | _IOC_SIZE(cmd), p); | ||
613 | 613 | ||
614 | if (_IOC_NR(cmd) == _IOC_NR(EVIOCGPHYS(0))) | 614 | if (_IOC_NR(cmd) == _IOC_NR(EVIOCGPHYS(0))) |
615 | return str_to_user(dev->phys, _IOC_SIZE(cmd), p); | 615 | return str_to_user(dev->phys, _IOC_SIZE(cmd), p); |
@@ -807,16 +807,15 @@ static int evdev_connect(struct input_handler *handler, struct input_dev *dev, | |||
807 | mutex_init(&evdev->mutex); | 807 | mutex_init(&evdev->mutex); |
808 | init_waitqueue_head(&evdev->wait); | 808 | init_waitqueue_head(&evdev->wait); |
809 | 809 | ||
810 | snprintf(evdev->name, sizeof(evdev->name), "event%d", minor); | 810 | dev_set_name(&evdev->dev, "event%d", minor); |
811 | evdev->exist = 1; | 811 | evdev->exist = 1; |
812 | evdev->minor = minor; | 812 | evdev->minor = minor; |
813 | 813 | ||
814 | evdev->handle.dev = input_get_device(dev); | 814 | evdev->handle.dev = input_get_device(dev); |
815 | evdev->handle.name = evdev->name; | 815 | evdev->handle.name = dev_name(&evdev->dev); |
816 | evdev->handle.handler = handler; | 816 | evdev->handle.handler = handler; |
817 | evdev->handle.private = evdev; | 817 | evdev->handle.private = evdev; |
818 | 818 | ||
819 | dev_set_name(&evdev->dev, evdev->name); | ||
820 | evdev->dev.devt = MKDEV(INPUT_MAJOR, EVDEV_MINOR_BASE + minor); | 819 | evdev->dev.devt = MKDEV(INPUT_MAJOR, EVDEV_MINOR_BASE + minor); |
821 | evdev->dev.class = &input_class; | 820 | evdev->dev.class = &input_class; |
822 | evdev->dev.parent = &dev->dev; | 821 | evdev->dev.parent = &dev->dev; |
diff --git a/drivers/input/joydev.c b/drivers/input/joydev.c index 4224f0112849..15bb41195bea 100644 --- a/drivers/input/joydev.c +++ b/drivers/input/joydev.c | |||
@@ -39,7 +39,6 @@ struct joydev { | |||
39 | int exist; | 39 | int exist; |
40 | int open; | 40 | int open; |
41 | int minor; | 41 | int minor; |
42 | char name[16]; | ||
43 | struct input_handle handle; | 42 | struct input_handle handle; |
44 | wait_queue_head_t wait; | 43 | wait_queue_head_t wait; |
45 | struct list_head client_list; | 44 | struct list_head client_list; |
@@ -537,12 +536,14 @@ static int joydev_ioctl_common(struct joydev *joydev, | |||
537 | default: | 536 | default: |
538 | if ((cmd & ~IOCSIZE_MASK) == JSIOCGNAME(0)) { | 537 | if ((cmd & ~IOCSIZE_MASK) == JSIOCGNAME(0)) { |
539 | int len; | 538 | int len; |
540 | if (!dev->name) | 539 | const char *name = dev_name(&dev->dev); |
540 | |||
541 | if (!name) | ||
541 | return 0; | 542 | return 0; |
542 | len = strlen(dev->name) + 1; | 543 | len = strlen(name) + 1; |
543 | if (len > _IOC_SIZE(cmd)) | 544 | if (len > _IOC_SIZE(cmd)) |
544 | len = _IOC_SIZE(cmd); | 545 | len = _IOC_SIZE(cmd); |
545 | if (copy_to_user(argp, dev->name, len)) | 546 | if (copy_to_user(argp, name, len)) |
546 | return -EFAULT; | 547 | return -EFAULT; |
547 | return len; | 548 | return len; |
548 | } | 549 | } |
@@ -742,13 +743,13 @@ static int joydev_connect(struct input_handler *handler, struct input_dev *dev, | |||
742 | mutex_init(&joydev->mutex); | 743 | mutex_init(&joydev->mutex); |
743 | init_waitqueue_head(&joydev->wait); | 744 | init_waitqueue_head(&joydev->wait); |
744 | 745 | ||
745 | snprintf(joydev->name, sizeof(joydev->name), "js%d", minor); | 746 | dev_set_name(&joydev->dev, "js%d", minor); |
746 | joydev->exist = 1; | 747 | joydev->exist = 1; |
747 | joydev->minor = minor; | 748 | joydev->minor = minor; |
748 | 749 | ||
749 | joydev->exist = 1; | 750 | joydev->exist = 1; |
750 | joydev->handle.dev = input_get_device(dev); | 751 | joydev->handle.dev = input_get_device(dev); |
751 | joydev->handle.name = joydev->name; | 752 | joydev->handle.name = dev_name(&joydev->dev); |
752 | joydev->handle.handler = handler; | 753 | joydev->handle.handler = handler; |
753 | joydev->handle.private = joydev; | 754 | joydev->handle.private = joydev; |
754 | 755 | ||
@@ -797,7 +798,6 @@ static int joydev_connect(struct input_handler *handler, struct input_dev *dev, | |||
797 | } | 798 | } |
798 | } | 799 | } |
799 | 800 | ||
800 | dev_set_name(&joydev->dev, joydev->name); | ||
801 | joydev->dev.devt = MKDEV(INPUT_MAJOR, JOYDEV_MINOR_BASE + minor); | 801 | joydev->dev.devt = MKDEV(INPUT_MAJOR, JOYDEV_MINOR_BASE + minor); |
802 | joydev->dev.class = &input_class; | 802 | joydev->dev.class = &input_class; |
803 | joydev->dev.parent = &dev->dev; | 803 | joydev->dev.parent = &dev->dev; |
diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c index 17fd6d46d082..966b8868f792 100644 --- a/drivers/input/mousedev.c +++ b/drivers/input/mousedev.c | |||
@@ -60,7 +60,6 @@ struct mousedev { | |||
60 | int exist; | 60 | int exist; |
61 | int open; | 61 | int open; |
62 | int minor; | 62 | int minor; |
63 | char name[16]; | ||
64 | struct input_handle handle; | 63 | struct input_handle handle; |
65 | wait_queue_head_t wait; | 64 | wait_queue_head_t wait; |
66 | struct list_head client_list; | 65 | struct list_head client_list; |
@@ -863,19 +862,17 @@ static struct mousedev *mousedev_create(struct input_dev *dev, | |||
863 | init_waitqueue_head(&mousedev->wait); | 862 | init_waitqueue_head(&mousedev->wait); |
864 | 863 | ||
865 | if (minor == MOUSEDEV_MIX) | 864 | if (minor == MOUSEDEV_MIX) |
866 | strlcpy(mousedev->name, "mice", sizeof(mousedev->name)); | 865 | dev_set_name(&mousedev->dev, "mice"); |
867 | else | 866 | else |
868 | snprintf(mousedev->name, sizeof(mousedev->name), | 867 | dev_set_name(&mousedev->dev, "mouse%d", minor); |
869 | "mouse%d", minor); | ||
870 | 868 | ||
871 | mousedev->minor = minor; | 869 | mousedev->minor = minor; |
872 | mousedev->exist = 1; | 870 | mousedev->exist = 1; |
873 | mousedev->handle.dev = input_get_device(dev); | 871 | mousedev->handle.dev = input_get_device(dev); |
874 | mousedev->handle.name = mousedev->name; | 872 | mousedev->handle.name = dev_name(&mousedev->dev); |
875 | mousedev->handle.handler = handler; | 873 | mousedev->handle.handler = handler; |
876 | mousedev->handle.private = mousedev; | 874 | mousedev->handle.private = mousedev; |
877 | 875 | ||
878 | dev_set_name(&mousedev->dev, mousedev->name); | ||
879 | mousedev->dev.class = &input_class; | 876 | mousedev->dev.class = &input_class; |
880 | if (dev) | 877 | if (dev) |
881 | mousedev->dev.parent = &dev->dev; | 878 | mousedev->dev.parent = &dev->dev; |