* [PATCH net-next V2] Let the ADJ_OFFSET interface respect the ADJ_NANO flag for PHC devices.
@ 2020-05-24 18:27 Richard Cochran
2020-05-24 19:13 ` Vincent Cheng
2020-05-26 0:55 ` David Miller
0 siblings, 2 replies; 3+ messages in thread
From: Richard Cochran @ 2020-05-24 18:27 UTC (permalink / raw)
To: netdev; +Cc: David Miller, Miroslav Lichvar, John Stultz, Vincent Cheng
In commit 184ecc9eb260d5a3bcdddc5bebd18f285ac004e9 ("ptp: Add adjphase
function to support phase offset control.") the PTP Hardware Clock
interface expanded to support the ADJ_OFFSET offset mode. However,
the implementation did not respect the traditional yet pedantic
distinction between units of microseconds and nanoseconds signaled by
the ADJ_NANO flag. This patch fixes the issue by adding logic to
handle that flag.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
---
drivers/ptp/ptp_clock.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/ptp/ptp_clock.c b/drivers/ptp/ptp_clock.c
index fc984a8828fb..03a246e60fd9 100644
--- a/drivers/ptp/ptp_clock.c
+++ b/drivers/ptp/ptp_clock.c
@@ -147,8 +147,14 @@ static int ptp_clock_adjtime(struct posix_clock *pc, struct __kernel_timex *tx)
err = ops->adjfreq(ops, ppb);
ptp->dialed_frequency = tx->freq;
} else if (tx->modes & ADJ_OFFSET) {
- if (ops->adjphase)
- err = ops->adjphase(ops, tx->offset);
+ if (ops->adjphase) {
+ s32 offset = tx->offset;
+
+ if (!(tx->modes & ADJ_NANO))
+ offset *= NSEC_PER_USEC;
+
+ err = ops->adjphase(ops, offset);
+ }
} else if (tx->modes == 0) {
tx->freq = ptp->dialed_frequency;
err = 0;
--
2.20.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net-next V2] Let the ADJ_OFFSET interface respect the ADJ_NANO flag for PHC devices.
2020-05-24 18:27 [PATCH net-next V2] Let the ADJ_OFFSET interface respect the ADJ_NANO flag for PHC devices Richard Cochran
@ 2020-05-24 19:13 ` Vincent Cheng
2020-05-26 0:55 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: Vincent Cheng @ 2020-05-24 19:13 UTC (permalink / raw)
To: Richard Cochran; +Cc: netdev, David Miller, Miroslav Lichvar, John Stultz
On Sun, May 24, 2020 at 02:27:10PM EDT, Richard Cochran wrote:
>In commit 184ecc9eb260d5a3bcdddc5bebd18f285ac004e9 ("ptp: Add adjphase
>function to support phase offset control.") the PTP Hardware Clock
>interface expanded to support the ADJ_OFFSET offset mode. However,
>the implementation did not respect the traditional yet pedantic
>distinction between units of microseconds and nanoseconds signaled by
>the ADJ_NANO flag. This patch fixes the issue by adding logic to
>handle that flag.
>
>Signed-off-by: Richard Cochran <richardcochran@gmail.com>
>---
> drivers/ptp/ptp_clock.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
>diff --git a/drivers/ptp/ptp_clock.c b/drivers/ptp/ptp_clock.c
>index fc984a8828fb..03a246e60fd9 100644
>--- a/drivers/ptp/ptp_clock.c
>+++ b/drivers/ptp/ptp_clock.c
>@@ -147,8 +147,14 @@ static int ptp_clock_adjtime(struct posix_clock *pc, struct __kernel_timex *tx)
> err = ops->adjfreq(ops, ppb);
> ptp->dialed_frequency = tx->freq;
> } else if (tx->modes & ADJ_OFFSET) {
>- if (ops->adjphase)
>- err = ops->adjphase(ops, tx->offset);
>+ if (ops->adjphase) {
>+ s32 offset = tx->offset;
>+
>+ if (!(tx->modes & ADJ_NANO))
>+ offset *= NSEC_PER_USEC;
>+
>+ err = ops->adjphase(ops, offset);
>+ }
> } else if (tx->modes == 0) {
> tx->freq = ptp->dialed_frequency;
> err = 0;
>--
Hi Richard,
Oops. Thank-you for the fix.
Thanks,
Vincent
Reviewed-by: Vincent Cheng <vincent.cheng.xh@renesas.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next V2] Let the ADJ_OFFSET interface respect the ADJ_NANO flag for PHC devices.
2020-05-24 18:27 [PATCH net-next V2] Let the ADJ_OFFSET interface respect the ADJ_NANO flag for PHC devices Richard Cochran
2020-05-24 19:13 ` Vincent Cheng
@ 2020-05-26 0:55 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2020-05-26 0:55 UTC (permalink / raw)
To: richardcochran; +Cc: netdev, mlichvar, john.stultz, vincent.cheng.xh
From: Richard Cochran <richardcochran@gmail.com>
Date: Sun, 24 May 2020 11:27:10 -0700
> In commit 184ecc9eb260d5a3bcdddc5bebd18f285ac004e9 ("ptp: Add adjphase
> function to support phase offset control.") the PTP Hardware Clock
> interface expanded to support the ADJ_OFFSET offset mode. However,
> the implementation did not respect the traditional yet pedantic
> distinction between units of microseconds and nanoseconds signaled by
> the ADJ_NANO flag. This patch fixes the issue by adding logic to
> handle that flag.
>
> Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Applied, thanks Richard.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-05-26 0:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-05-24 18:27 [PATCH net-next V2] Let the ADJ_OFFSET interface respect the ADJ_NANO flag for PHC devices Richard Cochran
2020-05-24 19:13 ` Vincent Cheng
2020-05-26 0:55 ` David Miller
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).