]> git.baikalelectronics.ru Git - kernel.git/commitdiff
ptp_clock: Let the ADJ_OFFSET interface respect the ADJ_NANO flag for PHC devices.
authorRichard Cochran <richardcochran@gmail.com>
Sun, 24 May 2020 18:27:10 +0000 (11:27 -0700)
committerDavid S. Miller <davem@davemloft.net>
Tue, 26 May 2020 00:55:17 +0000 (17:55 -0700)
In commit 9c3e0a7e1bab9db1167d61bd6ee35b7eb45acc4a ("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>
Reviewed-by: Vincent Cheng <vincent.cheng.xh@renesas.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/ptp/ptp_clock.c

index fc984a8828fb0b5d3cdc90567d3a68f1a43dd457..03a246e60fd986a5d5e744dccd18304f90259af7 100644 (file)
@@ -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;