Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp986987pxb; Thu, 5 Nov 2020 20:03:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJyc+cQbN4hf2s8LW7OtZeilIksmmcL2QkBWQGVxwq2FUJSL8Z0kDFewa7/MR6LRthEa/lKO X-Received: by 2002:a17:906:831a:: with SMTP id j26mr142316ejx.450.1604635384477; Thu, 05 Nov 2020 20:03:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604635384; cv=none; d=google.com; s=arc-20160816; b=Nyw9IdtXacAB0zS4kVNWOZTjN8Vr8gfrXdkgY3ihQ5fQjAYdTBDvIXd0yp/QaJRdEW 0FAb6T2i205IK1z0odeX9iBHrjd3hJuSgCxpmIHtG2TT4OE4l9gwh3AHPgRy/rWmlaPs Eu1GFqfvqbK4O2W+dXgUShhywbd+AemMoT+9T5jlAwaDZWtI9ZpW8l18kWj2exSWbhaw Y+NHTfecqNAYFgq/4wrSLEprseh9XG/xf64Vd35I3CCucP9nbYIvFcdVWb37aJOqc8NM s9iFh7q7jLuV4n7X0d0JLeIqqH4D+o0C0HgcAoTP03vEzgS4m/DvCnG6+2Hs/TldynqN iSAg== 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=qyMkn8Ozd0GlJKWy7t4/Lv/1kqwi9gLwzAPvAM4aHVo=; b=xR+YBs7fEHB3Ib+wkfvmpr4mFqevn3j+4VK/mMHjEmPUDyTbYtPYXYGlIlrLkyS+e7 dqCd/0ZHOp1ctk5UYlJUkcetNZE9nTeJYgNXSqEt0VQx4lovg7RCtpnOK8nbelM/XF55 SD5TV8647c+hrptUlRjPQ0m2G5BxEAalLdmaLb7ptDRy9NH0lFvvav/0m0f9smegTbIf Iiz6EsoGOK3e/V3FGSx6dGRzgTeFgwICnJa5fnpsbPwg8unnL3Up2QKyWni0zEyIek3j O8mNRAqS7wLDwgU5jqOsgNXTtQbT0mBZdGjKbM+A5AQXmX6tq6BlXNWWVN4A193fht7t aYyw== 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 f19si47841edr.593.2020.11.05.20.02.41; Thu, 05 Nov 2020 20:03:04 -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 S1726166AbgKFD7x (ORCPT + 99 others); Thu, 5 Nov 2020 22:59:53 -0500 Received: from pbmsgap02.intersil.com ([192.157.179.202]:47722 "EHLO pbmsgap02.intersil.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725895AbgKFD7w (ORCPT ); Thu, 5 Nov 2020 22:59:52 -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 0A63pf7D009766; Thu, 5 Nov 2020 22:52:43 -0500 Received: from pbmxdp01.intersil.corp (pbmxdp01.pb.intersil.com [132.158.200.222]) by pbmsgap02.intersil.com with ESMTP id 34mk3mgb3x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 05 Nov 2020 22:52:42 -0500 Received: from pbmxdp02.intersil.corp (132.158.200.223) by pbmxdp01.intersil.corp (132.158.200.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.1979.3; Thu, 5 Nov 2020 22:52:41 -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; Thu, 5 Nov 2020 22:52:41 -0500 From: To: CC: , , Min Li Subject: [PATCH v4 net-next 3/3] ptp: idt82p33: optimize _idt82p33_adjfine Date: Thu, 5 Nov 2020 22:52:09 -0500 Message-ID: <1604634729-24960-3-git-send-email-min.li.xe@renesas.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1604634729-24960-1-git-send-email-min.li.xe@renesas.com> References: <1604634729-24960-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-06_01:2020-11-05,2020-11-06 signatures=0 X-Proofpoint-Spam-Details: rule=junk_notspam policy=junk score=0 mlxlogscore=741 phishscore=0 malwarescore=0 adultscore=0 bulkscore=0 suspectscore=4 spamscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2011060023 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 Acked-by: Richard Cochran --- 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 223bc11..c1c959f 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