diff options
| author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2017-09-06 19:34:31 -0400 |
|---|---|---|
| committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2017-10-23 19:32:30 -0400 |
| commit | c06616528f283c05ebcd24a12cf80007efbe8f21 (patch) | |
| tree | e8b701f9f136e298804e3027d6fcdde3a7fb555f /drivers/input | |
| parent | 8e009118a45af30451ff4bbae2b6efd9575d6694 (diff) | |
Input: uinput - fix coding style in uinput_ioctl_handler()
"case"s in switch statement were indented extra level, let's fix that.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Diffstat (limited to 'drivers/input')
| -rw-r--r-- | drivers/input/misc/uinput.c | 231 |
1 files changed, 115 insertions, 116 deletions
diff --git a/drivers/input/misc/uinput.c b/drivers/input/misc/uinput.c index c30704fa1a06..09549eddfcd4 100644 --- a/drivers/input/misc/uinput.c +++ b/drivers/input/misc/uinput.c | |||
| @@ -832,156 +832,155 @@ static long uinput_ioctl_handler(struct file *file, unsigned int cmd, | |||
| 832 | } | 832 | } |
| 833 | 833 | ||
| 834 | switch (cmd) { | 834 | switch (cmd) { |
| 835 | case UI_GET_VERSION: | 835 | case UI_GET_VERSION: |
| 836 | if (put_user(UINPUT_VERSION, | 836 | if (put_user(UINPUT_VERSION, (unsigned int __user *)p)) |
| 837 | (unsigned int __user *)p)) | 837 | retval = -EFAULT; |
| 838 | retval = -EFAULT; | 838 | goto out; |
| 839 | goto out; | ||
| 840 | 839 | ||
| 841 | case UI_DEV_CREATE: | 840 | case UI_DEV_CREATE: |
| 842 | retval = uinput_create_device(udev); | 841 | retval = uinput_create_device(udev); |
| 843 | goto out; | 842 | goto out; |
| 844 | 843 | ||
| 845 | case UI_DEV_DESTROY: | 844 | case UI_DEV_DESTROY: |
| 846 | uinput_destroy_device(udev); | 845 | uinput_destroy_device(udev); |
| 847 | goto out; | 846 | goto out; |
| 848 | 847 | ||
| 849 | case UI_DEV_SETUP: | 848 | case UI_DEV_SETUP: |
| 850 | retval = uinput_dev_setup(udev, p); | 849 | retval = uinput_dev_setup(udev, p); |
| 851 | goto out; | 850 | goto out; |
| 852 | 851 | ||
| 853 | /* UI_ABS_SETUP is handled in the variable size ioctls */ | 852 | /* UI_ABS_SETUP is handled in the variable size ioctls */ |
| 854 | 853 | ||
| 855 | case UI_SET_EVBIT: | 854 | case UI_SET_EVBIT: |
| 856 | retval = uinput_set_bit(arg, evbit, EV_MAX); | 855 | retval = uinput_set_bit(arg, evbit, EV_MAX); |
| 857 | goto out; | 856 | goto out; |
| 858 | 857 | ||
| 859 | case UI_SET_KEYBIT: | 858 | case UI_SET_KEYBIT: |
| 860 | retval = uinput_set_bit(arg, keybit, KEY_MAX); | 859 | retval = uinput_set_bit(arg, keybit, KEY_MAX); |
| 861 | goto out; | 860 | goto out; |
| 862 | 861 | ||
| 863 | case UI_SET_RELBIT: | 862 | case UI_SET_RELBIT: |
| 864 | retval = uinput_set_bit(arg, relbit, REL_MAX); | 863 | retval = uinput_set_bit(arg, relbit, REL_MAX); |
| 865 | goto out; | 864 | goto out; |
| 866 | 865 | ||
| 867 | case UI_SET_ABSBIT: | 866 | case UI_SET_ABSBIT: |
| 868 | retval = uinput_set_bit(arg, absbit, ABS_MAX); | 867 | retval = uinput_set_bit(arg, absbit, ABS_MAX); |
| 869 | goto out; | 868 | goto out; |
| 870 | 869 | ||
| 871 | case UI_SET_MSCBIT: | 870 | case UI_SET_MSCBIT: |
| 872 | retval = uinput_set_bit(arg, mscbit, MSC_MAX); | 871 | retval = uinput_set_bit(arg, mscbit, MSC_MAX); |
| 873 | goto out; | 872 | goto out; |
| 874 | 873 | ||
| 875 | case UI_SET_LEDBIT: | 874 | case UI_SET_LEDBIT: |
| 876 | retval = uinput_set_bit(arg, ledbit, LED_MAX); | 875 | retval = uinput_set_bit(arg, ledbit, LED_MAX); |
| 877 | goto out; | 876 | goto out; |
| 877 | |||
| 878 | case UI_SET_SNDBIT: | ||
| 879 | retval = uinput_set_bit(arg, sndbit, SND_MAX); | ||
| 880 | goto out; | ||
| 881 | |||
| 882 | case UI_SET_FFBIT: | ||
| 883 | retval = uinput_set_bit(arg, ffbit, FF_MAX); | ||
| 884 | goto out; | ||
| 885 | |||
| 886 | case UI_SET_SWBIT: | ||
| 887 | retval = uinput_set_bit(arg, swbit, SW_MAX); | ||
| 888 | goto out; | ||
| 889 | |||
| 890 | case UI_SET_PROPBIT: | ||
| 891 | retval = uinput_set_bit(arg, propbit, INPUT_PROP_MAX); | ||
| 892 | goto out; | ||
| 878 | 893 | ||
| 879 | case UI_SET_SNDBIT: | 894 | case UI_SET_PHYS: |
| 880 | retval = uinput_set_bit(arg, sndbit, SND_MAX); | 895 | if (udev->state == UIST_CREATED) { |
| 896 | retval = -EINVAL; | ||
| 881 | goto out; | 897 | goto out; |
| 898 | } | ||
| 882 | 899 | ||
| 883 | case UI_SET_FFBIT: | 900 | phys = strndup_user(p, 1024); |
| 884 | retval = uinput_set_bit(arg, ffbit, FF_MAX); | 901 | if (IS_ERR(phys)) { |
| 902 | retval = PTR_ERR(phys); | ||
| 885 | goto out; | 903 | goto out; |
| 904 | } | ||
| 905 | |||
| 906 | kfree(udev->dev->phys); | ||
| 907 | udev->dev->phys = phys; | ||
| 908 | goto out; | ||
| 886 | 909 | ||
| 887 | case UI_SET_SWBIT: | 910 | case UI_BEGIN_FF_UPLOAD: |
| 888 | retval = uinput_set_bit(arg, swbit, SW_MAX); | 911 | retval = uinput_ff_upload_from_user(p, &ff_up); |
| 912 | if (retval) | ||
| 889 | goto out; | 913 | goto out; |
| 890 | 914 | ||
| 891 | case UI_SET_PROPBIT: | 915 | req = uinput_request_find(udev, ff_up.request_id); |
| 892 | retval = uinput_set_bit(arg, propbit, INPUT_PROP_MAX); | 916 | if (!req || req->code != UI_FF_UPLOAD || |
| 917 | !req->u.upload.effect) { | ||
| 918 | retval = -EINVAL; | ||
| 893 | goto out; | 919 | goto out; |
| 920 | } | ||
| 894 | 921 | ||
| 895 | case UI_SET_PHYS: | 922 | ff_up.retval = 0; |
| 896 | if (udev->state == UIST_CREATED) { | 923 | ff_up.effect = *req->u.upload.effect; |
| 897 | retval = -EINVAL; | 924 | if (req->u.upload.old) |
| 898 | goto out; | 925 | ff_up.old = *req->u.upload.old; |
| 899 | } | 926 | else |
| 927 | memset(&ff_up.old, 0, sizeof(struct ff_effect)); | ||
| 900 | 928 | ||
| 901 | phys = strndup_user(p, 1024); | 929 | retval = uinput_ff_upload_to_user(p, &ff_up); |
| 902 | if (IS_ERR(phys)) { | 930 | goto out; |
| 903 | retval = PTR_ERR(phys); | ||
| 904 | goto out; | ||
| 905 | } | ||
| 906 | 931 | ||
| 907 | kfree(udev->dev->phys); | 932 | case UI_BEGIN_FF_ERASE: |
| 908 | udev->dev->phys = phys; | 933 | if (copy_from_user(&ff_erase, p, sizeof(ff_erase))) { |
| 934 | retval = -EFAULT; | ||
| 909 | goto out; | 935 | goto out; |
| 936 | } | ||
| 910 | 937 | ||
| 911 | case UI_BEGIN_FF_UPLOAD: | 938 | req = uinput_request_find(udev, ff_erase.request_id); |
| 912 | retval = uinput_ff_upload_from_user(p, &ff_up); | 939 | if (!req || req->code != UI_FF_ERASE) { |
| 913 | if (retval) | 940 | retval = -EINVAL; |
| 914 | goto out; | ||
| 915 | |||
| 916 | req = uinput_request_find(udev, ff_up.request_id); | ||
| 917 | if (!req || req->code != UI_FF_UPLOAD || | ||
| 918 | !req->u.upload.effect) { | ||
| 919 | retval = -EINVAL; | ||
| 920 | goto out; | ||
| 921 | } | ||
| 922 | |||
| 923 | ff_up.retval = 0; | ||
| 924 | ff_up.effect = *req->u.upload.effect; | ||
| 925 | if (req->u.upload.old) | ||
| 926 | ff_up.old = *req->u.upload.old; | ||
| 927 | else | ||
| 928 | memset(&ff_up.old, 0, sizeof(struct ff_effect)); | ||
| 929 | |||
| 930 | retval = uinput_ff_upload_to_user(p, &ff_up); | ||
| 931 | goto out; | 941 | goto out; |
| 942 | } | ||
| 932 | 943 | ||
| 933 | case UI_BEGIN_FF_ERASE: | 944 | ff_erase.retval = 0; |
| 934 | if (copy_from_user(&ff_erase, p, sizeof(ff_erase))) { | 945 | ff_erase.effect_id = req->u.effect_id; |
| 935 | retval = -EFAULT; | 946 | if (copy_to_user(p, &ff_erase, sizeof(ff_erase))) { |
| 936 | goto out; | 947 | retval = -EFAULT; |
| 937 | } | ||
| 938 | |||
| 939 | req = uinput_request_find(udev, ff_erase.request_id); | ||
| 940 | if (!req || req->code != UI_FF_ERASE) { | ||
| 941 | retval = -EINVAL; | ||
| 942 | goto out; | ||
| 943 | } | ||
| 944 | |||
| 945 | ff_erase.retval = 0; | ||
| 946 | ff_erase.effect_id = req->u.effect_id; | ||
| 947 | if (copy_to_user(p, &ff_erase, sizeof(ff_erase))) { | ||
| 948 | retval = -EFAULT; | ||
| 949 | goto out; | ||
| 950 | } | ||
| 951 | |||
| 952 | goto out; | 948 | goto out; |
| 949 | } | ||
| 953 | 950 | ||
| 954 | case UI_END_FF_UPLOAD: | 951 | goto out; |
| 955 | retval = uinput_ff_upload_from_user(p, &ff_up); | ||
| 956 | if (retval) | ||
| 957 | goto out; | ||
| 958 | 952 | ||
| 959 | req = uinput_request_find(udev, ff_up.request_id); | 953 | case UI_END_FF_UPLOAD: |
| 960 | if (!req || req->code != UI_FF_UPLOAD || | 954 | retval = uinput_ff_upload_from_user(p, &ff_up); |
| 961 | !req->u.upload.effect) { | 955 | if (retval) |
| 962 | retval = -EINVAL; | 956 | goto out; |
| 963 | goto out; | ||
| 964 | } | ||
| 965 | 957 | ||
| 966 | req->retval = ff_up.retval; | 958 | req = uinput_request_find(udev, ff_up.request_id); |
| 967 | complete(&req->done); | 959 | if (!req || req->code != UI_FF_UPLOAD || |
| 960 | !req->u.upload.effect) { | ||
| 961 | retval = -EINVAL; | ||
| 968 | goto out; | 962 | goto out; |
| 963 | } | ||
| 969 | 964 | ||
| 970 | case UI_END_FF_ERASE: | 965 | req->retval = ff_up.retval; |
| 971 | if (copy_from_user(&ff_erase, p, sizeof(ff_erase))) { | 966 | complete(&req->done); |
| 972 | retval = -EFAULT; | 967 | goto out; |
| 973 | goto out; | ||
| 974 | } | ||
| 975 | 968 | ||
| 976 | req = uinput_request_find(udev, ff_erase.request_id); | 969 | case UI_END_FF_ERASE: |
| 977 | if (!req || req->code != UI_FF_ERASE) { | 970 | if (copy_from_user(&ff_erase, p, sizeof(ff_erase))) { |
| 978 | retval = -EINVAL; | 971 | retval = -EFAULT; |
| 979 | goto out; | 972 | goto out; |
| 980 | } | 973 | } |
| 981 | 974 | ||
| 982 | req->retval = ff_erase.retval; | 975 | req = uinput_request_find(udev, ff_erase.request_id); |
| 983 | complete(&req->done); | 976 | if (!req || req->code != UI_FF_ERASE) { |
| 977 | retval = -EINVAL; | ||
| 984 | goto out; | 978 | goto out; |
| 979 | } | ||
| 980 | |||
| 981 | req->retval = ff_erase.retval; | ||
| 982 | complete(&req->done); | ||
| 983 | goto out; | ||
| 985 | } | 984 | } |
| 986 | 985 | ||
| 987 | size = _IOC_SIZE(cmd); | 986 | size = _IOC_SIZE(cmd); |
