input_register_device(9)
π input_register_device β register device with input core π
okay so real talk, bestie, this one is from the Kernel API Manual, section 9, and it's literally the moment your input device becomes official. no cap. π
β¨ SYNOPSIS β¨
int input_register_device (struct input_dev *dev );
πΈ ARGUMENTS πΈ
devβ the device you're registering. yes queen, that's the whole argument. π¦
π DESCRIPTION π
okay so here's the tea. input_register_device registers your device with the input core β like, it's giving "officially introducing your device to the whole friend group" energy. π
bestie, before you can do that, the device must be allocated with input_allocate_device and all its capabilities set up before registering. like, don't show up to the party with no capabilities. that's not the vibe. π
and listen β if the function fails, the device must be freed with input_free_device. periodt. don't leave it hanging in memory. π
once the device has been successfully registered, though? you can unregister it with input_unregister_device. and in that case, input_free_device should not be called. nope. nope nope nope. the vibes would be off. π«
β οΈ ok so this is the part where you need to pay attention, bestie β getting this free/unregister pairing wrong is giving π energy. read it twice. iykyk.
π§ the managed device situation π§
not me about to explain devres... ok so, highkey relevant: this function is also used to register managed input devices (the ones allocated with devm_input_allocate_device). π
those managed input devices need not be explicitly unregistered or freed β their tear down is controlled by the devres infrastructure. it handles it. let it cook. β¨
also worth noting (and this is the iconic part): tear down of managed input devices is internally a 2-step process:
- the registered managed input device is first unregistered, but stays in memory and can still handle
input_eventcalls β although events will not be delivered anywhere. π«₯ - the freeing of the managed input device happens later, when the devres stack is unwound to the point where device allocation was made. β
like, it's alive but it's not delivering, you know? main character in the memory, ghost in the event delivery. πβ¨
π₯ SEE ALSO π₯
- Kernel file
./drivers/input/input.c input_event(9)input_inject_event(9)input_alloc_absinfo(9)input_copy_abs(9)input_grab_device(9)input_release_device(9)input_open_device(9)input_close_device(9)input_scancode_to_scalar(9)input_default_setkeycode(9)input_get_keycode(9)input_set_keycode(9)input_reset_device(9)input_allocate_device(9)devm_input_allocate_device(9)input_free_device(9)input_set_timestamp(9)input_get_timestamp(9)input_set_capability(9)input_enable_softrepeat(9)input_unregister_device(9)input_register_handler(9)input_unregister_handler(9)input_handler_for_each_handle(9)input_register_handle(9)input_unregister_handle(9)input_get_new_minor(9)input_free_minor(9)
mwah π this page lives in ./drivers/input, dated October 2026, and it's input_register_device(9) β go register something iconic, bestie. ππ
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms