aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/evdev.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-08-05 11:42:42 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2008-08-08 11:54:58 -0400
commit5402a7349d26875f69c184badf87b88541b1cf6c (patch)
treeff368dabc74cbd09dcb1687a622f8c4e9199f253 /drivers/input/evdev.c
parent8e4ae1017a555662d698ea4616dcfe71b17d3732 (diff)
Input: evdev - split EVIOCGBIT handlig into a separate function
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input/evdev.c')
-rw-r--r--drivers/input/evdev.c44
1 files changed, 24 insertions, 20 deletions
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index 2d65411f6763..ef8c2ed792c3 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -647,6 +647,28 @@ static int str_to_user(const char *str, unsigned int maxlen, void __user *p)
647 return copy_to_user(p, str, len) ? -EFAULT : len; 647 return copy_to_user(p, str, len) ? -EFAULT : len;
648} 648}
649 649
650static int handle_eviocgbit(struct input_dev *dev, unsigned int cmd, void __user *p, int compat_mode)
651{
652 unsigned long *bits;
653 int len;
654
655 switch (_IOC_NR(cmd) & EV_MAX) {
656
657 case 0: bits = dev->evbit; len = EV_MAX; break;
658 case EV_KEY: bits = dev->keybit; len = KEY_MAX; break;
659 case EV_REL: bits = dev->relbit; len = REL_MAX; break;
660 case EV_ABS: bits = dev->absbit; len = ABS_MAX; break;
661 case EV_MSC: bits = dev->mscbit; len = MSC_MAX; break;
662 case EV_LED: bits = dev->ledbit; len = LED_MAX; break;
663 case EV_SND: bits = dev->sndbit; len = SND_MAX; break;
664 case EV_FF: bits = dev->ffbit; len = FF_MAX; break;
665 case EV_SW: bits = dev->swbit; len = SW_MAX; break;
666 default: return -EINVAL;
667 }
668 return bits_to_user(bits, len, _IOC_SIZE(cmd), p, compat_mode);
669}
670
671
650static long evdev_do_ioctl(struct file *file, unsigned int cmd, 672static long evdev_do_ioctl(struct file *file, unsigned int cmd,
651 void __user *p, int compat_mode) 673 void __user *p, int compat_mode)
652{ 674{
@@ -733,26 +755,8 @@ static long evdev_do_ioctl(struct file *file, unsigned int cmd,
733 755
734 if (_IOC_DIR(cmd) == _IOC_READ) { 756 if (_IOC_DIR(cmd) == _IOC_READ) {
735 757
736 if ((_IOC_NR(cmd) & ~EV_MAX) == _IOC_NR(EVIOCGBIT(0, 0))) { 758 if ((_IOC_NR(cmd) & ~EV_MAX) == _IOC_NR(EVIOCGBIT(0, 0)))
737 759 return handle_eviocgbit(dev, cmd, p, compat_mode);
738 unsigned long *bits;
739 int len;
740
741 switch (_IOC_NR(cmd) & EV_MAX) {
742
743 case 0: bits = dev->evbit; len = EV_MAX; break;
744 case EV_KEY: bits = dev->keybit; len = KEY_MAX; break;
745 case EV_REL: bits = dev->relbit; len = REL_MAX; break;
746 case EV_ABS: bits = dev->absbit; len = ABS_MAX; break;
747 case EV_MSC: bits = dev->mscbit; len = MSC_MAX; break;
748 case EV_LED: bits = dev->ledbit; len = LED_MAX; break;
749 case EV_SND: bits = dev->sndbit; len = SND_MAX; break;
750 case EV_FF: bits = dev->ffbit; len = FF_MAX; break;
751 case EV_SW: bits = dev->swbit; len = SW_MAX; break;
752 default: return -EINVAL;
753 }
754 return bits_to_user(bits, len, _IOC_SIZE(cmd), p, compat_mode);
755 }
756 760
757 if (_IOC_NR(cmd) == _IOC_NR(EVIOCGKEY(0))) 761 if (_IOC_NR(cmd) == _IOC_NR(EVIOCGKEY(0)))
758 return bits_to_user(dev->key, KEY_MAX, _IOC_SIZE(cmd), 762 return bits_to_user(dev->key, KEY_MAX, _IOC_SIZE(cmd),