Lines Matching defs:tm
57 static void regs_to_tm(u8 *regs, struct rtc_time *tm)
59 tm->tm_year = bcd2bin(regs[RTC_YEAR2]) * 100 +
61 tm->tm_mon = bcd2bin(regs[RTC_MONTH] & 0x1f) - 1;
62 tm->tm_mday = bcd2bin(regs[RTC_DATE] & 0x3f);
63 tm->tm_wday = (regs[RTC_WEEKDAY] & 0x07);
65 tm->tm_hour = bcd2bin(regs[RTC_HOUR] & 0x01f);
66 if (tm->tm_hour == 12)
67 tm->tm_hour = 0;
69 tm->tm_hour += 12;
71 tm->tm_hour = bcd2bin(regs[RTC_HOUR] & 0x03f);
73 tm->tm_min = bcd2bin(regs[RTC_MIN] & 0x7f);
74 tm->tm_sec = bcd2bin(regs[RTC_SEC] & 0x7f);
77 static void tm_to_regs(struct rtc_time *tm, u8 *regs)
81 high = (tm->tm_year + 1900) / 100;
82 low = tm->tm_year % 100;
85 regs[RTC_MONTH] = bin2bcd(tm->tm_mon + 1);
86 regs[RTC_DATE] = bin2bcd(tm->tm_mday);
87 regs[RTC_WEEKDAY] = tm->tm_wday;
88 regs[RTC_HOUR] = bin2bcd(tm->tm_hour);
89 regs[RTC_MIN] = bin2bcd(tm->tm_min);
90 regs[RTC_SEC] = bin2bcd(tm->tm_sec);
93 static int max8907_rtc_read_time(struct device *dev, struct rtc_time *tm)
104 regs_to_tm(regs, tm);
109 static int max8907_rtc_set_time(struct device *dev, struct rtc_time *tm)
114 tm_to_regs(tm, regs);