From d5cf47f7f6ad67833b6e731ed858732576f2079e Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Mon, 8 Apr 2013 15:44:07 +0200 Subject: [PATCH] phc2sys: Use phc_open(). Signed-off-by: Miroslav Lichvar --- phc2sys.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/phc2sys.c b/phc2sys.c index cab5c9a..ab35fb1 100644 --- a/phc2sys.c +++ b/phc2sys.c @@ -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) { - int fd; + int clkid; if (device[0] != '/') { if (!strcasecmp(device, "CLOCK_REALTIME")) @@ -71,12 +71,10 @@ static clockid_t clock_open(char *device) return CLOCK_INVALID; } - fd = open(device, O_RDWR); - if (fd < 0) { + clkid = phc_open(device); + if (clkid == CLOCK_INVALID) fprintf(stderr, "cannot open %s: %m\n", device); - return CLOCK_INVALID; - } - return FD_TO_CLOCKID(fd); + return clkid; } static int read_phc(clockid_t clkid, clockid_t sysclk, int readings,