drivers/remoteproc/remoteproc_cdev.c
Source file repositories/reference/linux-study-clean/drivers/remoteproc/remoteproc_cdev.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/remoteproc/remoteproc_cdev.c- Extension
.c- Size
- 2987 bytes
- Lines
- 127
- Domain
- Driver Families
- Bucket
- drivers/remoteproc
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/cdev.hlinux/compat.hlinux/fs.hlinux/module.hlinux/remoteproc.hlinux/uaccess.huapi/linux/remoteproc_cdev.hremoteproc_internal.h
Detected Declarations
function rproc_cdev_writefunction rproc_device_ioctlfunction rproc_cdev_releasefunction rproc_char_device_addfunction rproc_char_device_removefunction rproc_init_cdev
Annotated Snippet
static const struct file_operations rproc_fops = {
.write = rproc_cdev_write,
.unlocked_ioctl = rproc_device_ioctl,
.compat_ioctl = compat_ptr_ioctl,
.release = rproc_cdev_release,
};
int rproc_char_device_add(struct rproc *rproc)
{
int ret;
cdev_init(&rproc->cdev, &rproc_fops);
rproc->cdev.owner = THIS_MODULE;
rproc->dev.devt = MKDEV(MAJOR(rproc_major), rproc->index);
cdev_set_parent(&rproc->cdev, &rproc->dev.kobj);
ret = cdev_add(&rproc->cdev, rproc->dev.devt, 1);
if (ret < 0)
dev_err(&rproc->dev, "Failed to add char dev for %s\n", rproc->name);
return ret;
}
void rproc_char_device_remove(struct rproc *rproc)
{
cdev_del(&rproc->cdev);
}
void __init rproc_init_cdev(void)
{
int ret;
ret = alloc_chrdev_region(&rproc_major, 0, NUM_RPROC_DEVICES, "remoteproc");
if (ret < 0)
pr_err("Failed to alloc rproc_cdev region, err %d\n", ret);
}
Annotation
- Immediate include surface: `linux/cdev.h`, `linux/compat.h`, `linux/fs.h`, `linux/module.h`, `linux/remoteproc.h`, `linux/uaccess.h`, `uapi/linux/remoteproc_cdev.h`, `remoteproc_internal.h`.
- Detected declarations: `function rproc_cdev_write`, `function rproc_device_ioctl`, `function rproc_cdev_release`, `function rproc_char_device_add`, `function rproc_char_device_remove`, `function rproc_init_cdev`.
- Atlas domain: Driver Families / drivers/remoteproc.
- 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.