[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20180811192802.bk3akunth2xpsxaj@localhost>
Date: Sat, 11 Aug 2018 12:28:02 -0700
From: Richard Cochran <richardcochran@...il.com>
To: Bryan Whitehead <Bryan.Whitehead@...rochip.com>
Cc: davem@...emloft.net, netdev@...r.kernel.org,
UNGLinuxDriver@...rochip.com
Subject: Re: [PATCH v1 net-next] lan743x: lan743x: Add PTP support
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
Powered by blists - more mailing lists