drivers/tty/serdev/core.c
Source file repositories/reference/linux-study-clean/drivers/tty/serdev/core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/tty/serdev/core.c- Extension
.c- Size
- 22544 bytes
- Lines
- 908
- Domain
- Driver Families
- Bucket
- drivers/tty
- 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.
- 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/acpi.hlinux/errno.hlinux/idr.hlinux/kernel.hlinux/module.hlinux/of.hlinux/of_graph.hlinux/of_device.hlinux/pm_domain.hlinux/pm_runtime.hlinux/property.hlinux/sched.hlinux/serdev.hlinux/slab.hlinux/platform_data/x86/apple.h
Detected Declarations
struct acpi_serdev_lookupfunction modalias_showfunction serdev_device_ueventfunction serdev_device_releasefunction is_serdev_devicefunction serdev_ctrl_releasefunction serdev_device_matchfunction serdev_device_addfunction serdev_device_removefunction serdev_device_openfunction serdev_device_closefunction devm_serdev_device_closefunction devm_serdev_device_openfunction serdev_device_write_wakeupfunction serdev_device_wait_until_sentfunction serdev_device_wait_until_sentfunction serdev_device_write_flushfunction serdev_device_set_baudratefunction serdev_device_set_flow_controlfunction serdev_device_set_parityfunction serdev_device_wait_until_sentfunction serdev_device_get_tiocmfunction serdev_device_set_tiocmfunction serdev_device_break_ctlfunction serdev_drv_probefunction serdev_drv_removefunction serdev_drv_shutdownfunction serdev_device_allocfunction serdev_controller_allocfunction of_find_serdev_controller_by_nodefunction of_serdev_register_devicesfunction for_each_available_child_of_nodefunction serdev_acpi_get_uart_resourcefunction acpi_serdev_parse_resourcefunction acpi_serdev_do_lookupfunction acpi_serdev_check_resourcesfunction acpi_serdev_register_devicefunction acpi_serdev_add_devicefunction acpi_serdev_register_devicesfunction acpi_serdev_register_devicesfunction serdev_controller_addfunction serdev_remove_devicefunction serdev_controller_removefunction serdev_legacy_shutdownfunction __serdev_device_driver_registerfunction serdev_exitfunction serdev_initexport serdev_device_add
Annotated Snippet
static int serdev_device_match(struct device *dev, const struct device_driver *drv)
{
if (!is_serdev_device(dev))
return 0;
/* TODO: platform matching */
if (acpi_driver_match_device(dev, drv))
return 1;
return of_driver_match_device(dev, drv);
}
/**
* serdev_device_add() - add a device previously constructed via serdev_device_alloc()
* @serdev: serdev_device to be added
*/
int serdev_device_add(struct serdev_device *serdev)
{
struct serdev_controller *ctrl = serdev->ctrl;
struct device *parent = serdev->dev.parent;
int err;
dev_set_name(&serdev->dev, "%s-%d", dev_name(parent), serdev->nr);
/* Only a single slave device is currently supported. */
if (ctrl->serdev) {
dev_err(&serdev->dev, "controller busy\n");
return -EBUSY;
}
ctrl->serdev = serdev;
err = device_add(&serdev->dev);
if (err < 0) {
dev_err(&serdev->dev, "Failed to add serdev: %d\n", err);
goto err_clear_serdev;
}
dev_dbg(&serdev->dev, "serdev registered successfully\n");
return 0;
err_clear_serdev:
ctrl->serdev = NULL;
return err;
}
EXPORT_SYMBOL_GPL(serdev_device_add);
/**
* serdev_device_remove(): remove an serdev device
* @serdev: serdev_device to be removed
*/
void serdev_device_remove(struct serdev_device *serdev)
{
struct serdev_controller *ctrl = serdev->ctrl;
device_unregister(&serdev->dev);
ctrl->serdev = NULL;
}
EXPORT_SYMBOL_GPL(serdev_device_remove);
int serdev_device_open(struct serdev_device *serdev)
{
struct serdev_controller *ctrl = serdev->ctrl;
int ret;
if (!ctrl || !ctrl->ops->open)
return -EINVAL;
ret = ctrl->ops->open(ctrl);
if (ret)
return ret;
ret = pm_runtime_get_sync(&ctrl->dev);
if (ret < 0) {
pm_runtime_put_noidle(&ctrl->dev);
goto err_close;
}
return 0;
err_close:
if (ctrl->ops->close)
ctrl->ops->close(ctrl);
return ret;
}
EXPORT_SYMBOL_GPL(serdev_device_open);
void serdev_device_close(struct serdev_device *serdev)
{
Annotation
- Immediate include surface: `linux/acpi.h`, `linux/errno.h`, `linux/idr.h`, `linux/kernel.h`, `linux/module.h`, `linux/of.h`, `linux/of_graph.h`, `linux/of_device.h`.
- Detected declarations: `struct acpi_serdev_lookup`, `function modalias_show`, `function serdev_device_uevent`, `function serdev_device_release`, `function is_serdev_device`, `function serdev_ctrl_release`, `function serdev_device_match`, `function serdev_device_add`, `function serdev_device_remove`, `function serdev_device_open`.
- Atlas domain: Driver Families / drivers/tty.
- Implementation status: pattern 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.