Skip to content

input_register_device()

Purpose

Registers an input device with the Linux input subsystem.

#include <linux/input.h>

Prototype

int input_register_device(struct input_dev *dev);

Parameters

  • dev: initialized input device.

Return Value

  • 0 on success.
  • Negative errno on failure.

Minimal Example

input_set_capability(input, EV_KEY, KEY_ENTER);

ret = input_register_device(input);
if (ret)
    return ret;

Common Pitfalls

  • Set device capabilities before calling this function.
  • After successful registration, the input core owns the normal input device lifetime.
  • With devm_input_allocate_device(), cleanup is managed by the device core.