提交 7528f543 编写于 作者: K Krzysztof Helt 提交者: Linus Torvalds

cirrusfb: simplify clock calculation

Simplify clock calculation.
Signed-off-by: NKrzysztof Helt <krzysztof.h1@wp.pl>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 786e463e
...@@ -3075,38 +3075,36 @@ static void bestclock(long freq, long *best, long *nom, ...@@ -3075,38 +3075,36 @@ static void bestclock(long freq, long *best, long *nom,
f = freq * 10; f = freq * 10;
for (n = 32; n < 128; n++) { for (n = 32; n < 128; n++) {
int s = 0;
d = (143181 * n) / f; d = (143181 * n) / f;
if ((d >= 7) && (d <= 63)) { if ((d >= 7) && (d <= 63)) {
if (d > 31) int temp = d;
d = (d / 2) * 2;
h = (14318 * n) / d; if (temp > 31) {
s = 1;
temp >>= 1;
}
h = ((14318 * n) / temp) >> s;
if (abs(h - freq) < abs(*best - freq)) { if (abs(h - freq) < abs(*best - freq)) {
*best = h; *best = h;
*nom = n; *nom = n;
if (d < 32) { *den = temp;
*den = d; *div = s;
*div = 0;
} else {
*den = d / 2;
*div = 1;
}
} }
} }
d = DIV_ROUND_UP(143181 * n, f); d++;
if ((d >= 7) && (d <= 63)) { if ((d >= 7) && (d <= 63)) {
if (d > 31) if (d > 31) {
d = (d / 2) * 2; s = 1;
h = (14318 * n) / d; d >>= 1;
}
h = ((14318 * n) / d) >> s;
if (abs(h - freq) < abs(*best - freq)) { if (abs(h - freq) < abs(*best - freq)) {
*best = h; *best = h;
*nom = n; *nom = n;
if (d < 32) { *den = d;
*den = d; *div = s;
*div = 0;
} else {
*den = d / 2;
*div = 1;
}
} }
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册