lkml.org 
[lkml]   [2023]   [May]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 6/8] auto: promote DIV_U64_ROUND_CLOSEST macro to function
Date
Both arguments are cast to specific types, so moving cast earlier is OK.

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
include/linux/math64.h | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/include/linux/math64.h b/include/linux/math64.h
index d8770c8a9cff..3ab235c8a94c 100644
--- a/include/linux/math64.h
+++ b/include/linux/math64.h
@@ -328,8 +328,10 @@ static inline u64 DIV64_U64_ROUND_CLOSEST(u64 dividend, u64 divisor)
*
* Return: dividend / divisor rounded to nearest integer
*/
-#define DIV_U64_ROUND_CLOSEST(dividend, divisor) \
- ({ u32 _tmp = (divisor); div_u64((u64)(dividend) + _tmp / 2, _tmp); })
+static inline u64 DIV_U64_ROUND_CLOSEST(u64 dividend, u32 divisor)
+{
+ return div_u64(dividend + divisor / 2, divisor);
+}

/**
* DIV_S64_ROUND_CLOSEST - signed 64bit divide with 32bit divisor rounded to nearest integer
--
2.40.1
\
 
 \ /
  Last update: 2023-05-18 17:48    [W:0.065 / U:0.784 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site