drivers/soc/qcom/cmd-db.c
Source file repositories/reference/linux-study-clean/drivers/soc/qcom/cmd-db.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/soc/qcom/cmd-db.c- Extension
.c- Size
- 9682 bytes
- Lines
- 395
- Domain
- Driver Families
- Bucket
- drivers/soc
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitfield.hlinux/debugfs.hlinux/kernel.hlinux/module.hlinux/of.hlinux/of_address.hlinux/of_reserved_mem.hlinux/platform_device.hlinux/seq_file.hlinux/types.hsoc/qcom/cmd-db.h
Detected Declarations
struct entry_headerstruct rsc_hdrstruct cmd_db_headerfunction cmd_db_magic_matchesfunction rsc_offsetfunction cmd_db_readyfunction cmd_db_get_headerfunction cmd_db_read_addrfunction cmd_db_read_aux_datafunction cmd_db_match_resource_addrfunction cmd_db_read_slave_idfunction cmd_db_debugfs_dumpfunction open_cmd_db_debugfsfunction cmd_db_dev_probefunction cmd_db_device_initmodule init cmd_db_device_initexport cmd_db_readyexport cmd_db_read_addrexport cmd_db_read_aux_dataexport cmd_db_match_resource_addrexport cmd_db_read_slave_id
Annotated Snippet
static const struct file_operations cmd_db_debugfs_ops = {
#ifdef CONFIG_DEBUG_FS
.open = open_cmd_db_debugfs,
#endif
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
static int cmd_db_dev_probe(struct platform_device *pdev)
{
struct reserved_mem *rmem;
int ret = 0;
rmem = of_reserved_mem_lookup(pdev->dev.of_node);
if (!rmem) {
dev_err(&pdev->dev, "failed to acquire memory region\n");
return -EINVAL;
}
cmd_db_header = devm_memremap(&pdev->dev, rmem->base, rmem->size, MEMREMAP_WC);
if (IS_ERR(cmd_db_header)) {
ret = PTR_ERR(cmd_db_header);
cmd_db_header = NULL;
return ret;
}
if (!cmd_db_magic_matches(cmd_db_header)) {
dev_err(&pdev->dev, "Invalid Command DB Magic\n");
cmd_db_header = NULL;
return -EINVAL;
}
debugfs_create_file("cmd-db", 0400, NULL, NULL, &cmd_db_debugfs_ops);
device_set_pm_not_required(&pdev->dev);
return 0;
}
static const struct of_device_id cmd_db_match_table[] = {
{ .compatible = "qcom,cmd-db" },
{ }
};
MODULE_DEVICE_TABLE(of, cmd_db_match_table);
static struct platform_driver cmd_db_dev_driver = {
.probe = cmd_db_dev_probe,
.driver = {
.name = "cmd-db",
.of_match_table = cmd_db_match_table,
.suppress_bind_attrs = true,
},
};
static int __init cmd_db_device_init(void)
{
return platform_driver_register(&cmd_db_dev_driver);
}
core_initcall(cmd_db_device_init);
MODULE_DESCRIPTION("Qualcomm Technologies, Inc. Command DB Driver");
MODULE_LICENSE("GPL v2");
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/debugfs.h`, `linux/kernel.h`, `linux/module.h`, `linux/of.h`, `linux/of_address.h`, `linux/of_reserved_mem.h`, `linux/platform_device.h`.
- Detected declarations: `struct entry_header`, `struct rsc_hdr`, `struct cmd_db_header`, `function cmd_db_magic_matches`, `function rsc_offset`, `function cmd_db_ready`, `function cmd_db_get_header`, `function cmd_db_read_addr`, `function cmd_db_read_aux_data`, `function cmd_db_match_resource_addr`.
- Atlas domain: Driver Families / drivers/soc.
- Implementation status: pattern implementation candidate.
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.