Source
static int rtc_read_alarm_internal(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
/*
* RTC subsystem, interface functions
*
* Copyright (C) 2005 Tower Technologies
* Author: Alessandro Zummo <a.zummo@towertech.it>
*
* based on arch/arm/common/rtctime.c
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
static int rtc_timer_enqueue(struct rtc_device *rtc, struct rtc_timer *timer);
static void rtc_timer_remove(struct rtc_device *rtc, struct rtc_timer *timer);
static void rtc_add_offset(struct rtc_device *rtc, struct rtc_time *tm)
{
time64_t secs;
if (!rtc->offset_secs)
return;
secs = rtc_tm_to_time64(tm);
/*
* Since the reading time values from RTC device are always in the RTC
* original valid range, but we need to skip the overlapped region
* between expanded range and original range, which is no need to add
* the offset.
*/
if ((rtc->start_secs > rtc->range_min && secs >= rtc->start_secs) ||
(rtc->start_secs < rtc->range_min &&
secs <= (rtc->start_secs + rtc->range_max - rtc->range_min)))
return;
rtc_time64_to_tm(secs + rtc->offset_secs, tm);
}
static void rtc_subtract_offset(struct rtc_device *rtc, struct rtc_time *tm)
{
time64_t secs;
if (!rtc->offset_secs)
return;
secs = rtc_tm_to_time64(tm);
/*
* If the setting time values are in the valid range of RTC hardware
* device, then no need to subtract the offset when setting time to RTC
* device. Otherwise we need to subtract the offset to make the time
* values are valid for RTC hardware device.
*/