diff options
Diffstat (limited to 'hwclock')
-rw-r--r-- | hwclock/rtc.c | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/hwclock/rtc.c b/hwclock/rtc.c index f8e626eb8..724daf99e 100644 --- a/hwclock/rtc.c +++ b/hwclock/rtc.c @@ -104,24 +104,21 @@ open_rtc(void) { "/dev/misc/rtc", NULL }; - char **p = fls; - char *fname = rtc_dev_name ? : *p; - - do { - int fd = open(fname, O_RDONLY); - - if (fd < 0 && errno == ENOENT) { - if (fname == rtc_dev_name) - break; - fname = *++p; - } else { - rtc_dev_name = *p; - return fd; - } - } while(fname); - - if (!rtc_dev_name) - rtc_dev_name = *fls; + char **p; + + /* --rtc option has been given */ + if (rtc_dev_name) + return open(rtc_dev_name, O_RDONLY); + + for (p=fls; *p; ++p) { + int fd = open(*p, O_RDONLY); + + if (fd < 0 && errno == ENOENT) + continue; + rtc_dev_name = *p; + return fd; + } + rtc_dev_name = *fls; /* default */ return -1; } |