From: Simon Horman <horms@kernel.org>
To: Maciek Machnikowski <maciek@machnikowski.net>
Cc: netdev@vger.kernel.org, richardcochran@gmail.com,
jacob.e.keller@intel.com, vadfed@meta.com, darinzon@amazon.com,
kuba@kernel.org
Subject: Re: [RFC 1/3] ptp: Implement timex esterror support
Date: Wed, 14 Aug 2024 12:46:05 +0100 [thread overview]
Message-ID: <20240814114605.GC69536@kernel.org> (raw)
In-Reply-To: <20240813125602.155827-2-maciek@machnikowski.net>
On Tue, Aug 13, 2024 at 12:56:00PM +0000, Maciek Machnikowski wrote:
> The Timex structure returned by the clock_adjtime() POSIX API allows
> the clock to return the estimated error. Implement getesterror
> and setesterror functions in the ptp_clock_info to enable drivers
> to interact with the hardware to get the error information.
>
> getesterror additionally implements returning hw_ts and sys_ts
> to enable upper layers to estimate the maximum error of the clock
> based on the last time of correction. This functionality is not
> directly implemented in the clock_adjtime and will require
> a separate interface in the future.
>
> Signed-off-by: Maciek Machnikowski <maciek@machnikowski.net>
> ---
> drivers/ptp/ptp_clock.c | 18 +++++++++++++++++-
> include/linux/ptp_clock_kernel.h | 11 +++++++++++
> 2 files changed, 28 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/ptp/ptp_clock.c b/drivers/ptp/ptp_clock.c
> index c56cd0f63909..2cb1f6af60ea 100644
> --- a/drivers/ptp/ptp_clock.c
> +++ b/drivers/ptp/ptp_clock.c
> @@ -164,9 +164,25 @@ static int ptp_clock_adjtime(struct posix_clock *pc, struct __kernel_timex *tx)
>
> err = ops->adjphase(ops, offset);
> }
> + } else if (tx->modes & ADJ_ESTERROR) {
> + if (ops->setesterror)
> + if (tx->modes & ADJ_NANO)
> + err = ops->setesterror(ops, tx->esterror * 1000);
> + else
> + err = ops->setesterror(ops, tx->esterror);
Both GCC-14 and Clang-18 complain when compiling with W=1 that the relation
of the else to the two if's is ambiguous. Based on indentation I suggest
adding a { } to the outer-if.
> } else if (tx->modes == 0) {
> + long esterror;
> +
> tx->freq = ptp->dialed_frequency;
> - err = 0;
> + if (ops->getesterror) {
> + err = ops->getesterror(ops, &esterror, NULL, NULL);
> + if (err)
> + return err;
> + tx->modes &= ADJ_NANO;
> + tx->esterror = esterror;
> + } else {
> + err = 0;
> + }
> }
>
> return err;
...
next prev parent reply other threads:[~2024-08-14 11:46 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-13 12:55 [RFC 0/3] ptp: Add esterror support Maciek Machnikowski
2024-08-13 12:56 ` [RFC 1/3] ptp: Implement timex " Maciek Machnikowski
2024-08-14 9:29 ` Vadim Fedorenko
2024-08-15 9:33 ` Maciek Machnikowski
2024-08-14 11:46 ` Simon Horman [this message]
2024-08-15 9:32 ` Maciek Machnikowski
2024-08-15 4:23 ` Richard Cochran
2024-08-15 9:43 ` Maciek Machnikowski
2024-08-15 9:47 ` Maciek Machnikowski
2024-08-15 21:04 ` Richard Cochran
2024-08-13 12:56 ` [RFC 2/3] ptp: Implement support for esterror in ptp_mock Maciek Machnikowski
2024-08-13 12:56 ` [RFC 3/3] ptp: Add setting esterror and reading timex structure Maciek Machnikowski
2024-08-13 20:05 ` [RFC 0/3] ptp: Add esterror support Andrew Lunn
2024-08-14 8:44 ` Vadim Fedorenko
2024-08-14 13:08 ` Andrew Lunn
2024-08-14 15:08 ` Maciek Machnikowski
2024-08-15 3:53 ` Richard Cochran
2024-08-15 9:40 ` Maciek Machnikowski
2024-08-15 14:26 ` Andrew Lunn
2024-08-15 15:00 ` Maciek Machnikowski
2024-08-15 21:08 ` Richard Cochran
2024-08-15 22:06 ` Maciek Machnikowski
2024-08-15 23:11 ` Andrew Lunn
2024-08-16 4:13 ` Maciek Machnikowski
2024-08-17 4:29 ` Richard Cochran
2024-08-15 3:33 ` Richard Cochran
2024-08-15 4:16 ` Richard Cochran
2024-08-15 5:24 ` Miroslav Lichvar
2024-08-15 9:45 ` Maciek Machnikowski
2024-08-15 9:41 ` Maciek Machnikowski
2024-08-15 0:41 ` Jakub Kicinski
2024-08-15 3:42 ` Richard Cochran
2024-08-15 4:17 ` Richard Cochran
2024-08-15 9:35 ` Maciek Machnikowski
2024-08-15 10:29 ` Vadim Fedorenko
2024-08-15 11:40 ` Arinzon, David
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=20240814114605.GC69536@kernel.org \
--to=horms@kernel.org \
--cc=darinzon@amazon.com \
--cc=jacob.e.keller@intel.com \
--cc=kuba@kernel.org \
--cc=maciek@machnikowski.net \
--cc=netdev@vger.kernel.org \
--cc=richardcochran@gmail.com \
--cc=vadfed@meta.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
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;
as well as URLs for NNTP newsgroup(s).