diff --git a/drivers/video/modedb.c b/drivers/video/modedb.c index 0a4dbdc..a8283f5 100644 --- a/drivers/video/modedb.c +++ b/drivers/video/modedb.c @@ -29,6 +29,11 @@ #define DPRINTK(fmt, args...) #endif +#define absint(x) ({ \ + int __x = (x); \ + (__x < 0) ? -__x : __x; \ + }) + const char *fb_mode_option; EXPORT_SYMBOL_GPL(fb_mode_option); @@ -636,8 +641,8 @@ done: if (refresh_specified && db[i].refresh == refresh) { return 1; } else { - if (abs(db[i].refresh - refresh) < diff) { - diff = abs(db[i].refresh - refresh); + if (absint(db[i].refresh - refresh) < diff) { + diff = absint(db[i].refresh - refresh); best = i; } } @@ -654,8 +659,8 @@ done: for (i = 0; i < dbsize; i++) { DPRINTK("Trying %ix%i\n", db[i].xres, db[i].yres); if (!fb_try_mode(var, info, &db[i], bpp)) { - tdiff = abs(db[i].xres - xres) + - abs(db[i].yres - yres); + tdiff = absint(db[i].xres - xres) + + absint(db[i].yres - yres); /* * Penalize modes with resolutions smaller @@ -851,13 +856,13 @@ const struct fb_videomode *fb_find_nearest_mode(const struct fb_videomode *mode, modelist = list_entry(pos, struct fb_modelist, list); cmode = &modelist->mode; - d = abs(cmode->xres - mode->xres) + - abs(cmode->yres - mode->yres); + d = absint(cmode->xres - mode->xres) + + absint(cmode->yres - mode->yres); if (diff > d) { diff = d; best = cmode; } else if (diff == d) { - d = abs(cmode->refresh - mode->refresh); + d = absint(cmode->refresh - mode->refresh); if (diff_refresh > d) { diff_refresh = d; best = cmode; diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c index 7b8839e..b965667 100644 --- a/drivers/video/uvesafb.c +++ b/drivers/video/uvesafb.c @@ -29,6 +29,11 @@ #endif #include "edid.h" +#define absint(x) ({ \ + int __x = (x); \ + (__x < 0) ? -__x : __x; \ + }) + static struct cb_id uvesafb_cn_id = { .idx = CN_IDX_V86D, .val = CN_VAL_V86D_UVESAFB @@ -320,9 +325,9 @@ static int uvesafb_vbe_find_mode(struct uvesafb_par *par, int i, match = -1, h = 0, d = 0x7fffffff; for (i = 0; i < par->vbe_modes_cnt; i++) { - h = abs(par->vbe_modes[i].x_res - xres) + - abs(par->vbe_modes[i].y_res - yres) + - abs(depth - par->vbe_modes[i].depth); + h = absint(par->vbe_modes[i].x_res - xres) + + absint(par->vbe_modes[i].y_res - yres) + + absint(depth - par->vbe_modes[i].depth); /* * We have an exact match in terms of resolution @@ -1375,7 +1380,7 @@ static int uvesafb_check_var(struct fb_var_screeninfo *var, * which is theoretically incorrect, but which we'll try to handle * here. */ - if (depth == 0 || abs(depth - var->bits_per_pixel) >= 8) + if (depth == 0 || absint(depth - var->bits_per_pixel) >= 8) depth = var->bits_per_pixel; match = uvesafb_vbe_find_mode(par, var->xres, var->yres, depth,