lkml.org 
[lkml]   [2026]   [Apr]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 1/9] bitfield: add FIELD_GET_SIGNED()
From
Date
On Fri, 2026-04-24 at 12:35 -0400, Yury Norov wrote:
> > I (personally) tend to prefer the "__MAKE_OP" versions (*_get_bits()
> > etc.), in particular because WiFi and firmware interfaces deal a lot
> > with fixed endian fields.
>
> I don't like that __MAKE_OP magic because whatever it generates is not
> greppable. And because we disable strict type checks for kernel, but
> this API claims to typecheck the parameters for the user. So, the
> following compiles well:
>
> u64 val = 0;
> ret = le16_get_bits(val, GENMASK(15, 10));
>
> I don't like autogeneration in general. We generate, for example,
> be32_get_bits(), but never use it.

That's a lot of "I don't like", but whatever.


> We don't even know the level of the bloat.

These are static inlines so there's no binary cost, and given that
you're complaining about them being generated you can't really *also*
complain about too much code...

> > Any chance it'd be simple to generate u32_get_bits_signed() etc.? Could
> > be especially useful for le32_get_bits_signed() for example, to have the
> > endian conversion built-in unlike FIELD_GET_SIGNED().
>
> Maybe this:
>
> FIELD_GET_SIGNED(mask, le32_to_cpu(reg))

Awful. "I don't like". But we rarely deal with bit-packed signed values
anyway.

johannes

\
 
 \ /
  Last update: 2026-04-27 10:37    [W:0.143 / U:5.673 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and my Meterkast|Read the blog