phc2sys: Use phc_open().

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
master
Miroslav Lichvar 2013-04-08 15:44:07 +02:00 committed by Richard Cochran
parent 5835effd2a
commit d5cf47f7f6
1 changed files with 4 additions and 6 deletions

View File

@ -61,7 +61,7 @@ static int update_sync_offset(struct clock *clock, int64_t offset, uint64_t ts);
static clockid_t clock_open(char *device) static clockid_t clock_open(char *device)
{ {
int fd; int clkid;
if (device[0] != '/') { if (device[0] != '/') {
if (!strcasecmp(device, "CLOCK_REALTIME")) if (!strcasecmp(device, "CLOCK_REALTIME"))
@ -71,12 +71,10 @@ static clockid_t clock_open(char *device)
return CLOCK_INVALID; return CLOCK_INVALID;
} }
fd = open(device, O_RDWR); clkid = phc_open(device);
if (fd < 0) { if (clkid == CLOCK_INVALID)
fprintf(stderr, "cannot open %s: %m\n", device); fprintf(stderr, "cannot open %s: %m\n", device);
return CLOCK_INVALID; return clkid;
}
return FD_TO_CLOCKID(fd);
} }
static int read_phc(clockid_t clkid, clockid_t sysclk, int readings, static int read_phc(clockid_t clkid, clockid_t sysclk, int readings,