Linux driver-core infrastructure
 help / color / mirror / Atom feed
* [PATCH v2 0/3] regmap: handle values wider than val_bits consistently
@ 2026-11-25  8:09 Raffaele Tranfaglia via B4 Relay
  2026-11-25  8:09 ` [PATCH v2 1/3] ASoC: codecs: nau8360: set val_bits to the widest register size Raffaele Tranfaglia via B4 Relay
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Raffaele Tranfaglia via B4 Relay @ 2026-11-25  8:09 UTC (permalink / raw)
  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, linux-kernel,
	driver-core, linux-sound, Neo Chang, Raffaele Tranfaglia

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 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       | 14 ++++++++-
 sound/soc/codecs/nau8360.c         |  3 +-
 sound/soc/codecs/nau8360.h         |  3 +-
 5 files changed, 77 insertions(+), 4 deletions(-)
---
base-commit: 573c689219af87f6d5a4bbf809c174e7f28a23a1
change-id: 20261117-regmap-kunit-val-bits-6473305e083b

Best regards,
--  
Raffaele Tranfaglia <raffaele.tranfaglia@gmail.com>



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-11-25  8:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-25  8:09 [PATCH v2 0/3] regmap: handle values wider than val_bits consistently Raffaele Tranfaglia via B4 Relay
2026-11-25  8:09 ` [PATCH v2 1/3] ASoC: codecs: nau8360: set val_bits to the widest register size Raffaele Tranfaglia via B4 Relay
2026-11-25  8:09 ` [PATCH v2 2/3] regmap: mask values to val_bits on write Raffaele Tranfaglia via B4 Relay
2026-11-25  8:09 ` [PATCH v2 3/3] regmap: kunit: add tests for values wider than val_bits Raffaele Tranfaglia via B4 Relay

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox