Commit 9a4a83d2 authored by Jiri Slaby's avatar Jiri Slaby Committed by Linus Torvalds

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: default avatarJiri 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: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 99e9e7d6
...@@ -25,7 +25,7 @@ static inline void update_attr(u8 *dst, u8 *src, int attribute, ...@@ -25,7 +25,7 @@ static inline void update_attr(u8 *dst, u8 *src, int attribute,
struct vc_data *vc) struct vc_data *vc)
{ {
int i, offset = (vc->vc_font.height < 10) ? 1 : 2; int i, offset = (vc->vc_font.height < 10) ? 1 : 2;
int width = (vc->vc_font.width + 7) >> 3; int width = DIV_ROUND_UP(vc->vc_font.width, 8);
unsigned int cellsize = vc->vc_font.height * width; unsigned int cellsize = vc->vc_font.height * width;
u8 c; u8 c;
...@@ -144,7 +144,7 @@ static void bit_putcs(struct vc_data *vc, struct fb_info *info, ...@@ -144,7 +144,7 @@ static void bit_putcs(struct vc_data *vc, struct fb_info *info,
int fg, int bg) int fg, int bg)
{ {
struct fb_image image; struct fb_image image;
u32 width = (vc->vc_font.width + 7)/8; u32 width = DIV_ROUND_UP(vc->vc_font.width, 8);
u32 cellsize = width * vc->vc_font.height; u32 cellsize = width * vc->vc_font.height;
u32 maxcnt = info->pixmap.size/cellsize; u32 maxcnt = info->pixmap.size/cellsize;
u32 scan_align = info->pixmap.scan_align - 1; u32 scan_align = info->pixmap.scan_align - 1;
...@@ -173,7 +173,7 @@ static void bit_putcs(struct vc_data *vc, struct fb_info *info, ...@@ -173,7 +173,7 @@ static void bit_putcs(struct vc_data *vc, struct fb_info *info,
cnt = count; cnt = count;
image.width = vc->vc_font.width * cnt; image.width = vc->vc_font.width * cnt;
pitch = ((image.width + 7) >> 3) + scan_align; pitch = DIV_ROUND_UP(image.width, 8) + scan_align;
pitch &= ~scan_align; pitch &= ~scan_align;
size = pitch * image.height + buf_align; size = pitch * image.height + buf_align;
size &= ~buf_align; size &= ~buf_align;
...@@ -239,7 +239,7 @@ static void bit_cursor(struct vc_data *vc, struct fb_info *info, int mode, ...@@ -239,7 +239,7 @@ static void bit_cursor(struct vc_data *vc, struct fb_info *info, int mode,
struct fb_cursor cursor; struct fb_cursor cursor;
struct fbcon_ops *ops = info->fbcon_par; struct fbcon_ops *ops = info->fbcon_par;
unsigned short charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff; unsigned short charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff;
int w = (vc->vc_font.width + 7) >> 3, c; int w = DIV_ROUND_UP(vc->vc_font.width, 8), c;
int y = real_y(ops->p, vc->vc_y); int y = real_y(ops->p, vc->vc_y);
int attribute, use_sw = (vc->vc_cursor_type & 0x10); int attribute, use_sw = (vc->vc_cursor_type & 0x10);
int err = 1; int err = 1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment