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

Andy Shevchenko
2026-04-14T16:59:26Z

On Tue, Apr 14, 2026 at 04:02:30PM +0300, Dan Carpenter wrote:
> On Tue, Apr 14, 2026 at 03:33:52PM +0300, Andy Shevchenko wrote:
> > 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@intel.com> 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.
>
> There is no way we'd implement a BIT_ULL() that doesn't give you a ULL.

I meant that it's not crystal clear, one needs to know the naming convention of
BIT_ULL() and/or check the implementation. Reading (u64) is much clearer in
that sense. Also in case of BIT_ULL() parameter being < 32 it may be replaced
with BIT().

--
With Best Regards,
Andy Shevchenko