mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Richard Cochran <richardcochran@gmail.com>
To: min.li.xe@renesas.com
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next 3/3] ptp: idt82p33: optimize _idt82p33_adjfine
Date: Wed, 4 Nov 2020 08:46:57 -0800	[thread overview]
Message-ID: <20201104164657.GE16105@hoboy.vegasvil.org> (raw)
In-Reply-To: <1604505709-5483-3-git-send-email-min.li.xe@renesas.com>

On Wed, Nov 04, 2020 at 11:01:49AM -0500, min.li.xe@renesas.com wrote:
> From: Min Li <min.li.xe@renesas.com>
> 
> Use div_s64 so that the neg_adj is not needed.

Back in the day, I coded the neg_adj because there was some issue with
signed 64 bit division that I can't recall now.  Either div_s64 didn't
exist or it was buggy on some archs... there was _some_ reason.

So unless you are sure that this works on all platforms, I would leave
it alone.

Thanks,
Richard


> Signed-off-by: Min Li <min.li.xe@renesas.com>
> ---
>  drivers/ptp/ptp_idt82p33.c | 10 +---------
>  1 file changed, 1 insertion(+), 9 deletions(-)
> 
> diff --git a/drivers/ptp/ptp_idt82p33.c b/drivers/ptp/ptp_idt82p33.c
> index b1528a0..e970379d 100644
> --- a/drivers/ptp/ptp_idt82p33.c
> +++ b/drivers/ptp/ptp_idt82p33.c
> @@ -320,7 +320,6 @@ static int _idt82p33_adjfine(struct idt82p33_channel *channel, long scaled_ppm)
>  {
>  	struct idt82p33 *idt82p33 = channel->idt82p33;
>  	unsigned char buf[5] = {0};
> -	int neg_adj = 0;
>  	int err, i;
>  	s64 fcw;
>  
> @@ -340,16 +339,9 @@ static int _idt82p33_adjfine(struct idt82p33_channel *channel, long scaled_ppm)
>  	 * FCW = -------------
>  	 *         168 * 2^4
>  	 */
> -	if (scaled_ppm < 0) {
> -		neg_adj = 1;
> -		scaled_ppm = -scaled_ppm;
> -	}
>  
>  	fcw = scaled_ppm * 244140625ULL;
> -	fcw = div_u64(fcw, 2688);
> -
> -	if (neg_adj)
> -		fcw = -fcw;
> +	fcw = div_s64(fcw, 2688);
>  
>  	for (i = 0; i < 5; i++) {
>  		buf[i] = fcw & 0xff;
> -- 
> 2.7.4
> 

  reply	other threads:[~2020-11-04 16:47 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-04 16:01 [PATCH net-next 1/3] ptp: idt82p33: add adjphase support min.li.xe
2020-11-04 16:01 ` [PATCH net-next 2/3] ptp: idt82p33: use i2c_master_send for bus write min.li.xe
2020-11-04 16:43   ` Richard Cochran
2020-11-04 16:01 ` [PATCH net-next 3/3] ptp: idt82p33: optimize _idt82p33_adjfine min.li.xe
2020-11-04 16:46   ` Richard Cochran [this message]
2020-11-05  0:35     ` Vladimir Oltean
2020-11-05 17:02       ` Richard Cochran
2020-11-04 16:42 ` [PATCH net-next 1/3] ptp: idt82p33: add adjphase support Richard Cochran
2020-11-04 21:56 ` Jakub Kicinski

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=20201104164657.GE16105@hoboy.vegasvil.org \
    --to=richardcochran@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=min.li.xe@renesas.com \
    --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

all inboxes | Powered by JetHome®