From: Jacob Keller <jacob.e.keller@intel.com>
To: Vladimir Oltean <olteanv@gmail.com>,
kuba@kernel.org, davem@davemloft.net, netdev@vger.kernel.org
Cc: richardcochran@gmail.com
Subject: Re: [PATCH v2 net-next] ptp: only allow phase values lower than 1 period
Date: Tue, 4 Aug 2020 17:04:47 -0700 [thread overview]
Message-ID: <cc1465fd-2696-f73b-85c2-7f6132f6623d@intel.com> (raw)
In-Reply-To: <20200804234308.1303022-1-olteanv@gmail.com>
On 8/4/2020 4:43 PM, Vladimir Oltean wrote:
> The way we define the phase (the difference between the time of the
> signal's rising edge, and the closest integer multiple of the period),
> it doesn't make sense to have a phase value larger than 1 period.
>
> So deny these settings coming from the user.
>
> Signed-off-by: Vladimir Oltean <olteanv@gmail.com>
> ---
> Changes in v2:
> Be sure to also deny the case where the period is equal to the phase.
> This represents a 360 degree offset, which is equivalent to a phase of
> zero, so it should be rejected on the grounds of having a modulo
> equivalent as well.
>
> drivers/ptp/ptp_chardev.c | 13 +++++++++++++
> 1 file changed, 13 insertions(+)
>
> diff --git a/drivers/ptp/ptp_chardev.c b/drivers/ptp/ptp_chardev.c
> index e0e6f85966e1..ee48eb61b49c 100644
> --- a/drivers/ptp/ptp_chardev.c
> +++ b/drivers/ptp/ptp_chardev.c
> @@ -218,6 +218,19 @@ long ptp_ioctl(struct posix_clock *pc, unsigned int cmd, unsigned long arg)
> break;
> }
> }
> + if (perout->flags & PTP_PEROUT_PHASE) {
> + /*
> + * The phase should be specified modulo the
> + * period, therefore anything larger than 1
> + * period is invalid.
> + */
A nit: this could read "therefore anything equal or larger than 1 period
is invalid"? a number modulo itself is 0, right? and we use ">=" below
as well now.
I do think it's relatively clear from context so it probably isn't worth
a re-roll.
> + if (perout->phase.sec > perout->period.sec ||
> + (perout->phase.sec == perout->period.sec &&
> + perout->phase.nsec >= perout->period.nsec)) {
> + err = -ERANGE;
> + break;
> + }
> + }
> } else if (cmd == PTP_PEROUT_REQUEST) {
> req.perout.flags &= PTP_PEROUT_V1_VALID_FLAGS;
> req.perout.rsv[0] = 0;
>
next prev parent reply other threads:[~2020-08-05 0:04 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-04 23:43 [PATCH v2 net-next] ptp: only allow phase values lower than 1 period Vladimir Oltean
2020-08-05 0:04 ` Jacob Keller [this message]
2020-08-05 0:12 ` Vladimir Oltean
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=cc1465fd-2696-f73b-85c2-7f6132f6623d@intel.com \
--to=jacob.e.keller@intel.com \
--cc=davem@davemloft.net \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=richardcochran@gmail.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