drivers/rtc/interface.c
Source file repositories/reference/linux-study-clean/drivers/rtc/interface.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/rtc/interface.c- Extension
.c- Size
- 27911 bytes
- Lines
- 1120
- Domain
- Driver Families
- Bucket
- drivers/rtc
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/rtc.hlinux/sched.hlinux/module.hlinux/log2.hlinux/workqueue.htrace/events/rtc.h
Detected Declarations
function rtc_add_offsetfunction rtc_subtract_offsetfunction rtc_valid_rangefunction __rtc_read_timefunction rtc_read_timefunction rtc_set_timefunction rtc_read_alarm_internalfunction __rtc_read_alarmfunction rtc_read_alarmfunction __rtc_set_alarmfunction rtc_set_alarmfunction rtc_initialize_alarmfunction rtc_alarm_irq_enablefunction rtc_update_irq_enablefunction occurredfunction rtc_aie_update_irqfunction rtc_uie_update_irqfunction rtc_pie_update_irqfunction rtc_update_irqfunction rtc_class_closefunction rtc_update_hrtimerfunction rtc_irq_set_freqfunction rtc_irq_set_statefunction rtc_timer_enqueuefunction rtc_alarm_disablefunction rtc_timer_removefunction rtc_timer_do_workfunction rtc_timer_initfunction rtc_timer_startfunction rtc_timer_cancelfunction read_offsetfunction setableexport rtc_read_timeexport rtc_set_timeexport rtc_read_alarmexport rtc_set_alarmexport rtc_initialize_alarmexport rtc_alarm_irq_enableexport rtc_update_irq_enableexport rtc_update_irqexport rtc_class_openexport rtc_class_close
Annotated Snippet
if (err < 0) {
dev_dbg(&rtc->dev, "read_time: fail to read: %d\n",
err);
return err;
}
rtc_add_offset(rtc, tm);
err = rtc_valid_tm(tm);
if (err < 0)
dev_dbg(&rtc->dev, "read_time: rtc_time isn't valid\n");
}
return err;
}
int rtc_read_time(struct rtc_device *rtc, struct rtc_time *tm)
{
int err;
err = mutex_lock_interruptible(&rtc->ops_lock);
if (err)
return err;
err = __rtc_read_time(rtc, tm);
mutex_unlock(&rtc->ops_lock);
trace_rtc_read_time(rtc_tm_to_time64(tm), err);
return err;
}
EXPORT_SYMBOL_GPL(rtc_read_time);
int rtc_set_time(struct rtc_device *rtc, struct rtc_time *tm)
{
int err, uie;
err = rtc_valid_tm(tm);
if (err != 0)
return err;
err = rtc_valid_range(rtc, tm);
if (err)
return err;
rtc_subtract_offset(rtc, tm);
#ifdef CONFIG_RTC_INTF_DEV_UIE_EMUL
uie = rtc->uie_rtctimer.enabled || rtc->uie_irq_active;
#else
uie = rtc->uie_rtctimer.enabled;
#endif
if (uie) {
err = rtc_update_irq_enable(rtc, 0);
if (err)
return err;
}
err = mutex_lock_interruptible(&rtc->ops_lock);
if (err)
return err;
if (!rtc->ops)
err = -ENODEV;
else if (rtc->ops->set_time)
err = rtc->ops->set_time(rtc->dev.parent, tm);
else
err = -EINVAL;
pm_stay_awake(rtc->dev.parent);
mutex_unlock(&rtc->ops_lock);
/* A timer might have just expired */
schedule_work(&rtc->irqwork);
if (uie) {
err = rtc_update_irq_enable(rtc, 1);
if (err)
return err;
}
trace_rtc_set_time(rtc_tm_to_time64(tm), err);
return err;
}
EXPORT_SYMBOL_GPL(rtc_set_time);
static int rtc_read_alarm_internal(struct rtc_device *rtc,
struct rtc_wkalrm *alarm)
{
int err;
err = mutex_lock_interruptible(&rtc->ops_lock);
if (err)
Annotation
- Immediate include surface: `linux/rtc.h`, `linux/sched.h`, `linux/module.h`, `linux/log2.h`, `linux/workqueue.h`, `trace/events/rtc.h`.
- Detected declarations: `function rtc_add_offset`, `function rtc_subtract_offset`, `function rtc_valid_range`, `function __rtc_read_time`, `function rtc_read_time`, `function rtc_set_time`, `function rtc_read_alarm_internal`, `function __rtc_read_alarm`, `function rtc_read_alarm`, `function __rtc_set_alarm`.
- Atlas domain: Driver Families / drivers/rtc.
- Implementation status: integration 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.