本文整理汇总了C++中rtc_time_to_tm函数的典型用法代码示例。如果您正苦于以下问题:C++ rtc_time_to_tm函数的具体用法?C++ rtc_time_to_tm怎么用?C++ rtc_time_to_tm使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rtc_time_to_tm函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sprd_rtc_read_alarm
static int sprd_rtc_read_alarm(struct device *dev,
struct rtc_wkalrm *alrm)
{
unsigned long secs = sprd_rtc_get_alarm_sec();
secs = secs + secs_start_year_to_1970;
rtc_time_to_tm(secs, &alrm->time);
alrm->enabled = !!(sci_adi_read(ANA_RTC_INT_EN) & RTC_ALARM_BIT);
alrm->pending = !!(sci_adi_read(ANA_RTC_INT_RSTS) & RTC_ALARM_BIT);
printk("rtc_alarm:alrm->enabled=%d,secs=%lu\n",alrm->enabled,secs);
return 0;
}
示例2: ktd259b_backlight_earlyresume
static void ktd259b_backlight_earlyresume(struct early_suspend *desc)
{
struct ktd259b_bl_data *ktd259b = container_of(desc, struct ktd259b_bl_data,
early_suspend_desc);
struct backlight_device *bl = platform_get_drvdata(ktd259b->pdev);
struct timespec ts;
struct rtc_time tm;
getnstimeofday(&ts);
rtc_time_to_tm(ts.tv_sec, &tm);
backlight_mode=BACKLIGHT_RESUME;
printk("[%02d:%02d:%02d.%03lu][BACKLIGHT] earlyresume\n", tm.tm_hour, tm.tm_min, tm.tm_sec, ts.tv_nsec);
backlight_update_status(bl);
}
示例3: coh901331_read_time
static int coh901331_read_time(struct device *dev, struct rtc_time *tm)
{
struct coh901331_port *rtap = dev_get_drvdata(dev);
clk_enable(rtap->clk);
/* */
if (readl(rtap->virtbase + COH901331_VALID)) {
rtc_time_to_tm(readl(rtap->virtbase + COH901331_CUR_TIME), tm);
clk_disable(rtap->clk);
return rtc_valid_tm(tm);
}
clk_disable(rtap->clk);
return -EINVAL;
}
示例4: mv_rtc_read_time
static int mv_rtc_read_time(struct rtc_time *tm)
{
MV_RTC_TIME time;
unsigned long temp_t;
mvRtcDS1339TimeGet(&time);
/* same as in the U-Boot we use the year for century 20 only */
temp_t = mktime ( time.year + 2000, time.month,
time.date, time.hours,
time.minutes, time.seconds);
rtc_time_to_tm(temp_t, tm);
return 0;
}
示例5: test_wakealarm
static void __init test_wakealarm(struct rtc_device *rtc, suspend_state_t state)
{
static char err_readtime[] __initdata =
KERN_ERR "PM: can't read %s time, err %d\n";
static char err_wakealarm [] __initdata =
KERN_ERR "PM: can't set %s wakealarm, err %d\n";
static char err_suspend[] __initdata =
KERN_ERR "PM: suspend test failed, error %d\n";
static char info_test[] __initdata =
KERN_INFO "PM: test RTC wakeup from '%s' suspend\n";
unsigned long now;
struct rtc_wkalrm alm;
int status;
status = rtc_read_time(rtc, &alm.time);
if (status < 0) {
printk(err_readtime, dev_name(&rtc->dev), status);
return;
}
rtc_tm_to_time(&alm.time, &now);
memset(&alm, 0, sizeof alm);
rtc_time_to_tm(now + TEST_SUSPEND_SECONDS, &alm.time);
alm.enabled = true;
status = rtc_set_alarm(rtc, &alm);
if (status < 0) {
printk(err_wakealarm, dev_name(&rtc->dev), status);
return;
}
if (state == PM_SUSPEND_MEM) {
printk(info_test, pm_states[state]);
status = pm_suspend(state);
if (status == -ENODEV)
state = PM_SUSPEND_STANDBY;
}
if (state == PM_SUSPEND_STANDBY) {
printk(info_test, pm_states[state]);
status = pm_suspend(state);
}
if (status < 0)
printk(err_suspend, status);
alm.enabled = false;
rtc_set_alarm(rtc, &alm);
}
示例6: pm8xxx_rtc_read_time
static int pm8xxx_rtc_read_time(struct device *dev, struct rtc_time *tm)
{
int rc;
u8 value[NUM_8_BIT_RTC_REGS], reg;
unsigned long secs;
struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev);
rc = pm8xxx_read_wrapper(rtc_dd, value, rtc_dd->rtc_read_base,
NUM_8_BIT_RTC_REGS);
if (rc < 0) {
dev_err(dev, "RTC read data register failed\n");
return rc;
}
/*
* Read the LSB again and check if there has been a carry over.
* If there is, redo the read operation.
*/
rc = pm8xxx_read_wrapper(rtc_dd, ®, rtc_dd->rtc_read_base, 1);
if (rc < 0) {
dev_err(dev, "RTC read data register failed\n");
return rc;
}
if (unlikely(reg < value[0])) {
rc = pm8xxx_read_wrapper(rtc_dd, value,
rtc_dd->rtc_read_base, NUM_8_BIT_RTC_REGS);
if (rc < 0) {
dev_err(dev, "RTC read data register failed\n");
return rc;
}
}
secs = value[0] | (value[1] << 8) | (value[2] << 16) | (value[3] << 24);
rtc_time_to_tm(secs, tm);
rc = rtc_valid_tm(tm);
if (rc < 0) {
dev_err(dev, "Invalid time read from RTC\n");
return rc;
}
dev_dbg(dev, "secs = %lu, h:m:s == %d:%d:%d, d/m/y = %d/%d/%d\n",
secs, tm->tm_hour, tm->tm_min, tm->tm_sec,
tm->tm_mday, tm->tm_mon, tm->tm_year);
return 0;
}
示例7: omap_rtc_power_off
/*
* omap_rtc_poweroff: RTC-controlled power off
*
* The RTC can be used to control an external PMIC via the pmic_power_en pin,
* which can be configured to transition to OFF on ALARM2 events.
*
* Notes:
* The two-second alarm offset is the shortest offset possible as the alarm
* registers must be set before the next timer update and the offset
* calculation is too heavy for everything to be done within a single access
* period (~15 us).
*
* Called with local interrupts disabled.
*/
static void omap_rtc_power_off(void)
{
struct omap_rtc *rtc = omap_rtc_power_off_rtc;
struct rtc_time tm;
unsigned long now;
u32 val;
rtc->type->unlock(rtc);
/* enable pmic_power_en control */
val = rtc_readl(rtc, OMAP_RTC_PMIC_REG);
rtc_writel(rtc, OMAP_RTC_PMIC_REG, val | OMAP_RTC_PMIC_POWER_EN_EN);
/* set alarm two seconds from now */
omap_rtc_read_time_raw(rtc, &tm);
bcd2tm(&tm);
rtc_tm_to_time(&tm, &now);
rtc_time_to_tm(now + 2, &tm);
if (tm2bcd(&tm) < 0) {
dev_err(&rtc->rtc->dev, "power off failed\n");
return;
}
rtc_wait_not_busy(rtc);
rtc_write(rtc, OMAP_RTC_ALARM2_SECONDS_REG, tm.tm_sec);
rtc_write(rtc, OMAP_RTC_ALARM2_MINUTES_REG, tm.tm_min);
rtc_write(rtc, OMAP_RTC_ALARM2_HOURS_REG, tm.tm_hour);
rtc_write(rtc, OMAP_RTC_ALARM2_DAYS_REG, tm.tm_mday);
rtc_write(rtc, OMAP_RTC_ALARM2_MONTHS_REG, tm.tm_mon);
rtc_write(rtc, OMAP_RTC_ALARM2_YEARS_REG, tm.tm_year);
/*
* enable ALARM2 interrupt
*
* NOTE: this fails on AM3352 if rtc_write (writeb) is used
*/
val = rtc_read(rtc, OMAP_RTC_INTERRUPTS_REG);
rtc_writel(rtc, OMAP_RTC_INTERRUPTS_REG,
val | OMAP_RTC_INTERRUPTS_IT_ALARM2);
rtc->type->lock(rtc);
/*
* Wait for alarm to trigger (within two seconds) and external PMIC to
* power off the system. Add a 500 ms margin for external latencies
* (e.g. debounce circuits).
*/
mdelay(2500);
}
示例8: eemcs_sysfs_show_statistics
static ssize_t eemcs_sysfs_show_statistics(struct device *dev, struct device_attribute *attr, char *buf)
{
int i = 0;
char line[121]={0};
char c_time_string[30]={0};
int pos = 0;
struct timeval tv;
struct rtc_time tm;
struct rtc_time tm_now;
do_gettimeofday(&tv);
rtc_time_to_tm(tv.tv_sec,&tm_now);
rtc_time_to_tm(eemcs_statistics[0]->time.tv_sec,&tm);
sprintf(c_time_string,"%04d-%02d-%02d_%02d:%02d:%02d ~ %02d:%02d - %d sec",
tm.tm_year+1900,tm.tm_mon+1, tm.tm_mday,tm.tm_hour,tm.tm_min,tm.tm_sec,
tm_now.tm_min,tm_now.tm_sec,
(unsigned int)(tv.tv_sec - eemcs_statistics[0]->time.tv_sec));
pos += sprintf(buf+pos, "Record Time: %s\n", c_time_string);
pos += sprintf(buf+pos, "%15s | %7s | %7s | %9s | %8s | %8s | %7s | %7s |\n",
"CCCI PORT", "TX CNT", "RX CNT", "RX Q(MAX)", "TX TOTAL", "RX TOTAL", "TX DROP", "RX DROP");
memset(line, '=', 91);
pos += sprintf(buf+pos, "%s\n", line);
for (i=0; i< CCCI_PORT_NUM_MAX; i++){
CCCI_PORT_STATISTICS *port = &eemcs_statistics[0]->port[i];
CCCI_PORT_STATISTICS *port_total = &eemcs_statistics[0]->port_total[i];
pos += sprintf(buf+pos, "%15s | %7d | %7d | %3d(%4d) | %8d | %8d | %7d | %7d |\n",
ccci_port_name[i], port->cnt[TX], port->cnt[RX],
port->queue[RX], port_total->queue[RX],
port_total->cnt[TX], port_total->cnt[RX],
port_total->drop[TX], port_total->drop[RX]
);
}
return pos;
}
示例9: balong_rtc_readalarm
/**
* balong_rtc_readalarm-read rtc alarm
*/
s32 balong_rtc_readalarm(struct device *dev, struct rtc_wkalrm *alarm)
{
rtc_time_to_tm(readl(g_rtc_ctrl.rtc_base_addr + HI_RTC_CMR_OFFSET), &alarm->time);
alarm->pending = readl(g_rtc_ctrl.rtc_base_addr + HI_RTC_CCR_OFFSET) & RTC_BIT_AI;
if(readl(g_rtc_ctrl.rtc_base_addr + HI_RTC_CCR_OFFSET)&RTC_BIT_IM)
{
alarm->enabled = ALARM_DISABLED;
}
else
{
alarm->enabled = ALARM_ENABLE;
}
return BSP_OK;
}
开发者ID:fly2436732935,项目名称:android_kernel_honor7_PLK-AL10_PLK-TL01H_PLK-UL00_PLK-CL00_PLK-TL00,代码行数:18,代码来源:rtc_balong.c
示例10: alarm_set_rtc_ring
int alarm_set_rtc_ring(struct timespec alarm_time)
{
struct rtc_wkalrm rtc_alarm;
unsigned long rtc_alarm_time;
if (pwr_rtc_dev != NULL) {
rtc_alarm_time = alarm_time.tv_sec;
pr_alarm(INT, "%s, alarm time: %lu\n",
__func__, rtc_alarm_time);
rtc_time_to_tm(rtc_alarm_time, &rtc_alarm.time);
rtc_alarm.enabled = 1;
rtc_set_alarm(pwr_rtc_dev, &rtc_alarm);
}
return 0;
}
示例11: puv3_rtc_getalarm
static int puv3_rtc_getalarm(struct device *dev, struct rtc_wkalrm *alrm)
{
struct rtc_time *alm_tm = &alrm->time;
rtc_time_to_tm(readl(RTC_RTAR), alm_tm);
alrm->enabled = readl(RTC_RTSR) & RTC_RTSR_ALE;
pr_debug("read alarm %02x %02x.%02x.%02x %02x/%02x/%02x\n",
alrm->enabled,
alm_tm->tm_year, alm_tm->tm_mon, alm_tm->tm_mday,
alm_tm->tm_hour, alm_tm->tm_min, alm_tm->tm_sec);
return 0;
}
示例12: lpc32xx_rtc_read_alarm
static int lpc32xx_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *wkalrm)
{
unsigned long alarmsecs;
struct rtc_time *time = &wkalrm->time;
struct platform_device *pdev = to_platform_device(dev);
struct lpc32xx_rtc_priv *lpc32xx_rtc_dat = platform_get_drvdata(pdev);
/* Read alarm match register */
alarmsecs = __raw_readl(RTC_MATCH0(lpc32xx_rtc_dat->rtc_base));
wkalrm->enabled = lpc32xx_rtc_dat->alarm_enabled;
rtc_time_to_tm(alarmsecs, time);
return 0;
}
示例13: tegra_rtc_read_time
static int tegra_rtc_read_time(struct device *dev, struct rtc_time *tm)
{
NvU32 now;
if (hPmu == NULL)
return -1;
if (!NvOdmPmuReadRtc(hPmu, &now)) {
printk("NvOdmPmuReadRtc failed\n");
return -1;
}
rtc_time_to_tm(now, tm);
return 0;
}
示例14: ls1x_rtc_read_time
static int ls1x_rtc_read_time(struct device *dev, struct rtc_time *rtm)
{
unsigned long v, t;
v = readl(SYS_TOYREAD0);
t = readl(SYS_TOYREAD1);
memset(rtm, 0, sizeof(struct rtc_time));
t = mktime((t & LS1X_YEAR_MASK), ls1x_get_month(v),
ls1x_get_day(v), ls1x_get_hour(v),
ls1x_get_min(v), ls1x_get_sec(v));
rtc_time_to_tm(t, rtm);
return 0;
}
示例15: 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;
}