Lines Matching +full:timeout +full:- +full:ms
1 // SPDX-License-Identifier: GPL-2.0-only
16 * Execute a function while the UIP (Update-in-progress) bit of the RTC is
17 * unset. The timeout is configurable by the caller in ms.
22 int timeout, in mc146818_avoid_UIP() argument
29 for (i = 0; UIP_RECHECK_LOOPS_MS(i) < timeout; i++) { in mc146818_avoid_UIP()
34 * readout is unspecified. The maximum update time is ~2ms. Poll in mc146818_avoid_UIP()
81 pr_warn("Reading current time from RTC took around %li ms\n", in mc146818_avoid_UIP()
91 * If the UIP (Update-in-progress) bit of the RTC is set for more then
92 * 10ms, the RTC is apparently broken or not present.
119 * by the RTC when initially set to a non-zero value. in mc146818_get_time_callback()
121 p->time->tm_sec = seconds; in mc146818_get_time_callback()
122 p->time->tm_min = CMOS_READ(RTC_MINUTES); in mc146818_get_time_callback()
123 p->time->tm_hour = CMOS_READ(RTC_HOURS); in mc146818_get_time_callback()
124 p->time->tm_mday = CMOS_READ(RTC_DAY_OF_MONTH); in mc146818_get_time_callback()
125 p->time->tm_mon = CMOS_READ(RTC_MONTH); in mc146818_get_time_callback()
126 p->time->tm_year = CMOS_READ(RTC_YEAR); in mc146818_get_time_callback()
128 p->real_year = CMOS_READ(RTC_DEC_YEAR); in mc146818_get_time_callback()
133 p->century = CMOS_READ(acpi_gbl_FADT.century); in mc146818_get_time_callback()
135 p->century = 0; in mc146818_get_time_callback()
139 p->ctrl = CMOS_READ(RTC_CONTROL); in mc146818_get_time_callback()
143 * mc146818_get_time - Get the current time from the RTC
145 * @timeout: timeout value in ms
148 * provided struct rtc_time. The timeout parameter specifies the maximum
151 * Return: 0 on success, -ETIMEDOUT if the RTC did not become ready within
152 * the specified timeout, or another error code if an error occurred.
154 int mc146818_get_time(struct rtc_time *time, int timeout) in mc146818_get_time() argument
160 if (!mc146818_avoid_UIP(mc146818_get_time_callback, timeout, &p)) { in mc146818_get_time()
162 return -ETIMEDOUT; in mc146818_get_time()
167 time->tm_sec = bcd2bin(time->tm_sec); in mc146818_get_time()
168 time->tm_min = bcd2bin(time->tm_min); in mc146818_get_time()
169 time->tm_hour = bcd2bin(time->tm_hour); in mc146818_get_time()
170 time->tm_mday = bcd2bin(time->tm_mday); in mc146818_get_time()
171 time->tm_mon = bcd2bin(time->tm_mon); in mc146818_get_time()
172 time->tm_year = bcd2bin(time->tm_year); in mc146818_get_time()
179 time->tm_year += p.real_year - 72; in mc146818_get_time()
184 time->tm_year += (p.century - 19) * 100; in mc146818_get_time()
191 if (time->tm_year <= 69) in mc146818_get_time()
192 time->tm_year += 100; in mc146818_get_time()
194 time->tm_mon--; in mc146818_get_time()
223 yrs = time->tm_year; in mc146818_set_time()
224 mon = time->tm_mon + 1; /* tm_mon starts at zero */ in mc146818_set_time()
225 day = time->tm_mday; in mc146818_set_time()
226 hrs = time->tm_hour; in mc146818_set_time()
227 min = time->tm_min; in mc146818_set_time()
228 sec = time->tm_sec; in mc146818_set_time()
231 return -EINVAL; in mc146818_set_time()
241 * for non-leap years, so that Feb, 29th is handled in mc146818_set_time()
245 real_yrs--; in mc146818_set_time()
262 return -EINVAL; in mc146818_set_time()
265 yrs -= 100; in mc146818_set_time()