diff mbox

ptp: Allow selecting trigger/event index in testptp

Message ID 1391438187-21834-1-git-send-email-stefan.sorensen@spectralink.com
State Changes Requested, archived
Delegated to: David Miller
Headers show

Commit Message

Sørensen, Stefan Feb. 3, 2014, 2:36 p.m. UTC
Currently the trigger/event is hardcoded to 0, this patch adds
a new command line argument -i to select an arbitrary trigger/
event.

Signed-off-by: Stefan Sørensen <stefan.sorensen@spectralink.com>
---
 Documentation/ptp/testptp.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

Comments

Richard Cochran Feb. 3, 2014, 3:59 p.m. UTC | #1
On Mon, Feb 03, 2014 at 03:36:27PM +0100, Stefan Sørensen wrote:
> Currently the trigger/event is hardcoded to 0, this patch adds
> a new command line argument -i to select an arbitrary trigger/
> event.

This is a nice extension of the program, but ...

> diff --git a/Documentation/ptp/testptp.c b/Documentation/ptp/testptp.c
> index a74d0a8..04b21cd 100644
> --- a/Documentation/ptp/testptp.c
> +++ b/Documentation/ptp/testptp.c
> @@ -123,7 +123,8 @@ static void usage(char *progname)
>  		" -P val     enable or disable (val=1|0) the system clock PPS\n"
>  		" -s         set the ptp clock time from the system time\n"
>  		" -S         set the system time from the ptp clock time\n"
> -		" -t val     shift the ptp clock time by 'val' seconds\n",
> +		" -t val     shift the ptp clock time by 'val' seconds\n"
> +		" -i val     index for event/trigger\n",

can we please keep the options in alphabetical order?

Thanks,
Richard

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/Documentation/ptp/testptp.c b/Documentation/ptp/testptp.c
index a74d0a8..04b21cd 100644
--- a/Documentation/ptp/testptp.c
+++ b/Documentation/ptp/testptp.c
@@ -123,7 +123,8 @@  static void usage(char *progname)
 		" -P val     enable or disable (val=1|0) the system clock PPS\n"
 		" -s         set the ptp clock time from the system time\n"
 		" -S         set the system time from the ptp clock time\n"
-		" -t val     shift the ptp clock time by 'val' seconds\n",
+		" -t val     shift the ptp clock time by 'val' seconds\n"
+		" -i val     index for event/trigger\n",
 		progname);
 }
 
@@ -161,13 +162,14 @@  int main(int argc, char *argv[])
 	int perout = -1;
 	int pps = -1;
 	int settime = 0;
+	int index = 0;
 
 	int64_t t1, t2, tp;
 	int64_t interval, offset;
 
 	progname = strrchr(argv[0], '/');
 	progname = progname ? 1+progname : argv[0];
-	while (EOF != (c = getopt(argc, argv, "a:A:cd:e:f:ghk:p:P:sSt:v"))) {
+	while (EOF != (c = getopt(argc, argv, "a:A:cd:e:f:ghk:p:P:sSt:vi:"))) {
 		switch (c) {
 		case 'a':
 			oneshot = atoi(optarg);
@@ -209,6 +211,9 @@  int main(int argc, char *argv[])
 		case 't':
 			adjtime = atoi(optarg);
 			break;
+		case 'i':
+			index = atoi(optarg);
+			break;
 		case 'h':
 			usage(progname);
 			return 0;
@@ -301,7 +306,7 @@  int main(int argc, char *argv[])
 
 	if (extts) {
 		memset(&extts_request, 0, sizeof(extts_request));
-		extts_request.index = 0;
+		extts_request.index = index;
 		extts_request.flags = PTP_ENABLE_FEATURE;
 		if (ioctl(fd, PTP_EXTTS_REQUEST, &extts_request)) {
 			perror("PTP_EXTTS_REQUEST");
@@ -375,7 +380,7 @@  int main(int argc, char *argv[])
 			return -1;
 		}
 		memset(&perout_request, 0, sizeof(perout_request));
-		perout_request.index = 0;
+		perout_request.index = index;
 		perout_request.start.sec = ts.tv_sec + 2;
 		perout_request.start.nsec = 0;
 		perout_request.period.sec = 0;