drivers/rtc/dev.c
Source file repositories/reference/linux-study-clean/drivers/rtc/dev.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/rtc/dev.c- Extension
.c- Size
- 13510 bytes
- Lines
- 577
- Domain
- Driver Families
- Bucket
- drivers/rtc
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/compat.hlinux/module.hlinux/rtc.hlinux/sched/signal.hrtc-core.h
Detected Declarations
function rtc_dev_openfunction rtc_uie_taskfunction rtc_uie_timerfunction clear_uiefunction set_uiefunction rtc_dev_update_irq_enable_emulfunction rtc_dev_readfunction rtc_dev_pollfunction rtc_dev_ioctlfunction rtc_dev_compat_ioctlfunction rtc_dev_fasyncfunction rtc_dev_releasefunction rtc_dev_preparefunction rtc_dev_initexport rtc_dev_update_irq_enable_emul
Annotated Snippet
static const struct file_operations rtc_dev_fops = {
.owner = THIS_MODULE,
.read = rtc_dev_read,
.poll = rtc_dev_poll,
.unlocked_ioctl = rtc_dev_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = rtc_dev_compat_ioctl,
#endif
.open = rtc_dev_open,
.release = rtc_dev_release,
.fasync = rtc_dev_fasync,
};
/* insertion/removal hooks */
void rtc_dev_prepare(struct rtc_device *rtc)
{
if (!rtc_devt)
return;
if (rtc->id >= RTC_DEV_MAX) {
dev_dbg(&rtc->dev, "too many RTC devices\n");
return;
}
rtc->dev.devt = MKDEV(MAJOR(rtc_devt), rtc->id);
#ifdef CONFIG_RTC_INTF_DEV_UIE_EMUL
INIT_WORK(&rtc->uie_task, rtc_uie_task);
timer_setup(&rtc->uie_timer, rtc_uie_timer, 0);
#endif
cdev_init(&rtc->char_dev, &rtc_dev_fops);
rtc->char_dev.owner = rtc->owner;
}
void __init rtc_dev_init(void)
{
int err;
err = alloc_chrdev_region(&rtc_devt, 0, RTC_DEV_MAX, "rtc");
if (err < 0)
pr_err("failed to allocate char dev region\n");
}
Annotation
- Immediate include surface: `linux/compat.h`, `linux/module.h`, `linux/rtc.h`, `linux/sched/signal.h`, `rtc-core.h`.
- Detected declarations: `function rtc_dev_open`, `function rtc_uie_task`, `function rtc_uie_timer`, `function clear_uie`, `function set_uie`, `function rtc_dev_update_irq_enable_emul`, `function rtc_dev_read`, `function rtc_dev_poll`, `function rtc_dev_ioctl`, `function rtc_dev_compat_ioctl`.
- Atlas domain: Driver Families / drivers/rtc.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.