Re: [PATCH] iio: frequency: ad983x: replace do_div() with div64_ul().

From: Joshua Crofts

Date: Thu Apr 09 2026 - 15:58:55 EST


On Thu, 9 Apr 2026 at 19:27, David Laight <david.laight.linux@xxxxxxxxx> wrote:
> Except here you have clock frequencies.
> Either they fit in 32bits or they don't.
> So the value shouldn't be 'unsigned long', but either u32 or u64.

The clk struct in linux/clk.h explicitly uses an unsigned long to represent
the clock value, which is used in this driver. Using an unsigned long
ensures platform independent usage without type mismatching.

> You need to check the domain of the values, coccinelle is just looking
> at the types.
> Even with mclk being 'unsigned long' the code is fine provided the
> frequency is below 4.2GHz.

I agree that we're not dealing with potential truncation problems, however
changing to div64_ul aligns the types with the clk API and scrubs a perfectly
valid cocci error.

--
Kind regards

CJD