fbdev: Fix fb_find_nearest_mode refresh comparison
authorAndrew Kephart <andrew.kephart@alereon.com>
Mon, 13 Dec 2010 15:46:34 +0000 (09:46 -0600)
committerPaul Mundt <lethal@linux-sh.org>
Tue, 14 Dec 2010 09:03:49 +0000 (18:03 +0900)
Refresh rate nearness is not calculated or reset when nearest resolution
changes.

This patch resets the refresh rate differential measurement whenever a
new nearest resolution is discovered.  This fixes two error cases;
first, wherein the first mode's refresh rate differential is never
calculated and second, when the closest refresh rate from a previous
nearest resolution is erroneously preserved.

Signed-off-by: Andrew Kephart <andrew.kephart@alereon.com>
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
drivers/video/modedb.c

index 0a4dbdc1693a4462bddb82cdf5e0b9ab5ec4bed2..de450c1fb86926f39190f052d7644d56f60ccc5d 100644 (file)
@@ -855,6 +855,7 @@ const struct fb_videomode *fb_find_nearest_mode(const struct fb_videomode *mode,
                        abs(cmode->yres - mode->yres);
                if (diff > d) {
                        diff = d;
+                       diff_refresh = abs(cmode->refresh - mode->refresh);
                        best = cmode;
                } else if (diff == d) {
                        d = abs(cmode->refresh - mode->refresh);