| 289 | } |
| 290 | |
| 291 | static int |
| 292 | read_clocks(struct timespec *ts, bool debug_read) |
| 293 | { |
| 294 | struct rtc_instance *rtc; |
| 295 | int error; |
| 296 | |
| 297 | error = ENXIO; |
| 298 | sx_xlock(&rtc_list_lock); |
| 299 | LIST_FOREACH(rtc, &rtc_list, rtc_entries) { |
| 300 | if ((error = CLOCK_GETTIME(rtc->clockdev, ts)) != 0) |
| 301 | continue; |
| 302 | if (ts->tv_sec < 0 || ts->tv_nsec < 0) { |
| 303 | error = EINVAL; |
| 304 | continue; |
| 305 | } |
| 306 | if (!(rtc->flags & CLOCKF_GETTIME_NO_ADJ)) { |
| 307 | timespecadd(ts, &rtc->resadj, ts); |
| 308 | ts->tv_sec += utc_offset(); |
| 309 | } |
| 310 | if (!debug_read) { |
| 311 | if (bootverbose) |
| 312 | device_printf(rtc->clockdev, |
| 313 | "providing initial system time\n"); |
| 314 | break; |
| 315 | } |
| 316 | } |
| 317 | sx_xunlock(&rtc_list_lock); |
| 318 | return (error); |
| 319 | } |
| 320 | |
| 321 | /* |
| 322 | * Initialize the system time. Must be called from a context which does not |
no test coverage detected