mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Tomas Marek <tomas.marek@elrest.cz>,
	Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 2/2] i2c: efi: use DIV_ROUND_UP_ULL instead of native division
Date: Thu, 15 Aug 2024 08:56:46 +0200	[thread overview]
Message-ID: <20240815065646.1156788-2-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20240815065646.1156788-1-a.fatoum@pengutronix.de>

64-bit division on 32-bit platforms is normally handled by libgcc,
which, like the kernel, we don't link against in barebox.

Instead we have a number of division helpers that should be used for
64-bit division, which either expand to a normal division if possible or
to an out-of-line division. Make use of this to fix compilation for
32-bit.

Cc: Tomas Marek <tomas.marek@elrest.cz>
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
This replaces "i2c: efi: avoid 64-bit division"
---
 drivers/i2c/busses/i2c-efi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-efi.c b/drivers/i2c/busses/i2c-efi.c
index 5f6cc0eed28e..4c58279e0398 100644
--- a/drivers/i2c/busses/i2c-efi.c
+++ b/drivers/i2c/busses/i2c-efi.c
@@ -114,7 +114,7 @@ static unsigned int efi_i2c_msg_op_cnt(const struct efi_i2c_priv *i2c_priv,
 
 	max_len = efi_i2c_max_len(i2c_priv, msg);
 
-	return ((u64)msg->len + max_len - 1) / max_len;
+	return DIV_ROUND_UP_ULL(msg->len, max_len);
 }
 
 static unsigned int efi_i2c_req_op_cnt(
-- 
2.39.2




  reply	other threads:[~2024-08-15  6:57 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-15  6:56 [PATCH 1/2] include: linux/math.h: promote DIV_ROUND_UP_ULL args to 64-bit Ahmad Fatoum
2024-08-15  6:56 ` Ahmad Fatoum [this message]
2024-08-20  5:28   ` [PATCH 2/2] i2c: efi: use DIV_ROUND_UP_ULL instead of native division Tomas Marek
2024-08-20 12:07 ` [PATCH 1/2] include: linux/math.h: promote DIV_ROUND_UP_ULL args to 64-bit Sascha Hauer

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=20240815065646.1156788-2-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=tomas.marek@elrest.cz \
    /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