fb_find_best_nearest_mode - actually pick highest refresh this time

also optimize out the abs, since mode > cmode, it will always be positive
This commit is contained in:
Matt Sealey
2011-06-13 20:02:47 -05:00
parent 5b7fe2afda
commit 058da005af

View File

@@ -938,15 +938,15 @@ const struct fb_videomode *fb_find_best_nearest_mode(const struct fb_videomode *
/* the calculations here assume that every other mode than the one
passed is somewhat smaller :) */
if (mode->xres >= cmode->xres && mode->yres >= cmode->yres) {
d = abs(mode->xres - cmode->xres) +
abs(mode->yres - cmode->yres);
d = (mode->xres - cmode->xres) +
(mode->yres - cmode->yres);
if (diff > d) {
/* as d grows smaller, best gets closer to the
* passed mode */
diff = d;
best = cmode;
} else if (diff == d && best &&
mode->refresh > best->refresh) {
cmode->refresh > best->refresh) {
best = cmode;
}
}