mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alexey Dobriyan <adobriyan@gmail.com>
To: akpm@linux-foundation.org
Cc: linux-kernel@vger.kernel.org, adobriyan@gmail.com
Subject: [PATCH 5/8] auto: promote DIV64_U64_ROUND_CLOSEST macro to function
Date: Thu, 18 May 2023 18:46:46 +0300	[thread overview]
Message-ID: <20230518154648.581643-5-adobriyan@gmail.com> (raw)
In-Reply-To: <20230518154648.581643-1-adobriyan@gmail.com>

Same explanation as for DIV64_U64_ROUND_UP: div64_u64() wants "u64" in
the first argument so using anything wider in calculations before that
doesn't matter.

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 7e0e2625dc35..d8770c8a9cff 100644
--- a/include/linux/math64.h
+++ b/include/linux/math64.h
@@ -313,8 +313,10 @@ static inline u64 DIV64_U64_ROUND_UP(u64 ll, u64 d)
  *
  * Return: dividend / divisor rounded to nearest integer
  */
-#define DIV64_U64_ROUND_CLOSEST(dividend, divisor)	\
-	({ u64 _tmp = (divisor); div64_u64((dividend) + _tmp / 2, _tmp); })
+static inline u64 DIV64_U64_ROUND_CLOSEST(u64 dividend, u64 divisor)
+{
+	return div64_u64(dividend + divisor / 2, divisor);
+}
 
 /**
  * DIV_U64_ROUND_CLOSEST - unsigned 64bit divide with 32bit divisor rounded to nearest integer
-- 
2.40.1


  parent reply	other threads:[~2023-05-18 15:47 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-18 15:46 [PATCH 1/8] auto, kbuild: flatten KBUILD_CFLAGS Alexey Dobriyan
2023-05-18 15:46 ` [PATCH 2/8] auto: add "auto" keyword as alias for __auto_type Alexey Dobriyan
2023-05-18 15:46 ` [PATCH 3/8] auto, proc: use "auto" instead of quite chatty macros Alexey Dobriyan
2023-05-18 15:46 ` [PATCH 4/8] auto: promote DIV64_U64_ROUND_UP macro to function Alexey Dobriyan
2023-05-18 15:46 ` Alexey Dobriyan [this message]
2023-05-18 15:46 ` [PATCH 6/8] auto: promote DIV_U64_ROUND_CLOSEST " Alexey Dobriyan
2023-05-18 15:46 ` [PATCH 7/8] auto: promote DIV_S64_ROUND_CLOSEST " Alexey Dobriyan
2023-05-18 20:37 ` [PATCH 1/8] auto, kbuild: flatten KBUILD_CFLAGS Andrew Morton
2023-05-19 11:15   ` Alexey Dobriyan

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=20230518154648.581643-5-adobriyan@gmail.com \
    --to=adobriyan@gmail.com \
    --cc=akpm@linux-foundation.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®