Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

media: amlogic: c3-mipi-csi2: Handle 64-bits division

The kernel test robot reports the following error when building on
Hexagon with hexagon-allmodconfig.

ERROR: modpost: "__hexagon_divdi3"
[drivers/media/platform/amlogic/c3/mipi-csi2/c3-mipi-csi2.ko] undefined!

The error is caused by using DIV_ROUND_UP() with a 64 bits divisor with
a 32-bit dividend, which on Hexagon and clang-17 is resolved with a call
to the __hexagon_divdi3() helper function, part of the compiler support
library and not available when building Linux.

Use DIV_ROUND_UP_ULL() to fix the build error and avoid calling the
__hexagon_divdi3() helper function.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202505101334.UHxNcUUO-lkp@intel.com/
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>

authored by

Jacopo Mondi and committed by
Hans Verkuil
1b83a9f4 3328eb4d

+2 -1
+2 -1
drivers/media/platform/amlogic/c3/mipi-csi2/c3-mipi-csi2.c
··· 5 5 6 6 #include <linux/clk.h> 7 7 #include <linux/device.h> 8 + #include <linux/math.h> 8 9 #include <linux/module.h> 9 10 #include <linux/mutex.h> 10 11 #include <linux/platform_device.h> ··· 322 321 u32 settle; 323 322 324 323 /* Calculate the high speed settle */ 325 - val = DIV_ROUND_UP(1000000000, rate); 324 + val = DIV_ROUND_UP_ULL(1000000000, rate); 326 325 settle = (16 * val + 230) / 10; 327 326 328 327 c3_mipi_csi_write(csi, MIPI_PHY_CLK_LANE_CTRL,