Commit 7528f543 authored by Krzysztof Helt's avatar Krzysztof Helt Committed by Linus Torvalds

cirrusfb: simplify clock calculation

Simplify clock calculation.
Signed-off-by: default avatarKrzysztof Helt <krzysztof.h1@wp.pl>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 786e463e
......@@ -3075,38 +3075,36 @@ static void bestclock(long freq, long *best, long *nom,
f = freq * 10;
for (n = 32; n < 128; n++) {
int s = 0;
d = (143181 * n) / f;
if ((d >= 7) && (d <= 63)) {
if (d > 31)
d = (d / 2) * 2;
h = (14318 * n) / d;
int temp = d;
if (temp > 31) {
s = 1;
temp >>= 1;
}
h = ((14318 * n) / temp) >> s;
if (abs(h - freq) < abs(*best - freq)) {
*best = h;
*nom = n;
if (d < 32) {
*den = d;
*div = 0;
} else {
*den = d / 2;
*div = 1;
}
*den = temp;
*div = s;
}
}
d = DIV_ROUND_UP(143181 * n, f);
d++;
if ((d >= 7) && (d <= 63)) {
if (d > 31)
d = (d / 2) * 2;
h = (14318 * n) / d;
if (d > 31) {
s = 1;
d >>= 1;
}
h = ((14318 * n) / d) >> s;
if (abs(h - freq) < abs(*best - freq)) {
*best = h;
*nom = n;
if (d < 32) {
*den = d;
*div = 0;
} else {
*den = d / 2;
*div = 1;
}
*den = d;
*div = s;
}
}
}
......
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