drivers/char/adi.c
Source file repositories/reference/linux-study-clean/drivers/char/adi.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/char/adi.c- Extension
.c- Size
- 4446 bytes
- Lines
- 233
- Domain
- Driver Families
- Bucket
- drivers/char
- 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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/kernel.hlinux/miscdevice.hlinux/module.hlinux/proc_fs.hlinux/slab.hlinux/uaccess.hasm/asi.h
Detected Declarations
function read_mcd_tagfunction adi_readfunction set_mcd_tagfunction adi_writefunction adi_llseekfunction adi_initfunction adi_exitmodule init adi_init
Annotated Snippet
static const struct file_operations adi_fops = {
.owner = THIS_MODULE,
.llseek = adi_llseek,
.read = adi_read,
.write = adi_write,
.fop_flags = FOP_UNSIGNED_OFFSET,
};
static struct miscdevice adi_miscdev = {
.minor = MISC_DYNAMIC_MINOR,
.name = KBUILD_MODNAME,
.fops = &adi_fops,
};
static int __init adi_init(void)
{
if (!adi_capable())
return -EPERM;
return misc_register(&adi_miscdev);
}
static void __exit adi_exit(void)
{
misc_deregister(&adi_miscdev);
}
module_init(adi_init);
module_exit(adi_exit);
MODULE_AUTHOR("Tom Hromatka <tom.hromatka@oracle.com>");
MODULE_DESCRIPTION("Privileged interface to ADI");
MODULE_VERSION("1.0");
MODULE_LICENSE("GPL v2");
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/miscdevice.h`, `linux/module.h`, `linux/proc_fs.h`, `linux/slab.h`, `linux/uaccess.h`, `asm/asi.h`.
- Detected declarations: `function read_mcd_tag`, `function adi_read`, `function set_mcd_tag`, `function adi_write`, `function adi_llseek`, `function adi_init`, `function adi_exit`, `module init adi_init`.
- Atlas domain: Driver Families / drivers/char.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
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.