Thread (40 messages) 40 messages, 11 authors, 2021-11-24

Re: [PATCH 01/17] bitfield: Add non-constant field_{prep,get}() helpers

From: Jakub Kicinski <kuba@kernel.org>
Date: 2021-11-23 23:39:46
Also in: alsa-devel, linux-aspeed, linux-clk, linux-iio, linux-media, linux-mmc, linux-omap, linux-pm, linux-renesas-soc, linux-wireless, lkml, netdev

On Tue, 23 Nov 2021 09:36:22 +0100 Geert Uytterhoeven wrote:
quoted
quoted
Also, you're using __ffs(), which doesn't work for 64-bit on 32-bit
architectures (afaict), so that seems a bit awkward.

Maybe we can make {u32,...}_get_bits() be doing compile-time only checks
if it is indeed a constant? The __field_overflow() usage is already only
done if __builtin_constant_p(v), so I guess we can do the same with
__bad_mask()?  
Either that or add decomposition macros. Are compilers still really bad
at passing small structs by value?  
Sorry, I don't get what you mean by adding decomposition macros.
Can you please elaborate?
#define DECOMPOSE(_mask) \
  (struct bf){ .mask = _mask, .shf = __bf_shf(_mask), }

Then drivers can save or pass around the mask and shift params 
broken apart as a small struct.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help