All of lore.kernel.org
 help / color / mirror / Atom feed
From: Javi Merino <javi.merino@arm.com>
To: Jeff Epler <jepler@unpythonic.net>
Cc: "akpm@linux-foundation.org" <akpm@linux-foundation.org>,
	"intel-gfx@lists.freedesktop.org"
	<intel-gfx@lists.freedesktop.org>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Daniel Vetter <daniel.vetter@intel.com>,
	Jani Nikula <jani.nikula@linux.intel.com>,
	David Airlie <airlied@linux.ie>,
	"Darrick J. Wong" <djwong@us.ibm.com>,
	Guenter Roeck <linux@roeck-us.net>, Alex Elder <elder@ieee.org>
Subject: Re: [PATCH 1/4] kernel.h: Implement DIV_ROUND_CLOSEST_ULL
Date: Tue, 24 Mar 2015 11:49:12 +0000	[thread overview]
Message-ID: <20150324114912.GA3982@e104805> (raw)
In-Reply-To: <20150323170416.GA6161@e104805>

On Mon, Mar 23, 2015 at 05:04:16PM +0000, Javi Merino wrote:
> On Mon, Mar 23, 2015 at 12:34:04PM +0000, Jeff Epler wrote:
> > On Fri, Mar 20, 2015 at 11:14:40AM +0000, Javi Merino wrote:
> > > +/*
> > > + * Same as above but for u64 dividends.  divisor must be a 32-bit
> > > + * number.
> > > + */
> > > +#define DIV_ROUND_CLOSEST_ULL(x, divisor)(		\
> > > +{							\
> > > +	unsigned long long _tmp = (x) + (divisor) / 2;	\
> > > +	do_div(_tmp, divisor);				\
> > > +	_tmp;						\
> > > +}							\
> > > +)
> > 
> > The macro evaluates 'divisor' twice.
> 
> Good catch.  That needs to be fixed.  I could do the typeof trick that
> DIV_ROUND_CLOSEST() does but it's probably better to just create a
> static function as Alex Elder suggests.  I'll send a v2 tomorrow with
> a static function instead.

Nah, thinking about it and seeing the other macros in this file
(esp. DIV_ROUND_UP() and DIV_ROUND_UP_ULL()) I don't think a static
function gives you anything.  I'll just modify the macro to look similar
to DIV_ROUND_CLOSEST()

Cheers,
Javi


WARNING: multiple messages have this Message-ID (diff)
From: Javi Merino <javi.merino@arm.com>
To: Jeff Epler <jepler@unpythonic.net>
Cc: "intel-gfx@lists.freedesktop.org"
	<intel-gfx@lists.freedesktop.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	Daniel Vetter <daniel.vetter@intel.com>,
	"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
	Alex Elder <elder@ieee.org>, Guenter Roeck <linux@roeck-us.net>,
	"Darrick J. Wong" <djwong@us.ibm.com>
Subject: Re: [PATCH 1/4] kernel.h: Implement DIV_ROUND_CLOSEST_ULL
Date: Tue, 24 Mar 2015 11:49:12 +0000	[thread overview]
Message-ID: <20150324114912.GA3982@e104805> (raw)
In-Reply-To: <20150323170416.GA6161@e104805>

On Mon, Mar 23, 2015 at 05:04:16PM +0000, Javi Merino wrote:
> On Mon, Mar 23, 2015 at 12:34:04PM +0000, Jeff Epler wrote:
> > On Fri, Mar 20, 2015 at 11:14:40AM +0000, Javi Merino wrote:
> > > +/*
> > > + * Same as above but for u64 dividends.  divisor must be a 32-bit
> > > + * number.
> > > + */
> > > +#define DIV_ROUND_CLOSEST_ULL(x, divisor)(		\
> > > +{							\
> > > +	unsigned long long _tmp = (x) + (divisor) / 2;	\
> > > +	do_div(_tmp, divisor);				\
> > > +	_tmp;						\
> > > +}							\
> > > +)
> > 
> > The macro evaluates 'divisor' twice.
> 
> Good catch.  That needs to be fixed.  I could do the typeof trick that
> DIV_ROUND_CLOSEST() does but it's probably better to just create a
> static function as Alex Elder suggests.  I'll send a v2 tomorrow with
> a static function instead.

Nah, thinking about it and seeing the other macros in this file
(esp. DIV_ROUND_UP() and DIV_ROUND_UP_ULL()) I don't think a static
function gives you anything.  I'll just modify the macro to look similar
to DIV_ROUND_CLOSEST()

Cheers,
Javi

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2015-03-24 11:49 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-20 11:14 [PATCH 0/4] Consolidate DIV_ROUND_CLOSEST_ULL() Javi Merino
2015-03-20 11:14 ` [PATCH 1/4] kernel.h: Implement DIV_ROUND_CLOSEST_ULL Javi Merino
2015-03-20 13:15   ` Alex Elder
2015-03-20 18:19   ` Emil Velikov
2015-03-20 18:19     ` Emil Velikov
2015-03-20 18:27     ` Javi Merino
2015-03-23  7:41   ` Daniel Vetter
2015-03-23  7:41     ` Daniel Vetter
2015-03-23 12:34   ` Jeff Epler
2015-03-23 17:04     ` Javi Merino
2015-03-23 17:04       ` Javi Merino
2015-03-24 11:49       ` Javi Merino [this message]
2015-03-24 11:49         ` Javi Merino
2015-03-20 11:14 ` [PATCH 2/4] clk: bcm/kona: use DIV_ROUND_CLOSEST_ULL() Javi Merino
2015-03-20 11:14 ` [PATCH 3/4] cpuidle: menu: " Javi Merino
2015-03-20 11:14 ` [PATCH 4/4] media: cxd2820r: " Javi Merino
2015-03-20 11:17   ` Antti Palosaari
2015-03-20 13:51   ` Alex Elder
2015-03-20 17:27     ` Javi Merino
2015-03-20 19:46       ` Alex Elder

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=20150324114912.GA3982@e104805 \
    --to=javi.merino@arm.com \
    --cc=airlied@linux.ie \
    --cc=akpm@linux-foundation.org \
    --cc=daniel.vetter@intel.com \
    --cc=djwong@us.ibm.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=elder@ieee.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=jani.nikula@linux.intel.com \
    --cc=jepler@unpythonic.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    /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.