public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Make shr to divide by power of 2
@ 2009-08-06 18:09 Sergey Senozhatsky
  2009-08-07  6:50 ` Andi Kleen
  0 siblings, 1 reply; 6+ messages in thread
From: Sergey Senozhatsky @ 2009-08-06 18:09 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 918 bytes --]

Hello Andrew,

drivers/video/console/bitblit.c
'shr' is used to divide by 8 except 'static void bit_putcs'.

Of course, compiler supposed to do something like
	add    $0x7,%eax
	shr    $0x3,%eax
instead of div. Should we rely on this?
============

Make an arithmetic right shift to divide by power of 2.

Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
---
diff --git a/drivers/video/console/bitblit.c b/drivers/video/console/bitblit.c
index 69864b1..b816151 100644
--- a/drivers/video/console/bitblit.c
+++ b/drivers/video/console/bitblit.c
@@ -144,7 +144,7 @@ static void bit_putcs(struct vc_data *vc, struct fb_info *info,
 		      int fg, int bg)
 {
 	struct fb_image image;
-	u32 width = (vc->vc_font.width + 7)/8;
+	u32 width = (vc->vc_font.width + 7) >> 3;
 	u32 cellsize = width * vc->vc_font.height;
 	u32 maxcnt = info->pixmap.size/cellsize;
 	u32 scan_align = info->pixmap.scan_align - 1;

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 315 bytes --]

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-08-09  9:37 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-06 18:09 [PATCH] Make shr to divide by power of 2 Sergey Senozhatsky
2009-08-07  6:50 ` Andi Kleen
2009-08-07  7:42   ` Sergey Senozhatsky
2009-08-08  3:09   ` Robert Hancock
2009-08-08  7:35     ` Andi Kleen
2009-08-09  9:40       ` Sergey Senozhatsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox