diff mbox series

[net-next] testptp: set pin function before other requests

Message ID 20220105152506.3256026-1-mlichvar@redhat.com (mailing list archive)
State Accepted
Commit 87eee9c5589e1e546537a38a72e7ea3f0a7cac60
Delegated to: Netdev Maintainers
Headers show
Series [net-next] testptp: set pin function before other requests | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers fail 2 maintainers not CCed: linux-kselftest@vger.kernel.org shuah@kernel.org
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 36 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Miroslav Lichvar Jan. 5, 2022, 3:25 p.m. UTC
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: Miroslav Lichvar <mlichvar@redhat.com>
Cc: Richard Cochran <richardcochran@gmail.com>
Cc: Vladimir Oltean <olteanv@gmail.com>
---
 tools/testing/selftests/ptp/testptp.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

Comments

Vladimir Oltean Jan. 5, 2022, 3:44 p.m. UTC | #1
On Wed, Jan 05, 2022 at 04:25:06PM +0100, Miroslav Lichvar wrote:
> 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: Miroslav Lichvar <mlichvar@redhat.com>
> Cc: Richard Cochran <richardcochran@gmail.com>
> Cc: Vladimir Oltean <olteanv@gmail.com>
> ---

This makes sense. Looking back at my logs, I was setting the pin
function via sysfs, but if the code was structured differently I could
have done it in a single command using testptp. Not sure why I didn't
think of that.

Reviewed-by: Vladimir Oltean <olteanv@gmail.com>

>  tools/testing/selftests/ptp/testptp.c | 24 ++++++++++++------------
>  1 file changed, 12 insertions(+), 12 deletions(-)
> 
> diff --git a/tools/testing/selftests/ptp/testptp.c b/tools/testing/selftests/ptp/testptp.c
> index f7911aaeb007..c0f6a062364d 100644
> --- a/tools/testing/selftests/ptp/testptp.c
> +++ b/tools/testing/selftests/ptp/testptp.c
> @@ -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)) {
> -- 
> 2.33.1
>
Richard Cochran Jan. 5, 2022, 8:09 p.m. UTC | #2
On Wed, Jan 05, 2022 at 04:25:06PM +0100, Miroslav Lichvar wrote:
> 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.

Acked-by: Richard Cochran <richardcochran@gmail.com>
patchwork-bot+netdevbpf@kernel.org Jan. 6, 2022, 1:20 a.m. UTC | #3
Hello:

This patch was applied to netdev/net-next.git (master)
by Jakub Kicinski <kuba@kernel.org>:

On Wed,  5 Jan 2022 16:25:06 +0100 you wrote:
> 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.
> 
> [...]

Here is the summary with links:
  - [net-next] testptp: set pin function before other requests
    https://git.kernel.org/netdev/net-next/c/87eee9c5589e

You are awesome, thank you!
diff mbox series

Patch

diff --git a/tools/testing/selftests/ptp/testptp.c b/tools/testing/selftests/ptp/testptp.c
index f7911aaeb007..c0f6a062364d 100644
--- a/tools/testing/selftests/ptp/testptp.c
+++ b/tools/testing/selftests/ptp/testptp.c
@@ -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)) {