From: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
To: Jiri Slaby <jirislaby@gmail.com>
Cc: akpm@linux-foundation.org, andi@firstfloor.org,
rpjday@crashcourse.ca, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/1] VIDEO: console, use DIV_ROUND_UP
Date: Mon, 17 Aug 2009 11:00:23 +0300 [thread overview]
Message-ID: <20090817080023.GB2967@localdomain.by> (raw)
In-Reply-To: <1250495293-13035-1-git-send-email-jirislaby@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1657 bytes --]
On (08/17/09 09:48), Jiri Slaby wrote:
> On 08/17/2009 09:31 AM, Sergey Senozhatsky wrote:
> > On (08/17/09 09:15), Jiri Slaby wrote:
> >> Not at all. I was writing about about (X + 7) / 8 [or >> 3] which is
> >> DIV_ROUND_UP(X, 8).
> >>
> > As far as I can understand:
> > DIV_ROUND_UP(61, 8):
> > (111101 + 111) >> 3 -> 1000 == 8
> >
> > (int)(61/8) == 7
>
> Yeah, that's why there is the ROUND_UP keyword in the macro.
>
> I mean this:
> --
> 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>
> ---
> drivers/video/console/bitblit.c | 8 ++++----
> 1 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/video/console/bitblit.c b/drivers/video/console/bitblit.c
> index 69864b1..6b7c8fb 100644
> --- a/drivers/video/console/bitblit.c
> +++ b/drivers/video/console/bitblit.c
> @@ -25,7 +25,7 @@ static inline void update_attr(u8 *dst, u8 *src, int attribute,
> struct vc_data *vc)
> {
> 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);
So... In general, ((vc->vc_font.width + 7) >> 3) == DIV_ROUND_UP(vc->vc_font.width, 8) - 1;
That means:
unsigned int cellsize = vc->vc_font.height * width; now is unsigned int cellsize = vc->vc_font.height * (width + 1);
Are you sure we really can use DIV_ROUND_UP?
Sergey
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 315 bytes --]
next prev parent reply other threads:[~2009-08-17 7:57 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-15 13:43 [PATCH] Make shr to divide by power of 2 (resend) Sergey Senozhatsky
2009-08-15 13:48 ` Jiri Slaby
2009-08-15 13:49 ` Robert P. J. Day
2009-08-15 14:12 ` Sergey Senozhatsky
2009-08-15 20:42 ` Jiri Slaby
2009-08-16 9:14 ` Sergey Senozhatsky
2009-08-17 7:15 ` Jiri Slaby
2009-08-17 7:31 ` Sergey Senozhatsky
2009-08-17 7:48 ` [PATCH 1/1] VIDEO: console, use DIV_ROUND_UP Jiri Slaby
2009-08-17 8:00 ` Sergey Senozhatsky [this message]
2009-08-17 8:00 ` Jiri Slaby
2009-08-17 8:08 ` Sergey Senozhatsky
2009-08-17 8:11 ` Jiri Slaby
2009-08-15 14:26 ` [PATCH] Make shr to divide by power of 2 (resend) Sergey Senozhatsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090817080023.GB2967@localdomain.by \
--to=sergey.senozhatsky@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=andi@firstfloor.org \
--cc=jirislaby@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rpjday@crashcourse.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®