From patchwork Fri Jan 31 13:46:50 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 13955391 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6B3D6C0218F for ; Fri, 31 Jan 2025 13:51:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=JMEGILcF69irU9arW/KgodIGGc36sjVPZdJq9Ew/JBs=; b=EjAVrpsfrXArmu5QSicUArAoXX FQlvto7g2/EFb2KfE++HP9ADLlnK5qPhsCDvdMt+qoWnyiNTasQQfg6YprfBSoKOS1P9mHk2zhMqs KX+lds6a5NQo1/0FmaekqspP2VNFoez9pmijBxQrmr7rZjdpTtQO1JxVFvIL1qMit/4CREm/UxxqX yyh/HeJ/0mTBnE9ZYB05CqaYGX1RPbJoExBcHxE4kFjUeBTim3sDVWNqw6Z6trcITdCTRkYim6h6w CiajKadp7NWgIyzQ3WDbdrOTLTCwir4F27PAEb/MKhdh36eqS9I4OxVXpWrY/BlorPh58AKGTNnd1 WADgkjAw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tdrQi-0000000Aii0-2GOk; Fri, 31 Jan 2025 13:51:32 +0000 Received: from baptiste.telenet-ops.be ([2a02:1800:120:4::f00:13]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tdrMo-0000000AiKF-3uRg for linux-arm-kernel@lists.infradead.org; Fri, 31 Jan 2025 13:47:34 +0000 Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed80:a916:3147:9f19:c260]) by baptiste.telenet-ops.be with cmsmtp id 7pmw2E00W0naHe801pmwxH; Fri, 31 Jan 2025 14:47:24 +0100 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtp (Exim 4.97) (envelope-from ) id 1tdrM6-0000000FHxr-1qQW; Fri, 31 Jan 2025 14:46:56 +0100 Received: from geert by rox.of.borg with local (Exim 4.97) (envelope-from ) id 1tdrMG-0000000DFVN-1Vog; Fri, 31 Jan 2025 14:46:56 +0100 From: Geert Uytterhoeven To: Michael Turquette , Stephen Boyd , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , Giovanni Cabiddu , Herbert Xu , "David S . Miller" , Linus Walleij , Bartosz Golaszewski , Joel Stanley , Andrew Jeffery , Crt Mori , Jonathan Cameron , Lars-Peter Clausen , Jacky Huang , Shan-Chun Hung , Yury Norov , Rasmus Villemoes , Jaroslav Kysela , Takashi Iwai , Johannes Berg , Jakub Kicinski , Alex Elder 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 Subject: [PATCH v2 0/3] Non-const bitfield helpers Date: Fri, 31 Jan 2025 14:46:50 +0100 Message-ID: X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250131_054731_108331_B260B4F5 X-CRM114-Status: GOOD ( 24.17 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi all, This is an updated subset of a patch series I sent more than 3 years ago[1]. 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 v1: - 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 three patches through the Renesas tree, and provide an immutable branch with the first patch for ther interested parties. Thanks for your comments! [1] "[PATCH 00/17] Non-const bitfield helper conversions" https://lore.kernel.org/all/cover.1637592133.git.geert+renesas@glider.be Geert Uytterhoeven (3): 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 | 34 +++++++++++++++++++ sound/usb/mixer_quirks.c | 4 --- 13 files changed, 52 insertions(+), 49 deletions(-)