From: "Peng Fan (OSS)" <peng.fan@oss.nxp.com>
To: Mark Brown <broonie@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Danilo Krummrich <dakr@kernel.org>,
Johan Hovold <johan@kernel.org>,
Lucas Tanure <tanureal@opensource.cirrus.com>
Cc: linux-kernel@vger.kernel.org, driver-core@lists.linux.dev,
Peng Fan <peng.fan@nxp.com>
Subject: [PATCH 0/9] regmap: clean up and improve __regmap_init()
Date: Tue, 10 Nov 2026 16:25:24 +0800 [thread overview]
Message-ID: <20261110-regmap-improve-v1-0-3a76b6c10ec6@nxp.com> (raw)
This patchset improves the __regmap_init() error handling and removes the
regmap_bus::free_on_exit. Patches 1-2 fix I2C adapter quirk handling;
patches 3-8 are cleanups with no functional change; patch 9 adds KUnit
coverage for the new bus callback.
Patch 1 fixes regmap_get_i2c_bus() so that applying an adapter read quirk
no longer drops the raw write limit advertised by the selected bus (and
vice versa). It currently starts from zero-initialised locals and
overwrites both limits of the bus copy.
Patch 2 avoids an underflow when the adapter's max_write_len quirk is not
larger than the register address size. In that case the maximum raw
payload size cannot be represented and no raw write can succeed, so the
existing limit is kept instead of being replaced with a bogus value.
Patches 3-6 are mechanical: evaluate fast_io once, and factor out
regmap_set_lock(), regmap_init_ranges() and the format selection into
helpers. The forward goto and the label-based unwinding are reduced to a
single error path.
Patch 7 drops regmap_bus::free_on_exit. Instead of kmemdup()ing the
static I2C/SPI bus to store per-device raw I/O limits, add an optional
regmap_bus::init_limits() callback. __regmap_init() invokes it before
regcache_init(), which is required because regcache_hw_init() may read
raw register defaults from the device during initialization and must
already see the effective max_raw_read limit. The static bus structures
can then be used directly and the per-device allocations disappear.
Patch 8 converts the error unwinding to the cleanup API and drops all
err_* labels. map->cache_type is now assigned just before
regcache_init() and reset to REGCACHE_NONE on failure, so the release
helper can safely call regcache_exit() on a partially initialised map.
Patch 9 adds a KUnit test which verifies that init_limits() is invoked
before regcache_init() by checking that the raw default readback is split
according to the limit installed by the callback.
Testing:
- Built drivers/base/regmap/ with W=1 on x86_64.
- regmap KUnit suite: tests pass under UML.
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
Peng Fan (9):
regmap-i2c: keep bus raw write limit when applying read quirk
regmap-i2c: avoid underflow when applying write length quirk
regmap: deduplicate fast_io checks
regmap: factor out regmap_set_lock()
regmap: factor out regmap_init_ranges()
regmap: factor out format initialisation into helpers
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 | 62 ++--
drivers/base/regmap/regmap-kunit.c | 89 +++++
drivers/base/regmap/regmap-spi.c | 64 ++--
drivers/base/regmap/regmap.c | 700 +++++++++++++++++++------------------
include/linux/regmap.h | 7 +-
5 files changed, 520 insertions(+), 402 deletions(-)
---
base-commit: f652a40d7240c9df35755316569afd12d7a85c57
change-id: 20261109-regmap-improve-915eee5a80ec
Best regards,
--
Peng Fan <peng.fan@nxp.com>
next reply other threads:[~2026-11-10 8:29 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-10 8:25 Peng Fan (OSS) [this message]
2026-11-10 8:25 ` [PATCH 1/9] regmap-i2c: keep bus raw write limit when applying read quirk Peng Fan (OSS)
2026-11-10 8:25 ` [PATCH 2/9] regmap-i2c: avoid underflow when applying write length quirk Peng Fan (OSS)
2026-11-10 8:25 ` [PATCH 3/9] regmap: deduplicate fast_io checks Peng Fan (OSS)
2026-11-10 8:25 ` [PATCH 4/9] regmap: factor out regmap_set_lock() Peng Fan (OSS)
2026-11-10 8:25 ` [PATCH 5/9] regmap: factor out regmap_init_ranges() Peng Fan (OSS)
2026-11-10 8:25 ` [PATCH 6/9] regmap: factor out format initialisation into helpers Peng Fan (OSS)
2026-11-10 8:25 ` [PATCH 7/9] regmap: drop regmap_bus::free_on_exit Peng Fan (OSS)
2026-11-10 8:25 ` [PATCH 8/9] regmap: use cleanup API in __regmap_init() Peng Fan (OSS)
2026-11-10 8:25 ` [PATCH 9/9] regmap: kunit: add test for regmap_bus::init_limits Peng Fan (OSS)
2026-11-10 11:47 ` [PATCH 0/9] regmap: clean up and improve __regmap_init() Peng Fan
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=20261110-regmap-improve-v1-0-3a76b6c10ec6@nxp.com \
--to=peng.fan@oss.nxp.com \
--cc=broonie@kernel.org \
--cc=dakr@kernel.org \
--cc=driver-core@lists.linux.dev \
--cc=gregkh@linuxfoundation.org \
--cc=johan@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peng.fan@nxp.com \
--cc=rafael@kernel.org \
--cc=tanureal@opensource.cirrus.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
all inboxes | Powered by JetHome®