Let the ADJ_OFFSET interface respect the STA_NANO flag for PHC devices.
Subsystems (3)
Richard Cochran
maintainerPATCH 1/1 Let the ADJ_OFFSET interface respect the STA_NANO flag for PHC devices.
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 STA_NANO flag. This patch fixes the issue by adding logic to handle that flag.
Signed-off-by Richard Cochran <[email protected]>
--- drivers/ptp/ptp_clock.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/ptp/ptp_clock.c +7 -2
@@ -147,8 +147,13 @@ 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->status &STA_NANO )) { + offset *=NSEC_PER_USEC ; + } + err = ops->adjphase (ops, offset); + } }else if (tx->modes ==0 ) { tx->freq = ptp->dialed_frequency; err =0 ;
Signature · 1 line
2.20.1
Richard Cochran
maintainerdrivers/ptp/ptp_clock.c static int ptp_clock_adjtime(struct posix_clock *pc, struct __kernel_timex *tx) · line 153
Quoted 10 lines · Richard Cochran
drivers/ptp/ptp_clock.c +4
-2@@ -147,8 +147,13 @@ 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->status &STA_NANO )) { + offset *=NSEC_PER_USEC ;
Oh man. This should check for ADJ_NANO instead. V2 follows soon...
Thanks,
Richard