Lines 163-169
Link Here
|
163 |
return dev->si_drv1; |
163 |
return dev->si_drv1; |
164 |
} |
164 |
} |
165 |
|
165 |
|
166 |
MALLOC(sc, struct rtc_softc*, sizeof(*sc), M_DEVBUF, M_WAITOK); |
166 |
sc = malloc(sizeof(*sc), M_DEVBUF, M_WAITOK); |
167 |
if (sc==NULL) |
167 |
if (sc==NULL) |
168 |
return NULL; |
168 |
return NULL; |
169 |
|
169 |
|
Lines 196-202
Link Here
|
196 |
} |
196 |
} |
197 |
|
197 |
|
198 |
callout_stop(&sc->var.rtc_handle); |
198 |
callout_stop(&sc->var.rtc_handle); |
199 |
FREE(sc, M_DEVBUF); |
199 |
free(sc, M_DEVBUF); |
200 |
dev->si_drv1 = NULL; |
200 |
dev->si_drv1 = NULL; |
201 |
return error; |
201 |
return error; |
202 |
} |
202 |
} |
Lines 433-454
Link Here
|
433 |
restart: |
433 |
restart: |
434 |
increment.tv_sec = 0; |
434 |
increment.tv_sec = 0; |
435 |
increment.tv_nsec = 1000000000 / sc->var.freq; |
435 |
increment.tv_nsec = 1000000000 / sc->var.freq; |
436 |
timespecadd(&sc->var.lasttime, &increment); |
436 |
#if P_OSREL_MAJOR(__FreeBSD_version) >= 12 |
437 |
nexttime.tv_sec = sc->var.lasttime.tv_sec; |
437 |
timespecadd(&sc->var.lasttime, &increment, &sc->var.lasttime); |
438 |
nexttime.tv_nsec = sc->var.lasttime.tv_nsec; |
438 |
timespecadd(&sc->var.lasttime, &increment, &nexttime); |
439 |
timespecadd(&nexttime, &increment); |
439 |
#else |
|
|
440 |
timespecadd(&sc->var.lasttime, &increment); |
441 |
nexttime.tv_sec = sc->var.lasttime.tv_sec; |
442 |
nexttime.tv_nsec = sc->var.lasttime.tv_nsec; |
443 |
timespecadd(&nexttime, &increment); |
444 |
#endif |
440 |
if (timespeccmp(&nexttime, &curtime, <)) { |
445 |
if (timespeccmp(&nexttime, &curtime, <)) { |
441 |
/* Catch up if we lag curtime */ |
446 |
/* Catch up if we lag curtime */ |
442 |
sc->var.lasttime.tv_sec = curtime.tv_sec; |
447 |
#if P_OSREL_MAJOR(__FreeBSD_version) >= 12 |
443 |
sc->var.lasttime.tv_nsec = curtime.tv_nsec; |
448 |
timespecsub(&curtime, &increment, &sc->var.lasttime); |
444 |
timespecsub(&sc->var.lasttime, &increment); |
449 |
timespecsub(&nexttime, &curtime, &nexttime); |
445 |
timespecsub(&nexttime, &curtime); |
450 |
#else |
|
|
451 |
sc->var.lasttime.tv_sec = curtime.tv_sec; |
452 |
sc->var.lasttime.tv_nsec = curtime.tv_nsec; |
453 |
timespecsub(&sc->var.lasttime, &increment); |
454 |
timespecsub(&nexttime, &curtime); |
455 |
#endif |
446 |
#if 0 |
456 |
#if 0 |
447 |
printf("lagging curtime by %d.%ld\n", nexttime.tv_sec, nexttime.tv_nsec); |
457 |
printf("lagging curtime by %d.%ld\n", nexttime.tv_sec, nexttime.tv_nsec); |
448 |
#endif |
458 |
#endif |
449 |
goto restart; |
459 |
goto restart; |
450 |
} else { |
460 |
} else { |
|
|
461 |
#if P_OSREL_MAJOR(__FreeBSD_version) >= 12 |
462 |
timespecsub(&nexttime, &curtime, &nexttime); |
463 |
#else |
451 |
timespecsub(&nexttime, &curtime); |
464 |
timespecsub(&nexttime, &curtime); |
|
|
465 |
#endif |
452 |
sleep = nexttime.tv_nsec / (1000000000 / hz); |
466 |
sleep = nexttime.tv_nsec / (1000000000 / hz); |
453 |
} |
467 |
} |
454 |
callout_reset(&sc->var.rtc_handle, sleep, &rtc_callback, xtp); |
468 |
callout_reset(&sc->var.rtc_handle, sleep, &rtc_callback, xtp); |