diff options
| author | Javi Merino <javi.merino@arm.com> | 2015-04-16 15:43:45 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-04-17 09:03:55 -0400 |
| commit | f766093ecb647f5a87bfa456715abbbccee547ce (patch) | |
| tree | 818e47743fc5216fe7647dca2d1d6ca4de78c824 /include/linux/kernel.h | |
| parent | 675cf53c1deaffadc7b6a0b4afe6cdafec86bedb (diff) | |
kernel.h: implement DIV_ROUND_CLOSEST_ULL
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.
Signed-off-by: Javi Merino <javi.merino@arm.com>
Reviewed-by: Jeff Epler <jepler@unpythonic.net>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: David Airlie <airlied@linux.ie>
Cc: Guenter Roeck <linux@roeck-us.net>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
Cc: Alex Elder <elder@linaro.org>
Cc: Antti Palosaari <crope@iki.fi>
Cc: Javi Merino <javi.merino@arm.com>
Cc: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Mike Turquette <mturquette@linaro.org>
Cc: Stephen Boyd <sboyd@codeaurora.org>
Cc: Stephen Hemminger <shemminger@linux-foundation.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/kernel.h')
| -rw-r--r-- | include/linux/kernel.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/include/linux/kernel.h b/include/linux/kernel.h index d6d630d31ef3..3a5b48e52a9e 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h | |||
| @@ -103,6 +103,18 @@ | |||
| 103 | (((__x) - ((__d) / 2)) / (__d)); \ | 103 | (((__x) - ((__d) / 2)) / (__d)); \ |
| 104 | } \ | 104 | } \ |
| 105 | ) | 105 | ) |
| 106 | /* | ||
| 107 | * Same as above but for u64 dividends. divisor must be a 32-bit | ||
| 108 | * number. | ||
| 109 | */ | ||
| 110 | #define DIV_ROUND_CLOSEST_ULL(x, divisor)( \ | ||
| 111 | { \ | ||
| 112 | typeof(divisor) __d = divisor; \ | ||
| 113 | unsigned long long _tmp = (x) + (__d) / 2; \ | ||
| 114 | do_div(_tmp, __d); \ | ||
| 115 | _tmp; \ | ||
| 116 | } \ | ||
| 117 | ) | ||
| 106 | 118 | ||
| 107 | /* | 119 | /* |
| 108 | * Multiplies an integer by a fraction, while avoiding unnecessary | 120 | * Multiplies an integer by a fraction, while avoiding unnecessary |
