public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/7] Input: export input_default_setkeycode
@ 2026-02-22  0:37 Dmitry Torokhov
  2026-02-22  0:37 ` [PATCH 2/7] Input: cros_ec_keyb - add function key support Dmitry Torokhov
                   ` (6 more replies)
  0 siblings, 7 replies; 20+ messages in thread
From: Dmitry Torokhov @ 2026-02-22  0:37 UTC (permalink / raw)
  To: Fabio Baltieri, Benson Leung
  Cc: Guenter Roeck, Simon Glass, Tzung-Bi Shih, linux-input,
	chrome-platform, linux-kernel

From: Fabio Baltieri <fabiobaltieri@chromium.org>

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>
Link: https://patch.msgid.link/20260211173421.1206478-2-fabiobaltieri@chromium.org
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/input/input.c | 23 ++++++++++++++++++++---
 include/linux/input.h |  4 ++++
 2 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/drivers/input/input.c b/drivers/input/input.c
index ceb134044175..9336980ee320 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -861,14 +861,30 @@ static int input_default_getkeycode(struct input_dev *dev,
 	return 0;
 }
 
-static int input_default_setkeycode(struct input_dev *dev,
-				    const struct input_keymap_entry *ke,
-				    unsigned int *old_keycode)
+/**
+ * input_default_setkeycode - default setkeycode method
+ * @dev: input device which keymap is being updated.
+ * @ke: new keymap entry.
+ * @old_keycode: pointer to the location where old keycode should be stored.
+ *
+ * This function is the default implementation of &input_dev.setkeycode()
+ * method. It is typically used when a driver does not provide its own
+ * implementation, but it is also exported so drivers can extend it.
+ *
+ * The function must be called with &input_dev.event_lock held.
+ *
+ * Return: 0 on success, or a negative error code on failure.
+ */
+int input_default_setkeycode(struct input_dev *dev,
+			     const struct input_keymap_entry *ke,
+			     unsigned int *old_keycode)
 {
 	unsigned int index;
 	int error;
 	int i;
 
+	lockdep_assert_held(&dev->event_lock);
+
 	if (!dev->keycodesize)
 		return -EINVAL;
 
@@ -922,6 +938,7 @@ static int input_default_setkeycode(struct input_dev *dev,
 	__set_bit(ke->keycode, dev->keybit);
 	return 0;
 }
+EXPORT_SYMBOL(input_default_setkeycode);
 
 /**
  * input_get_keycode - retrieve keycode currently mapped to a given scancode
diff --git a/include/linux/input.h b/include/linux/input.h
index 7d7cb0593a63..06ca62328db1 100644
--- a/include/linux/input.h
+++ b/include/linux/input.h
@@ -517,6 +517,10 @@ INPUT_GENERATE_ABS_ACCESSORS(res, resolution)
 int input_scancode_to_scalar(const struct input_keymap_entry *ke,
 			     unsigned int *scancode);
 
+int input_default_setkeycode(struct input_dev *dev,
+			     const struct input_keymap_entry *ke,
+			     unsigned int *old_keycode);
+
 int input_get_keycode(struct input_dev *dev, struct input_keymap_entry *ke);
 int input_set_keycode(struct input_dev *dev,
 		      const struct input_keymap_entry *ke);
-- 
2.53.0.345.g96ddfc5eaa-goog


^ permalink raw reply related	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2026-02-23 12:24 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-22  0:37 [PATCH 1/7] Input: export input_default_setkeycode Dmitry Torokhov
2026-02-22  0:37 ` [PATCH 2/7] Input: cros_ec_keyb - add function key support Dmitry Torokhov
2026-02-22 10:46   ` Tzung-Bi Shih
2026-02-23  3:47     ` Dmitry Torokhov
2026-02-23 12:24   ` Fabio Baltieri
2026-02-22  0:37 ` [PATCH 3/7] Input: cros_ec_keyb - use u8 instead of uint8_t Dmitry Torokhov
2026-02-22 10:47   ` Tzung-Bi Shih
2026-02-22  0:37 ` [PATCH 4/7] Input: cros_ec_keyb - use BIT() macro instead of open-coding shifts Dmitry Torokhov
2026-02-22 10:47   ` Tzung-Bi Shih
2026-02-22  0:37 ` [PATCH 5/7] Input: cros_ec_keyb - simplify cros_ec_keyb_work() Dmitry Torokhov
2026-02-22 10:47   ` Tzung-Bi Shih
2026-02-23  3:49     ` Dmitry Torokhov
2026-02-23  4:41       ` Tzung-Bi Shih
2026-02-22  0:37 ` [PATCH 6/7] Input: cros_ec_keyb - do not allocate keyboard state separately Dmitry Torokhov
2026-02-22 10:48   ` Tzung-Bi Shih
2026-02-22  0:37 ` [PATCH 7/7] Input: cros_ec_keyb - factor out column processing Dmitry Torokhov
2026-02-22 10:48   ` Tzung-Bi Shih
2026-02-23  3:51     ` Dmitry Torokhov
2026-02-23  4:40       ` Tzung-Bi Shih
2026-02-22 10:46 ` [PATCH 1/7] Input: export input_default_setkeycode Tzung-Bi Shih

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox