Re: drivers/iio/common/scmi_sensors/scmi_iio.c:247:1-7: WARNING: do_div() does a 64-by-32 division, please consider using div64_u64 instead.

Geert Uytterhoeven <[email protected]>
Newsgroups org.kernel.vger.arm-scmi,dev.linux.lists.oe-kbuild-all,org.kernel.vger.linux-iio,org.kernel.vger.linux-kernel
Message-ID <CAMuHMdUqo5C9epmE1idc15x9nByhVZP5Hdb5OKtOLSMakb+sfA@mail.gmail.com>
CC IIO/SCMI

On Wed, 3 Jun 2026 at 20:36, kernel test robot <[email protected]> wrote:
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head:   ba3e43a9e601636f5edb54e259a74f96ca3b8fd8
> commit: a0e2cb6a90634f3dc80f16e882a683ee5761b0b0 um: Add VFIO-based virtual PCI driver
> date:   1 year, 1 month ago
> config: um-randconfig-r052-20260603 (https://download.01.org/0day-ci/archive/20260604/[email protected]/config)
> compiler: clang version 23.0.0git (https://github.com/llvm/llvm-project e5ab4f8a1f766febdc65ce89c00dec85393cfd68)
>
> 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: a0e2cb6a9063 ("um: Add VFIO-based virtual PCI driver")
> | Reported-by: kernel test robot <[email protected]>
> | Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
>
> cocci warnings: (new ones prefixed by >>)
> >> drivers/iio/common/scmi_sensors/scmi_iio.c:247:1-7: WARNING: do_div() does a 64-by-32 division, please consider using div64_u64 instead.
>    drivers/iio/common/scmi_sensors/scmi_iio.c:507:2-8: WARNING: do_div() does a 64-by-32 division, please consider using div64_u64 instead.
>    drivers/iio/common/scmi_sensors/scmi_iio.c:273:2-8: WARNING: do_div() does a 64-by-32 division, please consider using div64_u64 instead.
>    drivers/iio/common/scmi_sensors/scmi_iio.c:166:1-7: WARNING: do_div() does a 64-by-32 division, please consider using div64_u64 instead.
>
> vim +247 drivers/iio/common/scmi_sensors/scmi_iio.c
>
> f774117c96f94c Jyoti Bhayana 2021-03-09  238
> f774117c96f94c Jyoti Bhayana 2021-03-09  239  static void convert_ns_to_freq(u64 interval_ns, u64 *hz, u64 *uhz)
> f774117c96f94c Jyoti Bhayana 2021-03-09  240  {
> f774117c96f94c Jyoti Bhayana 2021-03-09  241    u64 rem, freq;
> f774117c96f94c Jyoti Bhayana 2021-03-09  242
> f774117c96f94c Jyoti Bhayana 2021-03-09  243    freq = NSEC_PER_SEC;
> f774117c96f94c Jyoti Bhayana 2021-03-09  244    rem = do_div(freq, interval_ns);
> f774117c96f94c Jyoti Bhayana 2021-03-09  245    *hz = freq;
> f774117c96f94c Jyoti Bhayana 2021-03-09  246    *uhz = rem * 1000000UL;
> f774117c96f94c Jyoti Bhayana 2021-03-09 @247    do_div(*uhz, interval_ns);

Indeed, most do_div() use in that driver is broken on 32-bit.

> f774117c96f94c Jyoti Bhayana 2021-03-09  248  }
> f774117c96f94c Jyoti Bhayana 2021-03-09  249
>
> :::::: The code at line 247 was first introduced by commit
> :::::: f774117c96f94c7c4d2f076e4cacc80218b0df48 iio/scmi: Adding support for IIO SCMI Based Sensors
>
> :::::: TO: Jyoti Bhayana <[email protected]>
> :::::: CC: Jonathan Cameron <[email protected]>

So why was this sent to different people instead?

Gr{oetje,eeting}s,

                        Geert


--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.