From: Daniel Walker <dwalker@fifo99.com>
To: Joe Perches <joe@perches.com>
Cc: Julia Lawall <julia@diku.dk>,
linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] treewide: Use DIV_ROUND_UP
Date: Sun, 02 Aug 2009 00:10:57 +0000 [thread overview]
Message-ID: <1249171857.6114.5.camel@desktop> (raw)
In-Reply-To: <1249170191.22466.14.camel@Joe-Laptop.home>
On Sat, 2009-08-01 at 16:43 -0700, Joe Perches wrote:
> On Sat, 2009-08-01 at 21:48 +0200, Julia Lawall wrote:
> > The kernel.h macro DIV_ROUND_CLOSEST performs the computation (x + d/2)/d
> > but is perhaps more readable.
>
> Similarly, DIV_ROUND_UP does ((n + d - 1) / d)
>
> Signed-off-by: Joe Perches <joe@perches.com>
>
> arch/alpha/boot/tools/objstrip.c | 2 +-
> arch/sh/kernel/early_printk.c | 2 +-
> arch/um/include/asm/pgtable-2level.h | 2 +-
> arch/um/include/asm/pgtable-3level.h | 2 +-
> drivers/md/raid1.c | 2 +-
> drivers/md/raid10.c | 2 +-
> drivers/media/video/cx2341x.c | 4 ++--
> drivers/mtd/tests/mtd_stresstest.c | 2 +-
> drivers/net/s2io.c | 2 +-
> drivers/scsi/advansys.c | 2 +-
> drivers/scsi/cxgb3i/cxgb3i.h | 2 +-
> drivers/serial/sh-sci.c | 2 +-
> drivers/staging/winbond/mds.c | 2 +-
> drivers/xen/grant-table.c | 3 +--
> kernel/posix-cpu-timers.c | 2 +-
> lib/radix-tree.c | 2 +-
> sound/pci/ctxfi/ctresource.c | 2 +-
> sound/pci/hda/hda_intel.c | 3 +--
> 18 files changed, 19 insertions(+), 21 deletions(-)
>
> diff --git a/arch/alpha/boot/tools/objstrip.c b/arch/alpha/boot/tools/objstrip.c
> index ef18382..786e736 100644
> --- a/arch/alpha/boot/tools/objstrip.c
> +++ b/arch/alpha/boot/tools/objstrip.c
> @@ -253,7 +253,7 @@ main (int argc, char *argv[])
> }
>
> if (pad) {
> - mem_size = ((mem_size + pad - 1) / pad) * pad;
> + mem_size = DIV_ROUND_UP(mem_size, pad) * pad;
Doesn't this look more like,
#define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y))
> --- a/drivers/media/video/cx2341x.c
> +++ b/drivers/media/video/cx2341x.c
> @@ -304,7 +304,7 @@ static int cx2341x_set_ctrl(struct cx2341x_mpeg_params *params, int busy,
> int b = ctrl->value + 1;
> int gop = params->video_gop_size;
> params->video_b_frames = ctrl->value;
> - params->video_gop_size = b * ((gop + b - 1) / b);
> + params->video_gop_size = b * DIV_ROUND_UP(gop, b);
Same here , roundup() ..
> /* Max GOP size = 34 */
> while (params->video_gop_size > 34)
> params->video_gop_size -= b;
> @@ -313,7 +313,7 @@ static int cx2341x_set_ctrl(struct cx2341x_mpeg_params *params, int busy,
> case V4L2_CID_MPEG_VIDEO_GOP_SIZE: {
> int b = params->video_b_frames + 1;
> int gop = ctrl->value;
> - params->video_gop_size = b * ((gop + b - 1) / b);
> + params->video_gop_size = b * DIV_ROUND_UP(gop, b);
and here..
Seems like there are a few more like this .. Could you either use
roundup() or merge the two macros .. Or explain why your not using it..
Daniel
WARNING: multiple messages have this Message-ID (diff)
From: Daniel Walker <dwalker@fifo99.com>
To: Joe Perches <joe@perches.com>
Cc: Julia Lawall <julia@diku.dk>,
linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] treewide: Use DIV_ROUND_UP
Date: Sat, 01 Aug 2009 17:10:57 -0700 [thread overview]
Message-ID: <1249171857.6114.5.camel@desktop> (raw)
In-Reply-To: <1249170191.22466.14.camel@Joe-Laptop.home>
On Sat, 2009-08-01 at 16:43 -0700, Joe Perches wrote:
> On Sat, 2009-08-01 at 21:48 +0200, Julia Lawall wrote:
> > The kernel.h macro DIV_ROUND_CLOSEST performs the computation (x + d/2)/d
> > but is perhaps more readable.
>
> Similarly, DIV_ROUND_UP does ((n + d - 1) / d)
>
> Signed-off-by: Joe Perches <joe@perches.com>
>
> arch/alpha/boot/tools/objstrip.c | 2 +-
> arch/sh/kernel/early_printk.c | 2 +-
> arch/um/include/asm/pgtable-2level.h | 2 +-
> arch/um/include/asm/pgtable-3level.h | 2 +-
> drivers/md/raid1.c | 2 +-
> drivers/md/raid10.c | 2 +-
> drivers/media/video/cx2341x.c | 4 ++--
> drivers/mtd/tests/mtd_stresstest.c | 2 +-
> drivers/net/s2io.c | 2 +-
> drivers/scsi/advansys.c | 2 +-
> drivers/scsi/cxgb3i/cxgb3i.h | 2 +-
> drivers/serial/sh-sci.c | 2 +-
> drivers/staging/winbond/mds.c | 2 +-
> drivers/xen/grant-table.c | 3 +--
> kernel/posix-cpu-timers.c | 2 +-
> lib/radix-tree.c | 2 +-
> sound/pci/ctxfi/ctresource.c | 2 +-
> sound/pci/hda/hda_intel.c | 3 +--
> 18 files changed, 19 insertions(+), 21 deletions(-)
>
> diff --git a/arch/alpha/boot/tools/objstrip.c b/arch/alpha/boot/tools/objstrip.c
> index ef18382..786e736 100644
> --- a/arch/alpha/boot/tools/objstrip.c
> +++ b/arch/alpha/boot/tools/objstrip.c
> @@ -253,7 +253,7 @@ main (int argc, char *argv[])
> }
>
> if (pad) {
> - mem_size = ((mem_size + pad - 1) / pad) * pad;
> + mem_size = DIV_ROUND_UP(mem_size, pad) * pad;
Doesn't this look more like,
#define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y))
> --- a/drivers/media/video/cx2341x.c
> +++ b/drivers/media/video/cx2341x.c
> @@ -304,7 +304,7 @@ static int cx2341x_set_ctrl(struct cx2341x_mpeg_params *params, int busy,
> int b = ctrl->value + 1;
> int gop = params->video_gop_size;
> params->video_b_frames = ctrl->value;
> - params->video_gop_size = b * ((gop + b - 1) / b);
> + params->video_gop_size = b * DIV_ROUND_UP(gop, b);
Same here , roundup() ..
> /* Max GOP size = 34 */
> while (params->video_gop_size > 34)
> params->video_gop_size -= b;
> @@ -313,7 +313,7 @@ static int cx2341x_set_ctrl(struct cx2341x_mpeg_params *params, int busy,
> case V4L2_CID_MPEG_VIDEO_GOP_SIZE: {
> int b = params->video_b_frames + 1;
> int gop = ctrl->value;
> - params->video_gop_size = b * ((gop + b - 1) / b);
> + params->video_gop_size = b * DIV_ROUND_UP(gop, b);
and here..
Seems like there are a few more like this .. Could you either use
roundup() or merge the two macros .. Or explain why your not using it..
Daniel
next prev parent reply other threads:[~2009-08-02 0:10 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-01 19:48 [PATCH 1/5] drivers/media: Use DIV_ROUND_CLOSEST Julia Lawall
2009-08-01 19:48 ` Julia Lawall
2009-08-01 23:43 ` [PATCH] treewide: Use DIV_ROUND_UP Joe Perches
2009-08-01 23:43 ` Joe Perches
2009-08-02 0:10 ` Daniel Walker [this message]
2009-08-02 0:10 ` Daniel Walker
2009-08-02 1:07 ` [PATCH v2 1/2] treewide: Use roundup Joe Perches
2009-08-02 1:07 ` Joe Perches
2009-08-02 1:07 ` [PATCH v2 2/2] treewide: Use DIV_ROUND_UP Joe Perches
2009-08-02 1:07 ` Joe Perches
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=1249171857.6114.5.camel@desktop \
--to=dwalker@fifo99.com \
--cc=joe@perches.com \
--cc=julia@diku.dk \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.