Re: [PATCH v3 2/2] iio: frequency: ad9832: simplify bitwise math

From: Andy Shevchenko

Date: Tue Apr 14 2026 - 08:36:32 EST


On Tue, Apr 14, 2026 at 12:45:31PM +0200, Joshua Crofts wrote:
> On Tue, 14 Apr 2026 at 11:57, Andy Shevchenko
> <andriy.shevchenko@xxxxxxxxx> wrote:
> > It's up to you. (u64) casting here is not bad per se. And it's more robust
> > against changes in the second operand the type of which is hidden currently.
> > (Reading again what I just wrote, it seems I objecting my own suggestion!)

> If I'm not mistaken, the compiler would always do a type promotion of the
> "smaller" operand (in this case fout). By casting at this point we're just doing
> the work for it, so I guess it doesn't matter.

Yes, and the problem here that BIT_ULL() is (semi)hidden on what it returns for
smaller values. Explicit casting helps with that (while not needed). The problem
that might appear in the future if on some circumstances the both operands become
of 32-bit types... You won't get 64-bit value out of that without casting.

--
With Best Regards,
Andy Shevchenko