summaryrefslogtreecommitdiffstats
path: root/drivers/ptp
diff options
context:
space:
mode:
authorMin Li <min.li.xe@renesas.com>2020-11-06 04:52:09 +0100
committerJakub Kicinski <kuba@kernel.org>2020-11-07 22:10:31 +0100
commit6c196f36f5243b8814f471cba608b111a33f22df (patch)
treee5e205dc731949b7f9f13cf41e06ad4859e11d04 /drivers/ptp
parentptp: idt82p33: use i2c_master_send for bus write (diff)
downloadlinux-6c196f36f5243b8814f471cba608b111a33f22df.tar.xz
linux-6c196f36f5243b8814f471cba608b111a33f22df.zip
ptp: idt82p33: optimize _idt82p33_adjfine
Use div_s64 so that the neg_adj is not needed. Signed-off-by: Min Li <min.li.xe@renesas.com> Acked-by: Richard Cochran <richardcochran@gmail.com> Link: https://lore.kernel.org/r/1604634729-24960-3-git-send-email-min.li.xe@renesas.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'drivers/ptp')
-rw-r--r--drivers/ptp/ptp_idt82p33.c10
1 files changed, 1 insertions, 9 deletions
diff --git a/drivers/ptp/ptp_idt82p33.c b/drivers/ptp/ptp_idt82p33.c
index 223bc11cb8fe..c1c959f7e52b 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;