summaryrefslogtreecommitdiffstats
path: root/drivers/video
diff options
context:
space:
mode:
authorKrzysztof Helt <krzysztof.h1@wp.pl>2008-10-16 07:03:36 +0200
committerLinus Torvalds <torvalds@linux-foundation.org>2008-10-16 20:21:43 +0200
commit7528f543889fd460964b42881296b2e84457684e (patch)
tree512b7c766bacbfee1593673debf865cadaf60893 /drivers/video
parentcirrusfb: remove information about memory size during mode change (diff)
downloadlinux-7528f543889fd460964b42881296b2e84457684e.tar.xz
linux-7528f543889fd460964b42881296b2e84457684e.zip
cirrusfb: simplify clock calculation
Simplify clock calculation. Signed-off-by: Krzysztof Helt <krzysztof.h1@wp.pl> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to '')
-rw-r--r--drivers/video/cirrusfb.c40
1 files changed, 19 insertions, 21 deletions
diff --git a/drivers/video/cirrusfb.c b/drivers/video/cirrusfb.c
index 09f42145a5db..dfd12a2dfe72 100644
--- a/drivers/video/cirrusfb.c
+++ b/drivers/video/cirrusfb.c
@@ -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;
}
}
}