lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250307102405.56313-1-arnd@kernel.org>
Date: Fri,  7 Mar 2025 11:23:56 +0100
From: Arnd Bergmann <arnd@...nel.org>
To: Shreeya Patel <shreeya.patel@...labora.com>,
	Mauro Carvalho Chehab <mchehab@...nel.org>,
	Dingxian Wen <shawn.wen@...k-chips.com>,
	Hans Verkuil <hverkuil@...all.nl>,
	Dmitry Osipenko <dmitry.osipenko@...labora.com>
Cc: Arnd Bergmann <arnd@...db.de>,
	linux-media@...r.kernel.org,
	kernel@...labora.com,
	linux-kernel@...r.kernel.org
Subject: [PATCH] media: platform: synopsys: use div_u64() for 64-bit division

From: Arnd Bergmann <arnd@...db.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@...db.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


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ