Skip to content

Commit 6af7e00

Browse files
arndbhverkuil
authored andcommitted
media: staging/ipu7: avoid division by 64-bit value
On 32-bit targets, this causes a link failure: x86_64-linux-ld: drivers/staging/media/ipu7/ipu7-isys-csi-phy.o: in function `ipu7_isys_phy_config': ipu7-isys-csi-phy.c:(.text+0x1509): undefined reference to `__udivdi3' Note that this does not divide a 64-bit number by a 32-bit one as usual, but the other way round, which is something that the compiler should really be able to figure out but does not (as of gcc-15). A few lines higher, a similar division is done using the incorrect div_u64() that truncates the 64-bit divisor to 32 bits. Change both to use the safe but slow div64_u64() helper. Fixes: a516d36 ("media: staging/ipu7: add IPU7 input system device driver") Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
1 parent 2946bac commit 6af7e00

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

drivers/staging/media/ipu7/ipu7-isys-csi-phy.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,7 @@ static void ipu7_isys_cphy_config(struct ipu7_isys *isys, u8 id, u8 lanes,
734734
u16 reg;
735735
u16 val;
736736
u32 i;
737+
u64 r64;
737738
u32 r;
738739

739740
if (is_ipu7p5(isys->adev->isp->hw_ver))
@@ -806,17 +807,16 @@ static void ipu7_isys_cphy_config(struct ipu7_isys *isys, u8 id, u8 lanes,
806807
dwc_phy_write_mask(isys, id, reg, 2, 0, 2);
807808
}
808809

809-
deass_thresh = (u16)div_u64_rem(7 * 1000 * 6, mbps * 5U, &r) + 1;
810-
if (r != 0)
810+
deass_thresh = (u16)div64_u64_rem(7 * 1000 * 6, mbps * 5U, &r64) + 1;
811+
if (r64 != 0)
811812
deass_thresh++;
812813

813814
reg = CORE_DIG_RW_TRIO0_2;
814815
for (i = 0; i < trios; i++)
815816
dwc_phy_write_mask(isys, id, reg + 0x400 * i,
816817
deass_thresh, 0, 7);
817818

818-
delay_thresh =
819-
((224U - (9U * 7U)) * 1000U) / (5U * mbps) - 7U;
819+
delay_thresh = div64_u64((224U - (9U * 7U)) * 1000U, 5U * mbps) - 7u;
820820

821821
if (delay_thresh < 1)
822822
delay_thresh = 1;

0 commit comments

Comments
 (0)