mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/3] regmap: 2nd clean up and improve __regmap_init()
@ 2026-11-21 12:44 Peng Fan
  2026-11-21 12:44 ` [PATCH 1/3] regmap: drop regmap_bus::free_on_exit Peng Fan
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Peng Fan @ 2026-11-21 12:44 UTC (permalink / raw)
  To: Mark Brown, Greg Kroah-Hartman, Rafael J. Wysocki,
	Danilo Krummrich, Johan Hovold
  Cc: linux-kernel, driver-core, Peng Fan

This is a re-post of patch 8-10 from [1] with addressing Mark's comments
to patch 8 [2]

[1] https://lore.kernel.org/all/20261113-regmap-improve-v2-0-5dfd6a89078f@nxp.com/
[2] https://lore.kernel.org/all/179510759875.116416.1025341724543668395.b4-review@b4/

This series removes the per-device regmap_bus copies used by the I2C and
SPI helpers to override max_raw_read and max_raw_write, converts the
__regmap_init() error unwinding to the scope-based cleanup API, and adds
KUnit coverage for the new init_limits callback.

The first patch replaces regmap_bus::free_on_exit with an optional
init_limits() callback. It is invoked after the bus raw I/O limits have
been copied and before the cache is initialized. The ordering matters
for maps with raw register defaults: regcache_hw_init() reads them back
from the device during initialization and chunks that transfer using
max_raw_read. Following review feedback, the callback takes the bus
context, the config and pointers to the limits instead of struct regmap,
which is private to drivers/base/regmap, so bus implementations outside
the regmap core can use it.

The second patch converts the __regmap_init() error unwinding to the
cleanup API. A dedicated release helper unwinds a partially initialized
map in the same order as the old labels. map->cache_type is now assigned
just before regcache_init() and reset if it fails, which makes
regcache_exit() safe to call from the cleanup path at any point.

The third patch adds a KUnit test that lowers the raw I/O limits from the
init_limits callback and relies on raw register defaults. The test
verifies that the cache readback is split according to the limits and
that the callback runs before regcache_init().

No functional changes.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
Peng Fan (3):
      regmap: drop regmap_bus::free_on_exit
      regmap: use cleanup API in __regmap_init()
      regmap: kunit: add test for regmap_bus::init_limits

 drivers/base/regmap/regmap-i2c.c   | 85 ++++++++++++++++++-----------------
 drivers/base/regmap/regmap-kunit.c | 91 ++++++++++++++++++++++++++++++++++++++
 drivers/base/regmap/regmap-spi.c   | 66 +++++++++++----------------
 drivers/base/regmap/regmap.c       | 77 ++++++++++++++++----------------
 include/linux/regmap.h             | 10 ++++-
 5 files changed, 207 insertions(+), 122 deletions(-)
---
base-commit: 909ef7a9a30fa139e69e555e3606680f5cca7726
change-id: 20261121-regmap-improve-2nd-376762e4d823

Best regards,
-- 
Peng Fan <peng.fan@nxp.com>


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

end of thread, other threads:[~2026-11-21 12:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-21 12:44 [PATCH 0/3] regmap: 2nd clean up and improve __regmap_init() Peng Fan
2026-11-21 12:44 ` [PATCH 1/3] regmap: drop regmap_bus::free_on_exit Peng Fan
2026-11-21 12:44 ` [PATCH 2/3] regmap: use cleanup API in __regmap_init() Peng Fan
2026-11-21 12:44 ` [PATCH 3/3] regmap: kunit: add test for regmap_bus::init_limits Peng Fan

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

all inboxes | Powered by JetHome®