Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp1423681pxb; Wed, 4 Nov 2020 08:32:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJz4g+fdI8ZA/4CTEEFn3/YcSKC+/2Ba8oRD/Un6zwiviP6j2Yb0WauNooZlJVK1rzpQc6ni X-Received: by 2002:aa7:cad6:: with SMTP id l22mr28015820edt.229.1604507563120; Wed, 04 Nov 2020 08:32:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604507563; cv=none; d=google.com; s=arc-20160816; b=OssjJLhX0PYcljI/G/dCEVJ4lec9jQq3RLxE4wgxV4vqteZ7W1VGldSAFjT/q6rVD6 kNovsmUAVhwWBTHTAJ0gD0iCaPgpotjDw/ikh6O/KjC3lcP963BHyjz4JXOGRLjUi+8i 7EymNEclxbzbhn/hEr9LzGxM8Wstms2w951QyjjDtdvS1hXqdM2sf4NlgX8RclLtmHdm yEXT2k9gsf2YIf05Rs20aqCSxW7QZuJMngkTTBfOG6dcA9E3oPWT7zStOnEkpYVlc7ll tFPHJVEB9HpsIP2FGl7lmbrMfkdxv5T4rgjjZJQQOn8Tz3eW266VVQ8gYE8evkKamVLR 3FkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=d0BsXVkcEAgre9D3VtTP53lQfWKysA88gymy78Wx9lU=; b=dQ/ZLVGZ4Fd+nl7xkzS7SJH7wt5DXQO/6A6Z38rKtU+oWjc8w0+cHT5wRpOECX+Hhr vMuKJUQQTUV2YQwZZmkZts9r7/GJTfgyuxWz1KMZTUQTmbxkrZPSdxyhQ4UJCaDVTlZk 5Vjj77lbtMFPGnuHKtwceSx9WXuNLNdM33rN/mtzqjPS+ujmSSky7ahfwJUps37MtHa0 va33Gi7m2idU34CjQbSB8wENeg73cC62ZNOKRcKO9nkSmRXdKmkadPULETxLzDQhU5Ar hYZghVLUgoOPovFtLa7DAFPa7SCeM6JSkVPxm59HQm17n7Pnz72dQuuzIP79GAcPE68q jsrQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cf25si1601107edb.205.2020.11.04.08.32.20; Wed, 04 Nov 2020 08:32:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730832AbgKDQax (ORCPT + 99 others); Wed, 4 Nov 2020 11:30:53 -0500 Received: from pbmsgap02.intersil.com ([192.157.179.202]:38392 "EHLO pbmsgap02.intersil.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727285AbgKDQax (ORCPT ); Wed, 4 Nov 2020 11:30:53 -0500 Received: from pps.filterd (pbmsgap02.intersil.com [127.0.0.1]) by pbmsgap02.intersil.com (8.16.0.42/8.16.0.42) with SMTP id 0A4G1vmC028830; Wed, 4 Nov 2020 11:02:36 -0500 Received: from pbmxdp03.intersil.corp (pbmxdp03.pb.intersil.com [132.158.200.224]) by pbmsgap02.intersil.com with ESMTP id 34h23fa02t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 04 Nov 2020 11:02:36 -0500 Received: from pbmxdp02.intersil.corp (132.158.200.223) by pbmxdp03.intersil.corp (132.158.200.224) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.1979.3; Wed, 4 Nov 2020 11:02:35 -0500 Received: from localhost (132.158.202.109) by pbmxdp02.intersil.corp (132.158.200.223) with Microsoft SMTP Server id 15.1.1979.3 via Frontend Transport; Wed, 4 Nov 2020 11:02:34 -0500 From: To: CC: , , Min Li Subject: [PATCH net-next 3/3] ptp: idt82p33: optimize _idt82p33_adjfine Date: Wed, 4 Nov 2020 11:01:49 -0500 Message-ID: <1604505709-5483-3-git-send-email-min.li.xe@renesas.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1604505709-5483-1-git-send-email-min.li.xe@renesas.com> References: <1604505709-5483-1-git-send-email-min.li.xe@renesas.com> X-TM-AS-MML: disable MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.312,18.0.737 definitions=2020-11-04_11:2020-11-04,2020-11-04 signatures=0 X-Proofpoint-Spam-Details: rule=junk_notspam policy=junk score=0 mlxscore=0 adultscore=0 malwarescore=0 bulkscore=0 spamscore=0 mlxlogscore=792 phishscore=0 suspectscore=4 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2011040117 X-Proofpoint-Spam-Reason: mlx Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Min Li Use div_s64 so that the neg_adj is not needed. Signed-off-by: Min Li --- 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