[PATCH v3 0/6] Add FIELD_MODIFY() helper
Yury Norov
yury.norov at gmail.com
Wed Apr 23 11:44:47 PDT 2025
On Wed, Apr 23, 2025 at 06:44:15PM +0100, Russell King (Oracle) wrote:
> On Fri, Apr 18, 2025 at 11:08:38AM -0400, Yury Norov wrote:
> > The _replace_bits() functions return fixed-width values, and intended
> > for: "manipulating bitfields both in host- and fixed-endian", as the
> > very first line in the commit message says.
> >
> > Those using _replace_bits() for something else abuse the API, and
> > should switch to FIELD_MODIFY().
>
> Sorry, but please explain this statement, because it means nothing to
> me.
>
> FIELD_MODIFY() replaces bits in host endian. _replace_bits() also
> replaces bits, but has a wider range of which encompass FIELD_MODIFY().
>
> I see nothing that precludes using using _replace_bits() with
> bitfields.
>
> I see nothing that would differentiate the behaviour, other than maybe
> religous ideals about C functions vs macros or upper vs lower case.
Interesting, never heard about religious ideals in C.
> Please explain why you think there's a difference between the two
> because I really can't see any reason not to use one over the other
> apart from asthetics.
I explained that in subtread for 4/6 in this series. Shortly it's
about compiler's ability to catch various errors, like overflows,
and (not unlikely) generated code quality.
More information about the linux-arm-kernel
mailing list