本文整理汇总了C++中rtc_tm_to_time函数的典型用法代码示例。如果您正苦于以下问题:C++ rtc_tm_to_time函数的具体用法?C++ rtc_tm_to_time怎么用?C++ rtc_tm_to_time使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rtc_tm_to_time函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: set_wakealarm
static int set_wakealarm(void)
{
int retval = 0;
unsigned long now, alarm;
struct rtc_wkalrm alm;
struct rtc_device *rtc;
rtc = rtc_class_open(CONFIG_WAKEALARM_RTC);
if (!rtc) {
return -1;
}
/* Only request alarms that trigger in the future. Disable them
* by writing another time, e.g. 0 meaning Jan 1 1970 UTC.
*/
retval = rtc_read_time(rtc, &alm.time);
if (retval < 0)
goto close_rtc;
rtc_tm_to_time(&alm.time, &now);
alarm = now + sleep_time;
if (alarm > now) {
/* Avoid accidentally clobbering active alarms; we can't
* entirely prevent that here, without even the minimal
* locking from the /dev/rtcN api.
*/
retval = rtc_read_alarm(rtc, &alm);
if (retval < 0)
goto close_rtc;
alm.enabled = 1;
} else {
alm.enabled = 0;
/* Provide a valid future alarm time. Linux isn't EFI,
* this time won't be ignored when disabling the alarm.
*/
alarm = now + 300;
}
rtc_time_to_tm(alarm, &alm.time);
retval = rtc_set_alarm(rtc, &alm);
close_rtc:
rtc_class_close(rtc);
return retval;
}
示例2: omap_rtc_resume
static int omap_rtc_resume(struct platform_device *pdev)
{
struct rtc_time rtc_tm;
struct timespec time;
time.tv_nsec = 0;
omap_rtc_read_time(NULL, &rtc_tm);
rtc_tm_to_time(&rtc_tm, &time.tv_sec);
restore_time_delta(&rtc_delta, &time);
if (device_may_wakeup(&pdev->dev))
disable_irq_wake(omap_rtc_alarm);
else
rtc_write(irqstat, OMAP_RTC_INTERRUPTS_REG);
return 0;
}
示例3: pl030_set_alarm
static int pl030_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
{
struct pl030_rtc *rtc = dev_get_drvdata(dev);
unsigned long time;
int ret;
/*
* At the moment, we can only deal with non-wildcarded alarm times.
*/
ret = rtc_valid_tm(&alrm->time);
if (ret == 0)
ret = rtc_tm_to_time(&alrm->time, &time);
if (ret == 0)
writel(time, rtc->base + RTC_MR);
return ret;
}
示例4: dryice_rtc_set_time
/*
* set the seconds portion of dryice time counter and clear the
* fractional part.
*/
static int dryice_rtc_set_time(struct device *dev, struct rtc_time *tm)
{
struct rtc_drv_data *pdata = dev_get_drvdata(dev);
unsigned long now;
int rc;
dev_dbg(dev, "%s\n", __func__);
rc = rtc_tm_to_time(tm, &now);
if (rc == 0) {
/* zero the fractional part first */
di_write_wait_err(pdata, 0, DTCLR, rc, err);
di_write_wait_err(pdata, now, DTCMR, rc, err);
}
err:
return rc;
}
示例5: exynos_read_persistent_clock
/**
* read_persistent_clock() - Return time from a persistent clock.
* @ts: timespec returns a relative timestamp, not a wall time
*
* Reads a clock that keeps relative time across suspend/resume on Exynos
* platforms. The clock is accurate to 1 second.
*/
void exynos_read_persistent_clock(struct timespec *ts)
{
struct rtc_time rtc_tm;
unsigned long time;
if (!exynos_rtc_base) {
ts->tv_sec = 0;
ts->tv_nsec = 0;
return;
}
exynos_persistent_clock_read(&rtc_tm);
rtc_tm_to_time(&rtc_tm, &time);
ts->tv_sec = time;
ts->tv_nsec = 0;
}
示例6: iphone_rtc_settime
static int iphone_rtc_settime(struct device *dev, struct rtc_time *rtc_tm)
{
unsigned long secs;
unsigned long cur;
s32 offset;
rtc_tm_to_time(rtc_tm, &secs);
cur = iphone_pmu_get_epoch();
offset = secs - cur;
iphone_pmu_write_reg(0x6B, offset & 0xFF, 0);
iphone_pmu_write_reg(0x6C, (offset >> 8) & 0xFF, 0);
iphone_pmu_write_reg(0x6D, (offset >> 16) & 0xFF, 0);
iphone_pmu_write_reg(0x6E, (offset >> 24) & 0xFF, 0);
return 0;
}
示例7: xgene_rtc_set_alarm
static int xgene_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
{
struct xgene_rtc_dev *pdata = dev_get_drvdata(dev);
unsigned long rtc_time;
unsigned long alarm_time;
rtc_time = readl(pdata->csr_base + RTC_CCVR);
rtc_tm_to_time(&alrm->time, &alarm_time);
pdata->alarm_time = alarm_time;
writel((u32) pdata->alarm_time, pdata->csr_base + RTC_CMR);
xgene_rtc_alarm_irq_enable(dev, alrm->enabled);
return 0;
}
示例8: au1xtoy_rtc_set_time
static int au1xtoy_rtc_set_time(struct device *dev, struct rtc_time *tm)
{
unsigned long t;
rtc_tm_to_time(tm, &t);
alchemy_wrsys(t, AU1000_SYS_TOYWRITE);
/* wait for the pending register write to succeed. This can
* take up to 6 seconds...
*/
while (alchemy_rdsys(AU1000_SYS_CNTRCTRL) & SYS_CNTRL_C0S)
msleep(1);
return 0;
}
示例9: rtc_sysfs_show_since_epoch
static ssize_t
rtc_sysfs_show_since_epoch(struct device *dev, struct device_attribute *attr,
char *buf)
{
ssize_t retval;
struct rtc_time tm;
retval = rtc_read_time(to_rtc_device(dev), &tm);
if (retval == 0) {
unsigned long time;
rtc_tm_to_time(&tm, &time);
retval = sprintf(buf, "%lu\n", time);
}
return retval;
}
示例10: s3c_rtc_suspend
static int s3c_rtc_suspend(struct platform_device *pdev, pm_message_t state)
{
struct rtc_time tm;
struct timespec time;
time.tv_nsec = 0;
/* save TICNT for anyone using periodic interrupts */
ticnt_save = readb(s3c_rtc_base + S3C2410_TICNT);
s3c_rtc_gettime(&pdev->dev, &tm);
rtc_tm_to_time(&tm, &time.tv_sec);
save_time_delta(&s3c_rtc_delta, &time);
s3c_rtc_enable(pdev, 0);
return 0;
}
示例11: rtc_read_hw_time
unsigned long rtc_read_hw_time(void)
{
unsigned long time, flags;
struct rtc_time tm;
spin_lock_irqsave(&rtc_lock, flags);
/* rtc_ctrl_func(HAL_RTC_CMD_RELOAD, NULL); */
/* rtc_ctrl_func(HAL_RTC_CMD_GET_TIME, &tm); */
hal_rtc_get_tick_time(&tm);
spin_unlock_irqrestore(&rtc_lock, flags);
tm.tm_year += RTC_MIN_YEAR_OFFSET;
tm.tm_mon--;
rtc_tm_to_time(&tm, &time);
tm.tm_wday = (time / 86400 + 4) % 7; /* 1970/01/01 is Thursday */
return time;
}
示例12: pcap_rtc_set_alarm
static int pcap_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
{
struct pcap_rtc *pcap_rtc = dev_get_drvdata(dev);
struct rtc_time *tm = &alrm->time;
unsigned long secs;
u32 tod, days;
rtc_tm_to_time(tm, &secs);
tod = secs % SEC_PER_DAY;
ezx_pcap_write(pcap_rtc->pcap, PCAP_REG_RTC_TODA, tod);
days = secs / SEC_PER_DAY;
ezx_pcap_write(pcap_rtc->pcap, PCAP_REG_RTC_DAYA, days);
return 0;
}
示例13: au1xtoy_rtc_set_time
static int au1xtoy_rtc_set_time(struct device *dev, struct rtc_time *tm)
{
unsigned long t;
rtc_tm_to_time(tm, &t);
au_writel(t, SYS_TOYWRITE);
au_sync();
/* wait for the pending register write to succeed. This can
* take up to 6 seconds...
*/
while (au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_C0S)
msleep(1);
return 0;
}
示例14: sprd_rtc_set_alarm
static int sprd_rtc_set_alarm(struct device *dev,
struct rtc_wkalrm *alrm)
{
unsigned long secs;
unsigned temp;
unsigned long read_secs;
int i = 0,n;
rtc_tm_to_time(&alrm->time, &secs);
sci_adi_raw_write(ANA_RTC_INT_CLR, RTC_ALARM_BIT);
// printk("sprd_rtc_set_alarm enable : %d, : %lu, secs : %lu\n", alrm->enabled, secs_start_year_to_1970, secs);
// printk("sprd_rtc_set_alarm - day [%d] hour [%d] min [%d] sec [%d]\n", alrm->time.tm_mday, alrm->time.tm_hour, alrm->time.tm_min, alrm->time.tm_sec);
if(alrm->enabled){
if(secs < secs_start_year_to_1970)
return -1;
temp = sci_adi_read(ANA_RTC_INT_EN);
temp |= RTC_ALARM_BIT;
sci_adi_raw_write(ANA_RTC_INT_EN, temp);
secs = secs - secs_start_year_to_1970;
wake_lock(&rtc_wake_lock);
n = 2;
while(sprd_rtc_set_alarm_sec(secs)!=0&&(n--)>0);
do {
if(i!=0){
n = 2;
while(sprd_rtc_set_alarm_sec(secs)!=0&&(n--)>0);
}
read_secs = sprd_rtc_get_alarm_sec();
msleep(1);
i++;
}while(read_secs != secs && i < SPRD_RTC_SET_MAX);
//sci_adi_raw_write(ANA_RTC_SPG_UPD, SPRD_RTC_UNLOCK);
wake_unlock(&rtc_wake_lock);
}else{
sci_adi_clr(ANA_RTC_INT_EN, RTC_ALARM_BIT);
//sci_adi_raw_write(ANA_RTC_SPG_UPD, SPRD_RTC_LOCK);
msleep(150);
}
return 0;
}
示例15: alarm_read_rtc_ring
int alarm_read_rtc_ring(int *flag, unsigned long *alarm_time)
{
struct rtc_wkalrm rtc_alarm;
int ret = 0;
if (pwr_rtc_dev != NULL) {
if (pwr_rtc_dev->dev.platform_data)
*flag = *(int *)(pwr_rtc_dev->dev.platform_data);
ret = rtc_read_alarm(pwr_rtc_dev, &rtc_alarm);
if (ret < 0)
goto out;
rtc_tm_to_time(&rtc_alarm.time, alarm_time);
pr_alarm(INT, "%s, flag: %d, alarm time: %lu\n",
__func__, *flag, *alarm_time);
}
out:
return ret;
}