diff --git a/phc2sys.c b/phc2sys.c index cd91966..62248e7 100644 --- a/phc2sys.c +++ b/phc2sys.c @@ -85,7 +85,8 @@ static void clock_step(clockid_t clkid, int64_t ns) fprintf(stderr, "failed to step clock: %m\n"); } -static int read_phc(clockid_t clkid, clockid_t sysclk, int rdelay, int readings, int64_t *offset, uint64_t *ts) +static int read_phc(clockid_t clkid, clockid_t sysclk, int readings, + int64_t *offset, uint64_t *ts) { struct timespec tdst1, tdst2, tsrc; int i; @@ -106,8 +107,7 @@ static int read_phc(clockid_t clkid, clockid_t sysclk, int rdelay, int readings, if (best_interval > interval) { best_interval = interval; *offset = (tdst1.tv_sec - tsrc.tv_sec) * NS_PER_SEC + - tdst1.tv_nsec - tsrc.tv_nsec + - interval / 2 - rdelay; + tdst1.tv_nsec - tsrc.tv_nsec + interval / 2; *ts = tdst2.tv_sec * NS_PER_SEC + tdst2.tv_nsec; } } @@ -199,7 +199,6 @@ static void usage(char *progname) " -c [device] slave clock device, default CLOCK_REALTIME\n" " -d [device] master device, source of PPS events\n" " -h prints this message and exits\n" - " -r [val] reading the PHC device takes 'val' nanoseconds\n" " -s [device] set the time from this PHC device\n" " -P [val] set proportional constant to 'val'\n" " -I [val] set integration constant to 'val'\n" @@ -216,12 +215,12 @@ int main(int argc, char *argv[]) clockid_t src = CLOCK_INVALID, dst = CLOCK_REALTIME; uint64_t pps_ts, phc_ts; int64_t pps_offset, phc_offset; - int c, fd = 0, rdelay = 0, phc_readings = 5, phc_rate = 1; + int c, fd = 0, phc_readings = 5, phc_rate = 1; /* Process the command line arguments. */ progname = strrchr(argv[0], '/'); progname = progname ? 1+progname : argv[0]; - while (EOF != (c = getopt(argc, argv, "c:d:hr:s:P:I:R:N:"))) { + while (EOF != (c = getopt(argc, argv, "c:d:hs:P:I:R:N:"))) { switch (c) { case 'c': dst = clock_open(optarg); @@ -229,9 +228,6 @@ int main(int argc, char *argv[]) case 'd': device = optarg; break; - case 'r': - rdelay = atoi(optarg); - break; case 's': src = clock_open(optarg); break; @@ -283,7 +279,7 @@ int main(int argc, char *argv[]) usleep(1000000 / phc_rate); if (src != CLOCK_INVALID) { - if (!read_phc(src, dst, rdelay, phc_readings, &phc_offset, &phc_ts)) + if (!read_phc(src, dst, phc_readings, &phc_offset, &phc_ts)) continue; printf("phc %9lld ", phc_offset); }