Re: drivers/media/test-drivers/vimc/vimc-sensor.c:107:1-7: WARNING: do_div() does a 64-by-32 division, please consider using div64_u64 instead.

From: Geert Uytterhoeven

Date: Tue Apr 21 2026 - 03:00:43 EST


On Mon, 20 Apr 2026 at 19:29, kernel test robot <lkp@xxxxxxxxx> wrote:
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head: faeab166167f5787719eb8683661fd41a3bb1514
> commit: ec1e620b245495121535bf5c046c6885c7e409cb media: vimc: sensor: Add pixel_rate,vblank and hblank configuration
> date: 5 weeks ago
> config: sparc64-randconfig-r064-20260419
> compiler: clang version 23.0.0git (https://github.com/llvm/llvm-project 5bac06718f502014fade905512f1d26d578a18f3)
>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Fixes: ec1e620b2454 ("media: vimc: sensor: Add pixel_rate,vblank and hblank configuration")
> | Reported-by: kernel test robot <lkp@xxxxxxxxx>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202604191731.10nxGZ92-lkp@xxxxxxxxx/
>
> cocci warnings: (new ones prefixed by >>)
> >> drivers/media/test-drivers/vimc/vimc-sensor.c:107:1-7: WARNING: do_div() does a 64-by-32 division, please consider using div64_u64 instead.
>
> vim +107 drivers/media/test-drivers/vimc/vimc-sensor.c
>
> 94
> 95 static int vimc_sensor_update_frame_timing(struct v4l2_subdev *sd,
> 96 u32 width, u32 height)
> 97 {
> 98 struct vimc_sensor_device *vsensor =
> 99 container_of(sd, struct vimc_sensor_device, sd);
> 100 u64 pixel_rate = vsensor->pixel_rate->val;

v4l2_ctrl.val is s32, not u64.

> 101 u32 hts = width + vsensor->hblank->val;
> 102 u32 vts = height + vsensor->vblank->val;
> 103 u64 total_pixels = (u64)hts * vts;

mul_u32_u32()

> 104 u64 frame_interval_ns;
> 105
> 106 frame_interval_ns = total_pixels * NSEC_PER_SEC;
> > 107 do_div(frame_interval_ns, pixel_rate);
> 108 vsensor->hw.fps_jiffies = nsecs_to_jiffies(frame_interval_ns);
> 109 if (vsensor->hw.fps_jiffies == 0)
> 110 vsensor->hw.fps_jiffies = 1;
> 111
> 112 return 0;
> 113 }
> 114

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds