From: Geert Uytterhoeven <geert+renesas@glider.be>
To: Michael Turquette <mturquette@baylibre.com>,
Stephen Boyd <sboyd@kernel.org>,
Nicolas Ferre <nicolas.ferre@microchip.com>,
Alexandre Belloni <alexandre.belloni@bootlin.com>,
Claudiu Beznea <claudiu.beznea@tuxon.dev>,
Giovanni Cabiddu <giovanni.cabiddu@intel.com>,
Herbert Xu <herbert@gondor.apana.org.au>,
David Miller <davem@davemloft.net>,
Linus Walleij <linus.walleij@linaro.org>,
Bartosz Golaszewski <brgl@bgdev.pl>,
Joel Stanley <joel@jms.id.au>,
Andrew Jeffery <andrew@codeconstruct.com.au>,
Crt Mori <cmo@melexis.com>, Jonathan Cameron <jic23@kernel.org>,
Lars-Peter Clausen <lars@metafoo.de>,
Jacky Huang <ychuang3@nuvoton.com>,
Shan-Chun Hung <schung@nuvoton.com>,
Yury Norov <yury.norov@gmail.com>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
Johannes Berg <johannes@sipsolutions.net>,
Jakub Kicinski <kuba@kernel.org>, Alex Elder <elder@ieee.org>,
David Laight <david.laight.linux@gmail.com>,
Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Cc: linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-renesas-soc@vger.kernel.org, linux-crypto@vger.kernel.org,
qat-linux@intel.com, linux-gpio@vger.kernel.org,
linux-aspeed@lists.ozlabs.org, linux-iio@vger.kernel.org,
linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
Geert Uytterhoeven <geert+renesas@glider.be>
Subject: [PATCH v3 0/4] Non-const bitfield helpers
Date: Fri, 14 Feb 2025 14:55:49 +0100 [thread overview]
Message-ID: <cover.1739540679.git.geert+renesas@glider.be> (raw)
Hi all,
This is an updated subset of a patch series I sent more than 3 years
ago[2].
<linux/bitfield.h> contains various helpers for accessing bitfields, as
typically used in hardware registers for memory-mapped I/O blocks.
These helpers ensure type safety, and deduce automatically shift values
from mask values, avoiding mistakes due to inconsistent shifts and
masks, and leading to a reduction in source code size.
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 introduced its own
field_{prep,get}() macros. Hence my v1 series aimed to make them
available for general use, and convert several drivers to the existing
FIELD_{GET,PREP}() and the new field_{get,prep}() helpers.
Due to some pushback (mostly centered around using the typed
{u*,be*,le*,...}_get_bits() macros instead, which of course would
require making them work with non-constant masks first, too), this
series was never applied, and became buried deep in my TODO haystack...
However, several people still liked the idea: since v1, multiple copies
of the field_{prep,get}() macros appeared upstream, and one more is
queued for v6.15.
Hence I think it's time to revive and consolidate...
Changes compared to v2[1]:
- New patch "[PATCH v3 1/4] bitfield: Drop underscores from macro
parameters",
- Add Acked-by,
- Drop underscores from macro parameters,
- Use __auto_type where possible,
- Correctly cast reg to the mask type,
- Introduces __val and __reg intermediates to simplify the actual
operation,
- Drop unneeded parentheses,
- Clarify having both FIELD_{GET,PREP}() and field_{get,prep}(),
Changes compared to v1[2]:
- Cast val resp. reg to the mask type,
- Fix 64-bit use on 32-bit architectures,
- Convert new upstream users:
- drivers/crypto/intel/qat/qat_common/adf_gen4_pm_debugfs.c
- drivers/gpio/gpio-aspeed.c
- drivers/iio/temperature/mlx90614.c
- drivers/pinctrl/nuvoton/pinctrl-ma35.c
- sound/usb/mixer_quirks.c
- Convert new user queued in renesas-devel for v6.15:
- drivers/soc/renesas/rz-sysc.c
- Drop the last 14 RFC patches.
They can be updated/resubmitted/applied later.
I can take all four patches through the Renesas tree, and provide an
immutable branch with the first two patches for the interested parties.
Thanks for your comments!
[1] "[PATCH v2 0/3] Non-const bitfield helpers"
https://lore.kernel.org/all/cover.1738329458.git.geert+renesas@glider.be
[2] "[PATCH 00/17] Non-const bitfield helper conversions"
https://lore.kernel.org/all/cover.1637592133.git.geert+renesas@glider.be
Geert Uytterhoeven (4):
bitfield: Drop underscores from macro parameters
bitfield: Add non-constant field_{prep,get}() helpers
clk: renesas: Use bitfield helpers
soc: renesas: Use bitfield helpers
drivers/clk/at91/clk-peripheral.c | 1 +
drivers/clk/at91/pmc.h | 3 -
drivers/clk/renesas/clk-div6.c | 6 +-
drivers/clk/renesas/rcar-gen3-cpg.c | 15 +--
drivers/clk/renesas/rcar-gen4-cpg.c | 9 +-
.../qat/qat_common/adf_gen4_pm_debugfs.c | 8 +-
drivers/gpio/gpio-aspeed.c | 5 +-
drivers/iio/temperature/mlx90614.c | 5 +-
drivers/pinctrl/nuvoton/pinctrl-ma35.c | 4 -
drivers/soc/renesas/renesas-soc.c | 4 +-
drivers/soc/renesas/rz-sysc.c | 3 +-
include/linux/bitfield.h | 122 ++++++++++++------
sound/usb/mixer_quirks.c | 4 -
13 files changed, 97 insertions(+), 92 deletions(-)
--
2.43.0
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
next reply other threads:[~2025-02-14 13:56 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-14 13:55 Geert Uytterhoeven [this message]
2025-02-14 13:55 ` [PATCH v3 1/4] bitfield: Drop underscores from macro parameters Geert Uytterhoeven
2025-02-14 13:55 ` [PATCH treewide v3 2/4] bitfield: Add non-constant field_{prep,get}() helpers Geert Uytterhoeven
2025-02-14 14:05 ` Crt Mori
2025-02-14 15:34 ` Jakub Kicinski
2025-02-14 16:46 ` David Laight
2025-10-17 10:55 ` Geert Uytterhoeven
2025-10-17 10:55 ` Geert Uytterhoeven
2025-10-17 15:19 ` Jakub Kicinski
2025-10-17 16:00 ` Geert Uytterhoeven
2025-10-17 17:39 ` Jakub Kicinski
2025-02-14 13:55 ` [PATCH v3 3/4] clk: renesas: Use bitfield helpers Geert Uytterhoeven
2025-02-14 13:55 ` [PATCH v3 4/4] soc: " Geert Uytterhoeven
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cover.1739540679.git.geert+renesas@glider.be \
--to=geert+renesas@glider.be \
--cc=alexandre.belloni@bootlin.com \
--cc=andrew@codeconstruct.com.au \
--cc=brgl@bgdev.pl \
--cc=claudiu.beznea@tuxon.dev \
--cc=cmo@melexis.com \
--cc=davem@davemloft.net \
--cc=david.laight.linux@gmail.com \
--cc=elder@ieee.org \
--cc=giovanni.cabiddu@intel.com \
--cc=herbert@gondor.apana.org.au \
--cc=jic23@kernel.org \
--cc=joel@jms.id.au \
--cc=johannes@sipsolutions.net \
--cc=kuba@kernel.org \
--cc=lars@metafoo.de \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-aspeed@lists.ozlabs.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=mailhol.vincent@wanadoo.fr \
--cc=mturquette@baylibre.com \
--cc=nicolas.ferre@microchip.com \
--cc=perex@perex.cz \
--cc=qat-linux@intel.com \
--cc=sboyd@kernel.org \
--cc=schung@nuvoton.com \
--cc=tiwai@suse.com \
--cc=ychuang3@nuvoton.com \
--cc=yury.norov@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).