[PATCH] dmaengine: tegra210: avoid broken division

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Arnd Bergmann <arnd@xxxxxxxx>

When build testing on 32-bit targets with 64-bit resource_size_t,
the new probe logic causes a link failure:

arm-linux-gnueabi-ld: drivers/dma/tegra210-adma.o: in function `tegra_adma_probe':
tegra210-adma.c:(.text+0x122c): undefined reference to `__aeabi_uldivmod'

In addition, it seems that the same division can trap when running
on tegra210, which sets .ch_base_offset=0.

Avoid both using the div_u64() helper and an added zero-check.

Fixes: 68811c928f88 ("dmaengine: tegra210-adma: Support channel page")
Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx>
---
 drivers/dma/tegra210-adma.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/dma/tegra210-adma.c b/drivers/dma/tegra210-adma.c
index d80a60de0160..fd339f10151c 100644
--- a/drivers/dma/tegra210-adma.c
+++ b/drivers/dma/tegra210-adma.c
@@ -913,8 +913,9 @@ static int tegra_adma_probe(struct platform_device *pdev)
 			return PTR_ERR(tdma->ch_base_addr);
 
 		res_base = platform_get_resource_byname(pdev, IORESOURCE_MEM, "global");
-		if (res_base) {
-			page_no = (res_page->start - res_base->start) / cdata->ch_base_offset;
+		if (res_base && cdata->ch_base_offset) {
+			page_no = div_u64(res_page->start - res_base->start,
+					  cdata->ch_base_offset);
 			if (page_no <= 0)
 				return -EINVAL;
 			tdma->ch_page_no = page_no - 1;
-- 
2.39.5





[Index of Archives]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux PCI]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux