netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: <min.li.xe@renesas.com>
To: <richardcochran@gmail.com>
Cc: <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	Min Li <min.li.xe@renesas.com>
Subject: [PATCH net-next 3/3] ptp: idt82p33: optimize _idt82p33_adjfine
Date: Wed, 4 Nov 2020 11:01:49 -0500	[thread overview]
Message-ID: <1604505709-5483-3-git-send-email-min.li.xe@renesas.com> (raw)
In-Reply-To: <1604505709-5483-1-git-send-email-min.li.xe@renesas.com>

From: Min Li <min.li.xe@renesas.com>

Use div_s64 so that the neg_adj is not needed.

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


  parent reply	other threads:[~2020-11-04 16:30 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 ` min.li.xe [this message]
2020-11-04 16:46   ` [PATCH net-next 3/3] ptp: idt82p33: optimize _idt82p33_adjfine Richard Cochran
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=1604505709-5483-3-git-send-email-min.li.xe@renesas.com \
    --to=min.li.xe@renesas.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=richardcochran@gmail.com \
    /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;
as well as URLs for NNTP newsgroup(s).