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.

Input: export input_default_setkeycode

Export input_default_setkeycode so that a driver can set a custom
setkeycode handler to take some driver specific action but still call
the default handler at some point.

Signed-off-by: Fabio Baltieri <fabiobaltieri@chromium.org>
Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Link: https://patch.msgid.link/20260222003717.471977-1-dmitry.torokhov@gmail.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

Fabio Baltieri and committed by
Dmitry Torokhov
3d35d411 de716275

+24 -3
+20 -3
drivers/input/input.c
··· 800 800 return 0; 801 801 } 802 802 803 - static int input_default_setkeycode(struct input_dev *dev, 804 - const struct input_keymap_entry *ke, 805 - unsigned int *old_keycode) 803 + /** 804 + * input_default_setkeycode - default setkeycode method 805 + * @dev: input device which keymap is being updated. 806 + * @ke: new keymap entry. 807 + * @old_keycode: pointer to the location where old keycode should be stored. 808 + * 809 + * This function is the default implementation of &input_dev.setkeycode() 810 + * method. It is typically used when a driver does not provide its own 811 + * implementation, but it is also exported so drivers can extend it. 812 + * 813 + * The function must be called with &input_dev.event_lock held. 814 + * 815 + * Return: 0 on success, or a negative error code on failure. 816 + */ 817 + int input_default_setkeycode(struct input_dev *dev, 818 + const struct input_keymap_entry *ke, 819 + unsigned int *old_keycode) 806 820 { 807 821 unsigned int index; 808 822 int error; 809 823 int i; 824 + 825 + lockdep_assert_held(&dev->event_lock); 810 826 811 827 if (!dev->keycodesize) 812 828 return -EINVAL; ··· 877 861 __set_bit(ke->keycode, dev->keybit); 878 862 return 0; 879 863 } 864 + EXPORT_SYMBOL(input_default_setkeycode); 880 865 881 866 /** 882 867 * input_get_keycode - retrieve keycode currently mapped to a given scancode
+4
include/linux/input.h
··· 517 517 int input_scancode_to_scalar(const struct input_keymap_entry *ke, 518 518 unsigned int *scancode); 519 519 520 + int input_default_setkeycode(struct input_dev *dev, 521 + const struct input_keymap_entry *ke, 522 + unsigned int *old_keycode); 523 + 520 524 int input_get_keycode(struct input_dev *dev, struct input_keymap_entry *ke); 521 525 int input_set_keycode(struct input_dev *dev, 522 526 const struct input_keymap_entry *ke);