From: Raffaele Tranfaglia Subject: [PATCH v3 0/3] regmap: handle values wider than val_bits consistently Date: Sun, 29 Nov 2026 12:18:04 +0000 Message-Id: <20261129-regmap-kunit-val-bits-v3-0-499917221d04@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-B4-Tracking: v=1; b=H4sIAAAAAAAC/4WNyw6CMBBFf4V07ZhOKw9d+R/GBS0FRnmlhUZD+ HcLbtgYlyc599yZOWPJOHaJZmaNJ0d9F0AeIqbrvKsMUBGYCS4SREzBmqrNB3hOHY3g8wYUjQ6 SUyoljw3PpGJhO1hT0mvr3u5fdpN6GD2usdWoyY29fW/HHlfv34dHQMhRF1zwRApMr8Gi5qj7l q0fXuwqIv5VEcAhw0JJlZ51Ict9ZVmWD52JzLgSAQAA X-Change-ID: 20261117-regmap-kunit-val-bits-6473305e083b To: Mark Brown , Greg Kroah-Hartman , "Rafael J. Wysocki" , Danilo Krummrich , Johan Hovold , Liam Girdwood , Jaroslav Kysela , Takashi Iwai Cc: Andy Shevchenko , Jonathan Cameron , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, driver-core@lists.linux.dev, linux-sound@vger.kernel.org, Neo Chang , Raffaele Tranfaglia X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1795954687; l=2244; i=raffaele.tranfaglia@gmail.com; s=20261011; h=from:subject:message-id; bh=iS5W7JQLz7PoK35jA9K5CT+uIszL0hLOYZotng36fAE=; b=IzHI5zJIUEPCfUeNgqud6tm5A0fpiSKNCDwgzLiGSvkBiuEesgtKx+Hesn24PUPiJvpAY5bpq Rv0gHn7nEhzCWH9cL6w+3VkFBn2BsZKbwq+WyyFaIS3Zy6maFY0iW6+ X-Developer-Key: i=raffaele.tranfaglia@gmail.com; a=ed25519; pk=mweuSGNM6vguCTdqa+aiHwMXdgk70suj2wolzCp6XGM= X-Endpoint-Received: by B4 Relay for raffaele.tranfaglia@gmail.com/20261011 with auth_id=1160 List-Id: B4 Relay Submissions regmap_write() takes an unsigned int, and what happens to the bits above val_bits currently depends on the bus and on the cache type. As agreed on the RFC, mask them in the core, before the cache is updated. Patch 1 prepares nau8360, which sets val_bits = 16 but writes 32-bit values to its DSP registers, so it would break with the masking. Patch 2 adds the masking. Patch 3 adds the KUnit tests from the RFC, which now pass. I searched for other drivers whose reg_write() handles more bits than val_bits and found no other clear case, but the search cannot be exhaustive. Implementations of reg_update_bits() do not go through _regmap_write() and are not changed. The regmap KUnit tests pass on arm64 QEMU. The nau8360 change is only compile tested. I prepared these patches with the help of an AI coding assistant, and reviewed and tested them myself. --- Changes in v3: - Simplify the val_mask computation, no regmap uses val_bits above 32 (Andy). - Rebased on the current regmap for-7.5. - Collect Reviewed-by for patch 3 (Andy). - Link to v2: https://patch.msgid.link/20261125-regmap-kunit-val-bits-v2-0-81db3b79cd3f@gmail.com Changes in v2: - No longer an RFC. - New patch masking the values in the regmap core (Andy, Mark). - New patch preparing nau8360. - Use be16_to_cpup()/le16_to_cpup() instead of casts in the tests (Andy, Mark). - Rebased on regmap for-7.5. - Link to v1: https://patch.msgid.link/20261117-regmap-kunit-val-bits-v1-1-a1cd02063217@gmail.com --- Raffaele Tranfaglia (3): ASoC: codecs: nau8360: set val_bits to the widest register size regmap: mask values to val_bits on write regmap: kunit: add tests for values wider than val_bits drivers/base/regmap/internal.h | 1 + drivers/base/regmap/regmap-kunit.c | 60 ++++++++++++++++++++++++++++++++++++++ drivers/base/regmap/regmap.c | 13 ++++++++- sound/soc/codecs/nau8360.c | 3 +- sound/soc/codecs/nau8360.h | 3 +- 5 files changed, 76 insertions(+), 4 deletions(-) --- base-commit: b65165787330d13228a0d89e211971f65607ca92 change-id: 20261117-regmap-kunit-val-bits-6473305e083b Best regards, -- Raffaele Tranfaglia