netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Richard Cochran <richardcochran@gmail.com>
To: Bryan Whitehead <Bryan.Whitehead@microchip.com>
Cc: davem@davemloft.net, netdev@vger.kernel.org,
	UNGLinuxDriver@microchip.com
Subject: Re: [PATCH v1 net-next] lan743x: lan743x: Add PTP support
Date: Sat, 11 Aug 2018 12:28:02 -0700	[thread overview]
Message-ID: <20180811192802.bk3akunth2xpsxaj@localhost> (raw)
In-Reply-To: <1533843370-26315-1-git-send-email-Bryan.Whitehead@microchip.com>

On Thu, Aug 09, 2018 at 03:36:10PM -0400, Bryan Whitehead wrote:
> +static int lan743x_ptpci_adjfine(struct ptp_clock_info *ptpci, long scaled_ppm)
> +{
> +	struct lan743x_ptp *ptp =
> +		container_of(ptpci, struct lan743x_ptp, ptp_clock_info);
> +	struct lan743x_adapter *adapter =
> +		container_of(ptp, struct lan743x_adapter, ptp);
> +	u32 lan743x_rate_adj = 0;
> +	bool positive = true;
> +	u64 u64_delta = 0;
> +
> +	if ((scaled_ppm < (-LAN743X_PTP_MAX_FINE_ADJ_IN_SCALED_PPM)) ||
> +	    scaled_ppm > LAN743X_PTP_MAX_FINE_ADJ_IN_SCALED_PPM) {
> +		return -EINVAL;

Maybe ERANGE is better here.

> +	}
> +	if (scaled_ppm > 0) {
> +		u64_delta = (u64)scaled_ppm;
> +		positive = true;
> +	} else {
> +		u64_delta = (u64)(-scaled_ppm);
> +		positive = false;
> +	}
> +	u64_delta = (u64_delta << 19);
> +	lan743x_rate_adj = div_u64(u64_delta, 1000000);
> +
> +	if (positive)
> +		lan743x_rate_adj |= PTP_CLOCK_RATE_ADJ_DIR_;
> +
> +	lan743x_csr_write(adapter, PTP_CLOCK_RATE_ADJ,
> +			  lan743x_rate_adj);
> +
> +	return 0;
> +}
> +
> +static int lan743x_ptpci_adjfreq(struct ptp_clock_info *ptpci, s32 delta_ppb)
> +{

Since you have adjfine, you can delete adjfreq.  The core PTP code
does this in ptp_clock.c:

		if (ops->adjfine)
			err = ops->adjfine(ops, tx->freq);
		else
			err = ops->adjfreq(ops, ppb);

Thanks,
Richard

      parent reply	other threads:[~2018-08-11 22:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-09 19:36 [PATCH v1 net-next] lan743x: lan743x: Add PTP support Bryan Whitehead
2018-08-11 18:47 ` David Miller
2018-08-11 19:28 ` Richard Cochran [this message]

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=20180811192802.bk3akunth2xpsxaj@localhost \
    --to=richardcochran@gmail.com \
    --cc=Bryan.Whitehead@microchip.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    /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).