Re: [PATCH 2/7] iio: inkern: Add API for reading/writing events
From: Sean Anderson
Date: Thu Jul 17 2025 - 12:42:52 EST
On 7/16/25 05:28, Andy Shevchenko wrote:
> 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.
What's the purpose?
>> >> + 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?
inkern.c:(.text.iio_write_event_processed_scale+0x14c): undefined reference to `__aeabi_ldivmod'
>> >> + *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()?
Apparently not. The checks in __clamp_once are only for matching signedness. And
the ints are promoted to s64s when the comparison is made.
--Sean