netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] testptp: set pin function before other requests
@ 2022-01-05 15:25 Miroslav Lichvar
  2022-01-05 15:44 ` Vladimir Oltean
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Miroslav Lichvar @ 2022-01-05 15:25 UTC (permalink / raw)
  To: netdev; +Cc: Miroslav Lichvar, Richard Cochran, Vladimir Oltean

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(-)

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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] testptp: set pin function before other requests
  2022-01-05 15:25 [PATCH net-next] testptp: set pin function before other requests Miroslav Lichvar
@ 2022-01-05 15:44 ` Vladimir Oltean
  2022-01-05 20:09 ` Richard Cochran
  2022-01-06  1:20 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Vladimir Oltean @ 2022-01-05 15:44 UTC (permalink / raw)
  To: Miroslav Lichvar; +Cc: netdev, Richard Cochran

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
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] testptp: set pin function before other requests
  2022-01-05 15:25 [PATCH net-next] testptp: set pin function before other requests Miroslav Lichvar
  2022-01-05 15:44 ` Vladimir Oltean
@ 2022-01-05 20:09 ` Richard Cochran
  2022-01-06  1:20 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Richard Cochran @ 2022-01-05 20:09 UTC (permalink / raw)
  To: Miroslav Lichvar; +Cc: netdev, Vladimir Oltean

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>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] testptp: set pin function before other requests
  2022-01-05 15:25 [PATCH net-next] testptp: set pin function before other requests Miroslav Lichvar
  2022-01-05 15:44 ` Vladimir Oltean
  2022-01-05 20:09 ` Richard Cochran
@ 2022-01-06  1:20 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-01-06  1:20 UTC (permalink / raw)
  To: Miroslav Lichvar; +Cc: netdev, richardcochran, olteanv

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!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-01-06  1:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-05 15:25 [PATCH net-next] testptp: set pin function before other requests Miroslav Lichvar
2022-01-05 15:44 ` Vladimir Oltean
2022-01-05 20:09 ` Richard Cochran
2022-01-06  1:20 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).