Commit 6c196f36 authored by Min Li's avatar Min Li Committed by Jakub Kicinski

ptp: idt82p33: optimize _idt82p33_adjfine

Use div_s64 so that the neg_adj is not needed.
Signed-off-by: default avatarMin Li <min.li.xe@renesas.com>
Acked-by: default avatarRichard Cochran <richardcochran@gmail.com>
Link: https://lore.kernel.org/r/1604634729-24960-3-git-send-email-min.li.xe@renesas.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent e4c6eb68
...@@ -320,7 +320,6 @@ static int _idt82p33_adjfine(struct idt82p33_channel *channel, long scaled_ppm) ...@@ -320,7 +320,6 @@ static int _idt82p33_adjfine(struct idt82p33_channel *channel, long scaled_ppm)
{ {
struct idt82p33 *idt82p33 = channel->idt82p33; struct idt82p33 *idt82p33 = channel->idt82p33;
unsigned char buf[5] = {0}; unsigned char buf[5] = {0};
int neg_adj = 0;
int err, i; int err, i;
s64 fcw; s64 fcw;
...@@ -340,16 +339,9 @@ static int _idt82p33_adjfine(struct idt82p33_channel *channel, long scaled_ppm) ...@@ -340,16 +339,9 @@ static int _idt82p33_adjfine(struct idt82p33_channel *channel, long scaled_ppm)
* FCW = ------------- * FCW = -------------
* 168 * 2^4 * 168 * 2^4
*/ */
if (scaled_ppm < 0) {
neg_adj = 1;
scaled_ppm = -scaled_ppm;
}
fcw = scaled_ppm * 244140625ULL; fcw = scaled_ppm * 244140625ULL;
fcw = div_u64(fcw, 2688); fcw = div_s64(fcw, 2688);
if (neg_adj)
fcw = -fcw;
for (i = 0; i < 5; i++) { for (i = 0; i < 5; i++) {
buf[i] = fcw & 0xff; buf[i] = fcw & 0xff;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment