Commit 87eee9c5 authored by Miroslav Lichvar's avatar Miroslav Lichvar Committed by Jakub Kicinski
Browse files

testptp: set pin function before other requests



When the -L option of the testptp utility is specified with other
options (e.g. -p to enable PPS output), the user probably wants to
apply it to the pin configured by the -L option.

Reorder the code to set the pin function before other function requests
to avoid confusing users.

Signed-off-by: default avatarMiroslav Lichvar <mlichvar@redhat.com>
Reviewed-by: default avatarVladimir Oltean <olteanv@gmail.com>
Acked-by: default avatarRichard Cochran <richardcochran@gmail.com>
Link: https://lore.kernel.org/r/20220105152506.3256026-1-mlichvar@redhat.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent b9adba35
Loading
Loading
Loading
Loading
+12 −12
Original line number Diff line number Diff line
@@ -354,6 +354,18 @@ int main(int argc, char *argv[])
		}
	}

	if (pin_index >= 0) {
		memset(&desc, 0, sizeof(desc));
		desc.index = pin_index;
		desc.func = pin_func;
		desc.chan = index;
		if (ioctl(fd, PTP_PIN_SETFUNC, &desc)) {
			perror("PTP_PIN_SETFUNC");
		} else {
			puts("set pin function okay");
		}
	}

	if (extts) {
		memset(&extts_request, 0, sizeof(extts_request));
		extts_request.index = index;
@@ -444,18 +456,6 @@ int main(int argc, char *argv[])
		}
	}

	if (pin_index >= 0) {
		memset(&desc, 0, sizeof(desc));
		desc.index = pin_index;
		desc.func = pin_func;
		desc.chan = index;
		if (ioctl(fd, PTP_PIN_SETFUNC, &desc)) {
			perror("PTP_PIN_SETFUNC");
		} else {
			puts("set pin function okay");
		}
	}

	if (pps != -1) {
		int enable = pps ? 1 : 0;
		if (ioctl(fd, PTP_ENABLE_PPS, enable)) {