Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ptp: Add a command line option in testptp to set a specific PTP time

Signed-off-by: Manfred Rudigier <manfred.rudigier@omicron.at>
Signed-off-by: Christian Riesch <christian.riesch@omicron.at>
Acked-by: Richard Cochran <richardcochran@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Manfred Rudigier and committed by
David S. Miller
271c83de b620cb3e

+18 -2
+18 -2
Documentation/ptp/testptp.c
··· 131 131 " -P val enable or disable (val=1|0) the system clock PPS\n" 132 132 " -s set the ptp clock time from the system time\n" 133 133 " -S set the system time from the ptp clock time\n" 134 - " -t val shift the ptp clock time by 'val' seconds\n", 134 + " -t val shift the ptp clock time by 'val' seconds\n" 135 + " -T val set the ptp clock time to 'val' seconds\n", 135 136 progname); 136 137 } 137 138 ··· 173 172 int perout = -1; 174 173 int pin_index = -1, pin_func; 175 174 int pps = -1; 175 + int seconds = 0; 176 176 int settime = 0; 177 177 178 178 int64_t t1, t2, tp; ··· 181 179 182 180 progname = strrchr(argv[0], '/'); 183 181 progname = progname ? 1+progname : argv[0]; 184 - while (EOF != (c = getopt(argc, argv, "a:A:cd:e:f:ghi:k:lL:p:P:sSt:v"))) { 182 + while (EOF != (c = getopt(argc, argv, "a:A:cd:e:f:ghi:k:lL:p:P:sSt:T:v"))) { 185 183 switch (c) { 186 184 case 'a': 187 185 oneshot = atoi(optarg); ··· 235 233 break; 236 234 case 't': 237 235 adjtime = atoi(optarg); 236 + break; 237 + case 'T': 238 + settime = 3; 239 + seconds = atoi(optarg); 238 240 break; 239 241 case 'h': 240 242 usage(progname); ··· 326 320 if (settime == 2) { 327 321 clock_gettime(clkid, &ts); 328 322 if (clock_settime(CLOCK_REALTIME, &ts)) { 323 + perror("clock_settime"); 324 + } else { 325 + puts("set time okay"); 326 + } 327 + } 328 + 329 + if (settime == 3) { 330 + ts.tv_sec = seconds; 331 + ts.tv_nsec = 0; 332 + if (clock_settime(clkid, &ts)) { 329 333 perror("clock_settime"); 330 334 } else { 331 335 puts("set time okay");