Commit e3d8e588 authored by Richard Cochran's avatar Richard Cochran Committed by David S. Miller

ptp: Fix example program to match kernel.

Ever since commit 3a06c7ac ("posix-clocks: Remove interval timer
facility and mmap/fasync callbacks") the possibility of PHC based
posix timers has been removed.  In addition it will probably never
make sense to implement this functionality.

This patch removes the misleading example code which seems to suggest
that posix timers for PHC devices will ever be a thing.
Signed-off-by: default avatarRichard Cochran <richardcochran@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d97c6f68
...@@ -63,30 +63,6 @@ static clockid_t get_clockid(int fd) ...@@ -63,30 +63,6 @@ static clockid_t get_clockid(int fd)
return (((unsigned int) ~fd) << 3) | CLOCKFD; return (((unsigned int) ~fd) << 3) | CLOCKFD;
} }
static void handle_alarm(int s)
{
printf("received signal %d\n", s);
}
static int install_handler(int signum, void (*handler)(int))
{
struct sigaction action;
sigset_t mask;
/* Unblock the signal. */
sigemptyset(&mask);
sigaddset(&mask, signum);
sigprocmask(SIG_UNBLOCK, &mask, NULL);
/* Install the signal handler. */
action.sa_handler = handler;
action.sa_flags = 0;
sigemptyset(&action.sa_mask);
sigaction(signum, &action, NULL);
return 0;
}
static long ppb_to_scaled_ppm(int ppb) static long ppb_to_scaled_ppm(int ppb)
{ {
/* /*
...@@ -112,8 +88,6 @@ static void usage(char *progname) ...@@ -112,8 +88,6 @@ static void usage(char *progname)
{ {
fprintf(stderr, fprintf(stderr,
"usage: %s [options]\n" "usage: %s [options]\n"
" -a val request a one-shot alarm after 'val' seconds\n"
" -A val request a periodic alarm every 'val' seconds\n"
" -c query the ptp clock's capabilities\n" " -c query the ptp clock's capabilities\n"
" -d name device to open\n" " -d name device to open\n"
" -e val read 'val' external time stamp events\n" " -e val read 'val' external time stamp events\n"
...@@ -148,15 +122,9 @@ int main(int argc, char *argv[]) ...@@ -148,15 +122,9 @@ int main(int argc, char *argv[])
struct ptp_pin_desc desc; struct ptp_pin_desc desc;
struct timespec ts; struct timespec ts;
struct timex tx; struct timex tx;
static timer_t timerid;
struct itimerspec timeout;
struct sigevent sigevent;
struct ptp_clock_time *pct; struct ptp_clock_time *pct;
struct ptp_sys_offset *sysoff; struct ptp_sys_offset *sysoff;
char *progname; char *progname;
unsigned int i; unsigned int i;
int c, cnt, fd; int c, cnt, fd;
...@@ -170,10 +138,8 @@ int main(int argc, char *argv[]) ...@@ -170,10 +138,8 @@ int main(int argc, char *argv[])
int gettime = 0; int gettime = 0;
int index = 0; int index = 0;
int list_pins = 0; int list_pins = 0;
int oneshot = 0;
int pct_offset = 0; int pct_offset = 0;
int n_samples = 0; int n_samples = 0;
int periodic = 0;
int perout = -1; int perout = -1;
int pin_index = -1, pin_func; int pin_index = -1, pin_func;
int pps = -1; int pps = -1;
...@@ -185,14 +151,8 @@ int main(int argc, char *argv[]) ...@@ -185,14 +151,8 @@ int main(int argc, char *argv[])
progname = strrchr(argv[0], '/'); progname = strrchr(argv[0], '/');
progname = progname ? 1+progname : argv[0]; progname = progname ? 1+progname : argv[0];
while (EOF != (c = getopt(argc, argv, "a:A:cd:e:f:ghi:k:lL:p:P:sSt:T:v"))) { while (EOF != (c = getopt(argc, argv, "cd:e:f:ghi:k:lL:p:P:sSt:T:v"))) {
switch (c) { switch (c) {
case 'a':
oneshot = atoi(optarg);
break;
case 'A':
periodic = atoi(optarg);
break;
case 'c': case 'c':
capabilities = 1; capabilities = 1;
break; break;
...@@ -393,49 +353,6 @@ int main(int argc, char *argv[]) ...@@ -393,49 +353,6 @@ int main(int argc, char *argv[])
} }
} }
if (oneshot) {
install_handler(SIGALRM, handle_alarm);
/* Create a timer. */
sigevent.sigev_notify = SIGEV_SIGNAL;
sigevent.sigev_signo = SIGALRM;
if (timer_create(clkid, &sigevent, &timerid)) {
perror("timer_create");
return -1;
}
/* Start the timer. */
memset(&timeout, 0, sizeof(timeout));
timeout.it_value.tv_sec = oneshot;
if (timer_settime(timerid, 0, &timeout, NULL)) {
perror("timer_settime");
return -1;
}
pause();
timer_delete(timerid);
}
if (periodic) {
install_handler(SIGALRM, handle_alarm);
/* Create a timer. */
sigevent.sigev_notify = SIGEV_SIGNAL;
sigevent.sigev_signo = SIGALRM;
if (timer_create(clkid, &sigevent, &timerid)) {
perror("timer_create");
return -1;
}
/* Start the timer. */
memset(&timeout, 0, sizeof(timeout));
timeout.it_interval.tv_sec = periodic;
timeout.it_value.tv_sec = periodic;
if (timer_settime(timerid, 0, &timeout, NULL)) {
perror("timer_settime");
return -1;
}
while (1) {
pause();
}
timer_delete(timerid);
}
if (perout >= 0) { if (perout >= 0) {
if (clock_gettime(clkid, &ts)) { if (clock_gettime(clkid, &ts)) {
perror("clock_gettime"); perror("clock_gettime");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment