From: Richard Cochran <richardcochran@gmail•com>
To: netdev@vger•kernel.org
Cc: David Miller <davem@davemloft•net>,
Miroslav Lichvar <mlichvar@redhat•com>,
John Stultz <john.stultz@linaro•org>,
Vincent Cheng <vincent.cheng.xh@renesas•com>
Subject: [PATCH net-next V2] Let the ADJ_OFFSET interface respect the ADJ_NANO flag for PHC devices.
Date: Sun, 24 May 2020 11:27:10 -0700 [thread overview]
Message-ID: <20200524182710.576-1-richardcochran@gmail.com> (raw)
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
next reply other threads:[~2020-05-24 18:28 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-24 18:27 Richard Cochran [this message]
2020-05-24 19:13 ` [PATCH net-next V2] Let the ADJ_OFFSET interface respect the ADJ_NANO flag for PHC devices Vincent Cheng
2020-05-26 0:55 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200524182710.576-1-richardcochran@gmail.com \
--to=richardcochran@gmail$(echo .)com \
--cc=davem@davemloft$(echo .)net \
--cc=john.stultz@linaro$(echo .)org \
--cc=mlichvar@redhat$(echo .)com \
--cc=netdev@vger$(echo .)kernel.org \
--cc=vincent.cheng.xh@renesas$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox