drivers/input/input.c
Source file repositories/reference/linux-study-clean/drivers/input/input.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/input.c- Extension
.c- Size
- 72056 bytes
- Lines
- 2771
- Domain
- Driver Families
- Bucket
- drivers/input
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/export.hlinux/init.hlinux/types.hlinux/idr.hlinux/input/mt.hlinux/module.hlinux/slab.hlinux/random.hlinux/major.hlinux/proc_fs.hlinux/sched.hlinux/seq_file.hlinux/pm.hlinux/poll.hlinux/device.hlinux/kstrtox.hlinux/mutex.hlinux/rcupdate.hinput-compat.hinput-core-private.hinput-poller.h
Detected Declarations
struct input_seq_statestruct input_devresfunction is_event_supportedfunction input_defuzz_abs_eventfunction input_start_autorepeatfunction input_stop_autorepeatfunction input_pass_valuesfunction scoped_guardfunction list_for_each_entry_rcufunction input_handle_abs_eventfunction input_get_dispositionfunction input_event_disposefunction input_handle_eventfunction input_eventfunction input_inject_eventfunction input_alloc_absinfofunction input_set_abs_paramsfunction input_copy_absfunction input_grab_devicefunction scoped_cond_guardfunction __input_release_devicefunction startfunction input_open_devicefunction scoped_cond_guardfunction input_flush_devicefunction scoped_cond_guardfunction input_close_devicefunction input_dev_release_keysfunction input_disconnect_devicefunction input_scancode_to_scalarfunction input_fetch_keycodefunction input_default_getkeycodefunction input_default_setkeycodefunction input_get_keycodefunction input_set_keycodefunction __test_and_clear_bitfunction input_match_device_idfunction input_attach_handlerfunction input_wakeup_procfs_readersfunction input_proc_devices_pollfunction input_seq_stopfunction input_seq_print_bitmapfunction input_devices_seq_showfunction input_proc_devices_openfunction input_handlers_seq_showfunction input_proc_handlers_openfunction input_proc_initfunction input_proc_exit
Annotated Snippet
error = device_add(&dev->dev);
if (error)
goto err_devres_free;
path = kobject_get_path(&dev->dev.kobj, GFP_KERNEL);
pr_info("%s as %s\n",
dev->name ? dev->name : "Unspecified device",
path ? path : "N/A");
kfree(path);
error = -EINTR;
scoped_cond_guard(mutex_intr, goto err_device_del, &input_mutex) {
list_add_tail(&dev->node, &input_dev_list);
list_for_each_entry(handler, &input_handler_list, node)
input_attach_handler(dev, handler);
input_wakeup_procfs_readers();
}
if (dev->devres_managed) {
dev_dbg(dev->dev.parent, "%s: registering %s with devres.\n",
__func__, dev_name(&dev->dev));
devres_add(dev->dev.parent, devres);
}
return 0;
err_device_del:
device_del(&dev->dev);
err_devres_free:
devres_free(devres);
return error;
}
EXPORT_SYMBOL(input_register_device);
/**
* input_unregister_device - unregister previously registered device
* @dev: device to be unregistered
*
* This function unregisters an input device. Once device is unregistered
* the caller should not try to access it as it may get freed at any moment.
*/
void input_unregister_device(struct input_dev *dev)
{
if (dev->devres_managed) {
WARN_ON(devres_destroy(dev->dev.parent,
devm_input_device_unregister,
devm_input_device_match,
dev));
__input_unregister_device(dev);
/*
* We do not do input_put_device() here because it will be done
* when 2nd devres fires up.
*/
} else {
__input_unregister_device(dev);
input_put_device(dev);
}
}
EXPORT_SYMBOL(input_unregister_device);
static int input_handler_check_methods(const struct input_handler *handler)
{
int count = 0;
if (handler->filter)
count++;
if (handler->events)
count++;
if (handler->event)
count++;
if (count > 1) {
pr_err("%s: only one event processing method can be defined (%s)\n",
__func__, handler->name);
return -EINVAL;
}
return 0;
}
/**
* input_register_handler - register a new input handler
* @handler: handler to be registered
*
* This function registers a new input handler (interface) for input
* devices in the system and attaches it to all input devices that
* are compatible with the handler.
*/
int input_register_handler(struct input_handler *handler)
Annotation
- Immediate include surface: `linux/export.h`, `linux/init.h`, `linux/types.h`, `linux/idr.h`, `linux/input/mt.h`, `linux/module.h`, `linux/slab.h`, `linux/random.h`.
- Detected declarations: `struct input_seq_state`, `struct input_devres`, `function is_event_supported`, `function input_defuzz_abs_event`, `function input_start_autorepeat`, `function input_stop_autorepeat`, `function input_pass_values`, `function scoped_guard`, `function list_for_each_entry_rcu`, `function input_handle_abs_event`.
- Atlas domain: Driver Families / drivers/input.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.