static struct {
int (*init)(void);
void (*fini)(void);
- void (*time_pre_init)(void);
+ int (*time_pre_init)(void);
void (*time_init)(void (*after_hook)(void*), void *anything);
void (*start_measurements)(void);
int (*write_parameters)(void);
etc in this case, since we have fewer requirements regarding the
RTC behaviour than we do for the rest of the module. */
-void
+int
RTC_Linux_TimePreInit(void)
{
int fd, status;
fd = open(CNF_GetRtcDevice(), O_RDONLY);
if (fd < 0) {
- return; /* Can't open it, and won't be able to later */
+ return 0; /* Can't open it, and won't be able to later */
}
/* Retry reading the rtc until both read attempts give the same sec value.
/* Read system clock */
LCL_ReadCookedTime(&old_sys_time, NULL);
+ close(fd);
+
if (status >= 0) {
/* Convert to seconds since 1970 */
rtc_tm.tm_sec = rtc_raw.tm_sec;
}
} else {
LOG(LOGS_WARN, LOGF_RtcLinux, "Could not convert RTC reading to seconds since 1/1/1970");
+ return 0;
}
}
- close(fd);
+ return 1;
}
/* ================================================== */
extern int RTC_Linux_Initialise(void);
extern void RTC_Linux_Finalise(void);
-extern void RTC_Linux_TimePreInit(void);
+extern int RTC_Linux_TimePreInit(void);
extern void RTC_Linux_TimeInit(void (*after_hook)(void *), void *anything);
extern void RTC_Linux_StartMeasurements(void);