Message ID | cover.1637592133.git.geert+renesas@glider.be (mailing list archive) |
---|---|
Headers | show |
Series | Non-const bitfield helper conversions | expand |
Hi Alexandre, On Mon, Nov 22, 2021 at 6:50 PM Alexandre Belloni <alexandre.belloni@bootlin.com> wrote: > On 22/11/2021 16:53:53+0100, Geert Uytterhoeven wrote: > > The existing FIELD_{GET,PREP}() macros are limited to compile-time > > constants. However, it is very common to prepare or extract bitfield > > elements where the bitfield mask is not a compile-time constant. > > To avoid this limitation, the AT91 clock driver already has its own > > field_{prep,get}() macros. > > My understanding was that this (being compile time only) was actually > done on purpose. Did I misunderstand? Yes, it was done on purpose, to maximize type safety. However, this imposes a severe limitation: we cannot use them in case the mask is non-const (i.e. stored in some data structure). This is a quite common use-case, given the examples I found and converted, and given you added field_{get,prep}() to the AT91 clock driver. Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds