lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20201104164657.GE16105@hoboy.vegasvil.org>
Date:   Wed, 4 Nov 2020 08:46:57 -0800
From:   Richard Cochran <richardcochran@...il.com>
To:     min.li.xe@...esas.com
Cc:     netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH net-next 3/3] ptp: idt82p33: optimize _idt82p33_adjfine

On Wed, Nov 04, 2020 at 11:01:49AM -0500, min.li.xe@...esas.com wrote:
> From: Min Li <min.li.xe@...esas.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@...esas.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
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ