rtc: don't finalize driver if initialization failed
This commit is contained in:
parent
25bdee7a0e
commit
a57e1eb542
2 changed files with 12 additions and 13 deletions
2
rtc.c
2
rtc.c
|
@ -160,7 +160,7 @@ RTC_Initialise(int initial_set)
|
||||||
void
|
void
|
||||||
RTC_Finalise(void)
|
RTC_Finalise(void)
|
||||||
{
|
{
|
||||||
if (driver.fini) {
|
if (driver_initialised) {
|
||||||
(driver.fini)();
|
(driver.fini)();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
23
rtc_linux.c
23
rtc_linux.c
|
@ -505,6 +505,17 @@ switch_interrupts(int on_off)
|
||||||
int
|
int
|
||||||
RTC_Linux_Initialise(void)
|
RTC_Linux_Initialise(void)
|
||||||
{
|
{
|
||||||
|
/* Try to open the device */
|
||||||
|
fd = open(CNF_GetRtcDevice(), O_RDWR);
|
||||||
|
if (fd < 0) {
|
||||||
|
LOG(LOGS_ERR, "Could not open RTC device %s : %s",
|
||||||
|
CNF_GetRtcDevice(), strerror(errno));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Close on exec */
|
||||||
|
UTI_FdSetCloexec(fd);
|
||||||
|
|
||||||
rtc_sec = MallocArray(time_t, MAX_SAMPLES);
|
rtc_sec = MallocArray(time_t, MAX_SAMPLES);
|
||||||
rtc_trim = MallocArray(double, MAX_SAMPLES);
|
rtc_trim = MallocArray(double, MAX_SAMPLES);
|
||||||
system_times = MallocArray(struct timespec, MAX_SAMPLES);
|
system_times = MallocArray(struct timespec, MAX_SAMPLES);
|
||||||
|
@ -515,18 +526,6 @@ RTC_Linux_Initialise(void)
|
||||||
/* In case it didn't get done by pre-init */
|
/* In case it didn't get done by pre-init */
|
||||||
coefs_file_name = CNF_GetRtcFile();
|
coefs_file_name = CNF_GetRtcFile();
|
||||||
|
|
||||||
/* Try to open device */
|
|
||||||
|
|
||||||
fd = open (CNF_GetRtcDevice(), O_RDWR);
|
|
||||||
if (fd < 0) {
|
|
||||||
LOG(LOGS_ERR, "Could not open RTC device %s : %s",
|
|
||||||
CNF_GetRtcDevice(), strerror(errno));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Close on exec */
|
|
||||||
UTI_FdSetCloexec(fd);
|
|
||||||
|
|
||||||
n_samples = 0;
|
n_samples = 0;
|
||||||
n_samples_since_regression = 0;
|
n_samples_since_regression = 0;
|
||||||
n_runs = 0;
|
n_runs = 0;
|
||||||
|
|
Loading…
Reference in a new issue