Re: [PATCH] staging: iio: frequency: ad9832/ad9834: use div64_ul instead of do_div
From: Andy Shevchenko
Date: Tue Jun 30 2026 - 08:05:58 EST
On Tue, Jun 30, 2026 at 09:39:31AM +0200, Joshua Crofts wrote:
> On Tue, 30 Jun 2026 08:53:22 +0530
> Mohamad Raizudeen <raizudeen.kerneldev@xxxxxxxxx> wrote:
...
> > {
> > unsigned long long freqreg = (u64)fout *
> > (u64)((u64)1L << AD9832_FREQ_BITS);
> > - do_div(freqreg, mclk);
> > - return freqreg;
> > + return div64_ul(freqreg, mclk);
> > }
>
> I've actually sent a patch for this previously, however the
> discussion ended with the fact that there really isn't a point in
> doing this, since mclk will always be a value that can fit
> into a 32-bit unsigned type, therefore truncation isn't possible.
Since we are getting more "fixes" in the area, perhaps it's a time to add
a comment in the code summarizing the mentioned discussion?
> See here:
> https://lore.kernel.org/all/20260409182755.499a419c@pumpkin/
--
With Best Regards,
Andy Shevchenko