Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input

Pull input fixes from Dmitry Torokhov:
"Just a few small fixups here"

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input:
Input: imx_sc_key - only take the valid data from SCU firmware as key state
Input: add safety guards to input_set_keycode()
Input: input_event - fix struct padding on sparc64
Input: uinput - always report EPOLLOUT

+43 -25
+7 -7
drivers/input/evdev.c
··· 224 224 */ 225 225 client->tail = (client->head - 2) & (client->bufsize - 1); 226 226 227 - client->buffer[client->tail].input_event_sec = 228 - event->input_event_sec; 229 - client->buffer[client->tail].input_event_usec = 230 - event->input_event_usec; 231 - client->buffer[client->tail].type = EV_SYN; 232 - client->buffer[client->tail].code = SYN_DROPPED; 233 - client->buffer[client->tail].value = 0; 227 + client->buffer[client->tail] = (struct input_event) { 228 + .input_event_sec = event->input_event_sec, 229 + .input_event_usec = event->input_event_usec, 230 + .type = EV_SYN, 231 + .code = SYN_DROPPED, 232 + .value = 0, 233 + }; 234 234 235 235 client->packet_head = client->tail; 236 236 }
+16 -10
drivers/input/input.c
··· 878 878 } 879 879 } 880 880 881 - __clear_bit(*old_keycode, dev->keybit); 882 - __set_bit(ke->keycode, dev->keybit); 883 - 884 - for (i = 0; i < dev->keycodemax; i++) { 885 - if (input_fetch_keycode(dev, i) == *old_keycode) { 886 - __set_bit(*old_keycode, dev->keybit); 887 - break; /* Setting the bit twice is useless, so break */ 881 + if (*old_keycode <= KEY_MAX) { 882 + __clear_bit(*old_keycode, dev->keybit); 883 + for (i = 0; i < dev->keycodemax; i++) { 884 + if (input_fetch_keycode(dev, i) == *old_keycode) { 885 + __set_bit(*old_keycode, dev->keybit); 886 + /* Setting the bit twice is useless, so break */ 887 + break; 888 + } 888 889 } 889 890 } 890 891 892 + __set_bit(ke->keycode, dev->keybit); 891 893 return 0; 892 894 } 893 895 ··· 945 943 * Simulate keyup event if keycode is not present 946 944 * in the keymap anymore 947 945 */ 948 - if (test_bit(EV_KEY, dev->evbit) && 949 - !is_event_supported(old_keycode, dev->keybit, KEY_MAX) && 950 - __test_and_clear_bit(old_keycode, dev->key)) { 946 + if (old_keycode > KEY_MAX) { 947 + dev_warn(dev->dev.parent ?: &dev->dev, 948 + "%s: got too big old keycode %#x\n", 949 + __func__, old_keycode); 950 + } else if (test_bit(EV_KEY, dev->evbit) && 951 + !is_event_supported(old_keycode, dev->keybit, KEY_MAX) && 952 + __test_and_clear_bit(old_keycode, dev->key)) { 951 953 struct input_value vals[] = { 952 954 { EV_KEY, old_keycode, 0 }, 953 955 input_value_sync
+7 -1
drivers/input/keyboard/imx_sc_key.c
··· 78 78 return; 79 79 } 80 80 81 - state = (bool)msg.state; 81 + /* 82 + * The response data from SCU firmware is 4 bytes, 83 + * but ONLY the first byte is the key state, other 84 + * 3 bytes could be some dirty data, so we should 85 + * ONLY take the first byte as key state. 86 + */ 87 + state = (bool)(msg.state & 0xff); 82 88 83 89 if (state ^ priv->keystate) { 84 90 priv->keystate = state;
+12 -7
drivers/input/misc/uinput.c
··· 74 74 struct uinput_device *udev = input_get_drvdata(dev); 75 75 struct timespec64 ts; 76 76 77 - udev->buff[udev->head].type = type; 78 - udev->buff[udev->head].code = code; 79 - udev->buff[udev->head].value = value; 80 77 ktime_get_ts64(&ts); 81 - udev->buff[udev->head].input_event_sec = ts.tv_sec; 82 - udev->buff[udev->head].input_event_usec = ts.tv_nsec / NSEC_PER_USEC; 78 + 79 + udev->buff[udev->head] = (struct input_event) { 80 + .input_event_sec = ts.tv_sec, 81 + .input_event_usec = ts.tv_nsec / NSEC_PER_USEC, 82 + .type = type, 83 + .code = code, 84 + .value = value, 85 + }; 86 + 83 87 udev->head = (udev->head + 1) % UINPUT_BUFFER_SIZE; 84 88 85 89 wake_up_interruptible(&udev->waitq); ··· 693 689 static __poll_t uinput_poll(struct file *file, poll_table *wait) 694 690 { 695 691 struct uinput_device *udev = file->private_data; 692 + __poll_t mask = EPOLLOUT | EPOLLWRNORM; /* uinput is always writable */ 696 693 697 694 poll_wait(file, &udev->waitq, wait); 698 695 699 696 if (udev->head != udev->tail) 700 - return EPOLLIN | EPOLLRDNORM; 697 + mask |= EPOLLIN | EPOLLRDNORM; 701 698 702 - return EPOLLOUT | EPOLLWRNORM; 699 + return mask; 703 700 } 704 701 705 702 static int uinput_release(struct inode *inode, struct file *file)
+1
include/uapi/linux/input.h
··· 34 34 __kernel_ulong_t __sec; 35 35 #if defined(__sparc__) && defined(__arch64__) 36 36 unsigned int __usec; 37 + unsigned int __pad; 37 38 #else 38 39 __kernel_ulong_t __usec; 39 40 #endif