All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@kernel.org>
To: Shreeya Patel <shreeya.patel@collabora.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Dingxian Wen <shawn.wen@rock-chips.com>,
	Hans Verkuil <hverkuil@xs4all.nl>,
	Dmitry Osipenko <dmitry.osipenko@collabora.com>
Cc: Arnd Bergmann <arnd@arndb.de>,
	linux-media@vger.kernel.org, kernel@collabora.com,
	linux-kernel@vger.kernel.org
Subject: [PATCH] media: platform: synopsys: use div_u64() for 64-bit division
Date: Fri,  7 Mar 2025 11:23:56 +0100	[thread overview]
Message-ID: <20250307102405.56313-1-arnd@kernel.org> (raw)

From: Arnd Bergmann <arnd@arndb.de>

One open-coded division causes a link failure on 32-bit architectures:

ld.lld-21: error: undefined symbol: __aeabi_uldivmod
>>> referenced by snps_hdmirx.c
>>>               drivers/media/platform/synopsys/hdmirx/snps_hdmirx.o:(hdmirx_query_dv_timings) in archive vmlinux.a

Another one uses do_div() with a temporary variable.

Change both to use div_u64() to avoid the link failure and improve
readability.

Fixes: 7b59b132ad43 ("media: platform: synopsys: Add support for HDMI input driver")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/media/platform/synopsys/hdmirx/snps_hdmirx.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/media/platform/synopsys/hdmirx/snps_hdmirx.c b/drivers/media/platform/synopsys/hdmirx/snps_hdmirx.c
index 4ffc86ad6c35..438536d88c7f 100644
--- a/drivers/media/platform/synopsys/hdmirx/snps_hdmirx.c
+++ b/drivers/media/platform/synopsys/hdmirx/snps_hdmirx.c
@@ -296,7 +296,7 @@ static void hdmirx_get_timings(struct snps_hdmirx_dev *hdmirx_dev,
 	hfp = htotal - hact - hs - hbp;
 	vfp = vtotal - vact - vs - vbp;
 
-	fps = (bt->pixelclock + (htotal * vtotal) / 2) / (htotal * vtotal);
+	fps = div_u64(bt->pixelclock + (htotal * vtotal) / 2, htotal * vtotal);
 	bt->width = hact;
 	bt->height = vact;
 	bt->hfrontporch = hfp;
@@ -396,7 +396,7 @@ static int hdmirx_get_detected_timings(struct snps_hdmirx_dev *hdmirx_dev,
 	u32 val, tmdsqpclk_freq, pix_clk;
 	unsigned int num_retries = 0;
 	u32 field_type, deframer_st;
-	u64 tmp_data, tmds_clk;
+	u64 tmds_clk;
 	bool is_dvi_mode;
 	int ret;
 
@@ -418,9 +418,7 @@ static int hdmirx_get_detected_timings(struct snps_hdmirx_dev *hdmirx_dev,
 
 	tmdsqpclk_freq = hdmirx_readl(hdmirx_dev, CMU_TMDSQPCLK_FREQ);
 	tmds_clk = tmdsqpclk_freq * 4 * 1000;
-	tmp_data = tmds_clk * 24;
-	do_div(tmp_data, hdmirx_dev->color_depth);
-	pix_clk = tmp_data;
+	pix_clk = div_u64(tmds_clk * 24, hdmirx_dev->color_depth);
 	bt->pixelclock = pix_clk;
 
 	if (hdmirx_dev->pix_fmt == HDMIRX_YUV420)
-- 
2.39.5


             reply	other threads:[~2025-03-07 10:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-07 10:23 Arnd Bergmann [this message]
2025-03-07 10:31 ` [PATCH] media: platform: synopsys: use div_u64() for 64-bit division Dmitry Osipenko

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=20250307102405.56313-1-arnd@kernel.org \
    --to=arnd@kernel.org \
    --cc=arnd@arndb.de \
    --cc=dmitry.osipenko@collabora.com \
    --cc=hverkuil@xs4all.nl \
    --cc=kernel@collabora.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=shawn.wen@rock-chips.com \
    --cc=shreeya.patel@collabora.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.