[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20150323074115.GB1349@phenom.ffwll.local>
Date: Mon, 23 Mar 2015 08:41:15 +0100
From: Daniel Vetter <daniel@...ll.ch>
To: Javi Merino <javi.merino@....com>
Cc: akpm@...ux-foundation.org, intel-gfx@...ts.freedesktop.org,
linux-kernel@...r.kernel.org, dri-devel@...ts.freedesktop.org,
Daniel Vetter <daniel.vetter@...el.com>,
Guenter Roeck <linux@...ck-us.net>,
"Darrick J. Wong" <djwong@...ibm.com>
Subject: Re: [PATCH 1/4] kernel.h: Implement DIV_ROUND_CLOSEST_ULL
On Fri, Mar 20, 2015 at 11:14:40AM +0000, Javi Merino wrote:
> We have grown a number of different implementations of
> DIV_ROUND_CLOSEST_ULL throughout the kernel. Move the i915 one to
> kernel.h so that it can be reused.
>
> Cc: Daniel Vetter <daniel.vetter@...el.com>
> Cc: Jani Nikula <jani.nikula@...ux.intel.com>
> Cc: David Airlie <airlied@...ux.ie>
> Cc: Darrick J. Wong <djwong@...ibm.com>
> Cc: Guenter Roeck <linux@...ck-us.net>
> Cc: Andrew Morton <akpm@...ux-foundation.org>
> Signed-off-by: Javi Merino <javi.merino@....com>
Acked-by: Daniel Vetter <daniel.vetter@...ll.ch>
And preemptive ack for the next version with the includes at different
places.
-Daniel
> ---
> drivers/gpu/drm/i915/intel_drv.h | 4 +---
> include/linux/kernel.h | 11 +++++++++++
> 2 files changed, 12 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
> index eef79ccd0b7c..346e28fdd7dd 100644
> --- a/drivers/gpu/drm/i915/intel_drv.h
> +++ b/drivers/gpu/drm/i915/intel_drv.h
> @@ -28,6 +28,7 @@
> #include <linux/async.h>
> #include <linux/i2c.h>
> #include <linux/hdmi.h>
> +#include <linux/kernel.h>
> #include <drm/i915_drm.h>
> #include "i915_drv.h"
> #include <drm/drm_crtc.h>
> @@ -36,9 +37,6 @@
> #include <drm/drm_dp_mst_helper.h>
> #include <drm/drm_rect.h>
>
> -#define DIV_ROUND_CLOSEST_ULL(ll, d) \
> -({ unsigned long long _tmp = (ll)+(d)/2; do_div(_tmp, d); _tmp; })
> -
> /**
> * _wait_for - magic (register) wait macro
> *
> diff --git a/include/linux/kernel.h b/include/linux/kernel.h
> index d6d630d31ef3..f7d744e9d275 100644
> --- a/include/linux/kernel.h
> +++ b/include/linux/kernel.h
> @@ -103,6 +103,17 @@
> (((__x) - ((__d) / 2)) / (__d)); \
> } \
> )
> +/*
> + * 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; \
> +} \
> +)
>
> /*
> * Multiplies an integer by a fraction, while avoiding unnecessary
> --
> 1.9.1
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@...ts.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists