Re: [PATCH 2/7] iio: inkern: Add API for reading/writing events

From: Andy Shevchenko
Date: Wed Jul 16 2025 - 05:28:59 EST


On Tue, Jul 15, 2025 at 11:42:05AM -0400, Sean Anderson wrote:
> On 7/15/25 04:18, Andy Shevchenko wrote:
> > On Mon, Jul 14, 2025 at 09:20:18PM -0400, Sean Anderson wrote:

...

> >> +EXPORT_SYMBOL_GPL(iio_event_mode);
> >
> > Can we move this to namespace? Otherwise it will be never ending story...
> > Ditto for other new APIs.
>
> Never ending story of what?

Of converting IIO core to use exported namespaces.

...

> >> + if (scale64 <= INT_MAX && scale64 >= INT_MIN)
> >> + raw64 = processed / (int)scale64;
> >
> > Do you need the casting? (I mean if the compiler is dumb enough to not see this)
>
> AIUI 64-bit division is not available on 32-bit platforms. The cast
> ensures we get 32-bit division.

I put specifically a remark in the parentheses. So, the Q is if the compiler
doesn't recognize that. Can you confirm that 32-bit compilation without cast
is broken?

...

> >> + *raw = clamp(raw64, (s64)INT_MIN, (s64)INT_MAX);
> >
> > You already have similar approach here...
>
> Well, I can spell it 0x7fffffffLL if you'd like...

Nope, I like to have named constants instead of magics, but actually are those
castings needed for the clamp()?

--
With Best Regards,
Andy Shevchenko