drivers/input/serio/serio.c
Source file repositories/reference/linux-study-clean/drivers/input/serio/serio.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/serio/serio.c- Extension
.c- Size
- 23625 bytes
- Lines
- 1018
- Domain
- Driver Families
- Bucket
- drivers/input
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/stddef.hlinux/module.hlinux/serio.hlinux/errno.hlinux/sched.hlinux/slab.hlinux/workqueue.hlinux/mutex.h
Detected Declarations
struct serio_eventenum serio_event_typefunction serio_connect_driverfunction serio_reconnect_driverfunction serio_disconnect_driverfunction serio_match_portfunction serio_bind_driverfunction serio_find_driverfunction serio_free_eventfunction serio_remove_duplicate_eventsfunction list_for_each_entry_safefunction serio_handle_eventfunction serio_queue_eventfunction serio_remove_pending_eventsfunction list_for_each_entry_safefunction portfunction list_for_each_entryfunction serio_show_descriptionfunction modalias_showfunction type_showfunction proto_showfunction id_showfunction extra_showfunction drvctl_storefunction scoped_cond_guardfunction serio_show_bind_modefunction serio_set_bind_modefunction firmware_id_showfunction serio_release_portfunction serio_init_portfunction serio_add_portfunction serio_destroy_portfunction portfunction childrenfunction serio_disconnect_portfunction serio_rescanfunction serio_reconnectfunction __serio_register_portfunction serio_unregister_portfunction serio_unregister_child_portfunction list_for_each_entry_safefunction description_showfunction bind_mode_showfunction bind_mode_storefunction serio_driver_probefunction serio_driver_removefunction serio_cleanupfunction serio_shutdown
Annotated Snippet
struct device_driver *drv;
int error;
scoped_cond_guard(mutex_intr, return -EINTR, &serio_mutex) {
if (!strncmp(buf, "none", count)) {
serio_disconnect_port(serio);
} else if (!strncmp(buf, "reconnect", count)) {
serio_reconnect_subtree(serio);
} else if (!strncmp(buf, "rescan", count)) {
serio_disconnect_port(serio);
serio_find_driver(serio);
serio_remove_duplicate_events(serio, SERIO_RESCAN_PORT);
} else if ((drv = driver_find(buf, &serio_bus)) != NULL) {
serio_disconnect_port(serio);
error = serio_bind_driver(serio, to_serio_driver(drv));
serio_remove_duplicate_events(serio, SERIO_RESCAN_PORT);
if (error)
return error;
} else {
return -EINVAL;
}
}
return count;
}
static ssize_t serio_show_bind_mode(struct device *dev, struct device_attribute *attr, char *buf)
{
struct serio *serio = to_serio_port(dev);
return sprintf(buf, "%s\n", serio->manual_bind ? "manual" : "auto");
}
static ssize_t serio_set_bind_mode(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{
struct serio *serio = to_serio_port(dev);
int retval;
retval = count;
if (!strncmp(buf, "manual", count)) {
serio->manual_bind = true;
} else if (!strncmp(buf, "auto", count)) {
serio->manual_bind = false;
} else {
retval = -EINVAL;
}
return retval;
}
static ssize_t firmware_id_show(struct device *dev, struct device_attribute *attr, char *buf)
{
struct serio *serio = to_serio_port(dev);
return sprintf(buf, "%s\n", serio->firmware_id);
}
static DEVICE_ATTR_RO(type);
static DEVICE_ATTR_RO(proto);
static DEVICE_ATTR_RO(id);
static DEVICE_ATTR_RO(extra);
static struct attribute *serio_device_id_attrs[] = {
&dev_attr_type.attr,
&dev_attr_proto.attr,
&dev_attr_id.attr,
&dev_attr_extra.attr,
NULL
};
static const struct attribute_group serio_id_attr_group = {
.name = "id",
.attrs = serio_device_id_attrs,
};
static DEVICE_ATTR_RO(modalias);
static DEVICE_ATTR_WO(drvctl);
static DEVICE_ATTR(description, S_IRUGO, serio_show_description, NULL);
static DEVICE_ATTR(bind_mode, S_IWUSR | S_IRUGO, serio_show_bind_mode, serio_set_bind_mode);
static DEVICE_ATTR_RO(firmware_id);
static struct attribute *serio_device_attrs[] = {
&dev_attr_modalias.attr,
&dev_attr_description.attr,
&dev_attr_drvctl.attr,
&dev_attr_bind_mode.attr,
&dev_attr_firmware_id.attr,
NULL
};
static const struct attribute_group serio_device_attr_group = {
Annotation
- Immediate include surface: `linux/export.h`, `linux/stddef.h`, `linux/module.h`, `linux/serio.h`, `linux/errno.h`, `linux/sched.h`, `linux/slab.h`, `linux/workqueue.h`.
- Detected declarations: `struct serio_event`, `enum serio_event_type`, `function serio_connect_driver`, `function serio_reconnect_driver`, `function serio_disconnect_driver`, `function serio_match_port`, `function serio_bind_driver`, `function serio_find_driver`, `function serio_free_event`, `function serio_remove_duplicate_events`.
- Atlas domain: Driver Families / drivers/input.
- Implementation status: pattern implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.