drivers/input/keyboard/atkbd.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
Replace dev_warn() with dev_warn_ratelimited() for unmapped scancode
warnings, matching the existing rate-limited handling of spurious
ACK/NAK events in the same function.
Link: https://bugzilla.kernel.org/show_bug.cgi?id=221214
Signed-off-by: Zhang Heng <zhangheng@kylinos.cn>
---
drivers/input/keyboard/atkbd.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c
index 93650c98206d..26523329040b 100644
--- a/drivers/input/keyboard/atkbd.c
+++ b/drivers/input/keyboard/atkbd.c
@@ -497,13 +497,11 @@ static void atkbd_receive_byte(struct ps2dev *ps2dev, u8 data)
case ATKBD_KEY_NULL:
break;
case ATKBD_KEY_UNKNOWN:
- dev_warn(&serio->dev,
- "Unknown key %s (%s set %d, code %#x on %s).\n",
- atkbd->release ? "released" : "pressed",
- atkbd->translated ? "translated" : "raw",
- atkbd->set, code, serio->phys);
- dev_warn(&serio->dev,
- "Use 'setkeycodes %s%02x <keycode>' to make it known.\n",
- code & 0x80 ? "e0" : "", code & 0x7f);
+ dev_warn_ratelimited(&serio->dev,
+ "Unknown key %s (%s set %d, code %#x on %s); use 'setkeycodes %s%02x <keycode>' to make it known.\n",
+ atkbd->release ? "released" : "pressed",
+ atkbd->translated ? "translated" : "raw",
+ atkbd->set, code, serio->phys,
+ code & 0x80 ? "e0" : "", code & 0x7f);
input_sync(dev);
break;
--
2.25.1
Hi Zhang, On Mon, Sep 21, 2026 at 09:19:34PM +0800, Zhang Heng wrote: > Replace dev_warn() with dev_warn_ratelimited() for unmapped scancode > warnings, matching the existing rate-limited handling of spurious > ACK/NAK events in the same function. I do not think this is needed. Unlike spurious NAK/ACKs pressing keys are initiated by a person and events are naturally rate-limited. The solution is to indeed map the key to do nothing: KEYBOARD_KEY_xx=unknown Userspace ignores KEY_UNKNOWN events and there are no dmesg logs either. Thanks. -- Dmitry
Thanks for your reply. This fix should be handled in userspace. It’s just that for ordinary users, they see a lot of warning messages after pressing keys, so perhaps it would be better to limit the output. I also agree with you that this patch is not necessary—after all, the benefit of this patch is indeed limited. If the patch is not merged, I’m fine with that.
On Tue, Sep 22, 2026 at 10:12:15AM +0800, Zhang Heng wrote: > Thanks for your reply. This fix should be handled in userspace. It’s just > that for ordinary users, they see a lot of warning messages after pressing > keys, so perhaps it would be better to limit the output. I also agree with > you that this patch is not necessary—after all, the benefit of this patch is > indeed limited. If the patch is not merged, I’m fine with that. If you submit a patch to systemd's 60-keyboard.hwdb introducing the mapping you will solve this issue for users. Thanks. -- Dmitry
© 2016 - 2026 Red Hat, Inc.