Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

video: console, use DIV_ROUND_UP

Use DIV_ROUND_UP explicitly instead of manual shifts and adds. It makes
the code more readable and consistent (sometimes there were shifts,
sometimes divs).

There is no change on the assembly level (compilers should do the right
job).

Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: Krzysztof Helt <krzysztof.h1@poczta.fm>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Jiri Slaby and committed by
Linus Torvalds
9a4a83d2 99e9e7d6

+4 -4
+4 -4
drivers/video/console/bitblit.c
··· 25 25 struct vc_data *vc) 26 26 { 27 27 int i, offset = (vc->vc_font.height < 10) ? 1 : 2; 28 - int width = (vc->vc_font.width + 7) >> 3; 28 + int width = DIV_ROUND_UP(vc->vc_font.width, 8); 29 29 unsigned int cellsize = vc->vc_font.height * width; 30 30 u8 c; 31 31 ··· 144 144 int fg, int bg) 145 145 { 146 146 struct fb_image image; 147 - u32 width = (vc->vc_font.width + 7)/8; 147 + u32 width = DIV_ROUND_UP(vc->vc_font.width, 8); 148 148 u32 cellsize = width * vc->vc_font.height; 149 149 u32 maxcnt = info->pixmap.size/cellsize; 150 150 u32 scan_align = info->pixmap.scan_align - 1; ··· 173 173 cnt = count; 174 174 175 175 image.width = vc->vc_font.width * cnt; 176 - pitch = ((image.width + 7) >> 3) + scan_align; 176 + pitch = DIV_ROUND_UP(image.width, 8) + scan_align; 177 177 pitch &= ~scan_align; 178 178 size = pitch * image.height + buf_align; 179 179 size &= ~buf_align; ··· 239 239 struct fb_cursor cursor; 240 240 struct fbcon_ops *ops = info->fbcon_par; 241 241 unsigned short charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff; 242 - int w = (vc->vc_font.width + 7) >> 3, c; 242 + int w = DIV_ROUND_UP(vc->vc_font.width, 8), c; 243 243 int y = real_y(ops->p, vc->vc_y); 244 244 int attribute, use_sw = (vc->vc_cursor_type & 0x10); 245 245 int err = 1;