fbdev: use DIV_ROUND_UP or roundup

The kernel.h macro DIV_ROUND_UP performs the computation (((n) + (d) - 1) /
(d)) but is perhaps more readable.

An extract of the semantic patch that makes this change is as follows:
(http://www.emn.fr/x-info/coccinelle/)

// <smpl>
@haskernel@
@@

#include <linux/kernel.h>

@depends on haskernel@
expression n,d;
@@

(
- (n + d - 1) / d
+ DIV_ROUND_UP(n,d)
|
- (n + (d - 1)) / d
+ DIV_ROUND_UP(n,d)
)

@depends on haskernel@
expression n,d;
@@

- DIV_ROUND_UP((n),d)
+ DIV_ROUND_UP(n,d)

@depends on haskernel@
expression n,d;
@@

- DIV_ROUND_UP(n,(d))
+ DIV_ROUND_UP(n,d)
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Cc: "Antonino A. Daplas" <adaplas@pol.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Julia Lawall 2008-04-28 02:14:51 -07:00 committed by Linus Torvalds
parent 7f29b87a77
commit 416e74ea78
4 changed files with 4 additions and 5 deletions

View File

@ -1270,7 +1270,7 @@ again:
gstart = (prescale / 2 + plen * left_margin) / prescale; gstart = (prescale / 2 + plen * left_margin) / prescale;
/* gend1 is for hde (gend-gstart multiple of align), shifter's xres */ /* gend1 is for hde (gend-gstart multiple of align), shifter's xres */
gend1 = gstart + ((xres + align - 1) / align) * align * plen / prescale; gend1 = gstart + roundup(xres, align) * plen / prescale;
/* gend2 is for hbb, visible xres (rest to gend1 is cut off by hblank) */ /* gend2 is for hbb, visible xres (rest to gend1 is cut off by hblank) */
gend2 = gstart + xres * plen / prescale; gend2 = gstart + xres * plen / prescale;
par->HHT = plen * (left_margin + xres + right_margin) / par->HHT = plen * (left_margin + xres + right_margin) /

View File

@ -3117,7 +3117,7 @@ static void bestclock(long freq, long *best, long *nom,
} }
} }
} }
d = ((143181 * n) + f - 1) / f; d = DIV_ROUND_UP(143181 * n, f);
if ((d >= 7) && (d <= 63)) { if ((d >= 7) && (d <= 63)) {
if (d > 31) if (d > 31)
d = (d / 2) * 2; d = (d / 2) * 2;

View File

@ -620,8 +620,7 @@ static void fbcon_prepare_logo(struct vc_data *vc, struct fb_info *info,
if (fb_get_color_depth(&info->var, &info->fix) == 1) if (fb_get_color_depth(&info->var, &info->fix) == 1)
erase &= ~0x400; erase &= ~0x400;
logo_height = fb_prepare_logo(info, ops->rotate); logo_height = fb_prepare_logo(info, ops->rotate);
logo_lines = (logo_height + vc->vc_font.height - 1) / logo_lines = DIV_ROUND_UP(logo_height, vc->vc_font.height);
vc->vc_font.height;
q = (unsigned short *) (vc->vc_origin + q = (unsigned short *) (vc->vc_origin +
vc->vc_size_row * rows); vc->vc_size_row * rows);
step = logo_lines * cols; step = logo_lines * cols;

View File

@ -238,7 +238,7 @@ static int calc_pll(int period_ps, struct gxt4500_par *par)
for (pdiv1 = 1; pdiv1 <= 8; ++pdiv1) { for (pdiv1 = 1; pdiv1 <= 8; ++pdiv1) {
for (pdiv2 = 1; pdiv2 <= pdiv1; ++pdiv2) { for (pdiv2 = 1; pdiv2 <= pdiv1; ++pdiv2) {
postdiv = pdiv1 * pdiv2; postdiv = pdiv1 * pdiv2;
pll_period = (period_ps + postdiv - 1) / postdiv; pll_period = DIV_ROUND_UP(period_ps, postdiv);
/* keep pll in range 350..600 MHz */ /* keep pll in range 350..600 MHz */
if (pll_period < 1666 || pll_period > 2857) if (pll_period < 1666 || pll_period > 2857)
continue; continue;