(I'm so sorry!) Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git

regmap: convert lock/unlock to a scoped guard

The regmap lock and unlock callbacks are invoked directly as map->lock(map->lock_arg) / map->unlock(map->lock_arg) at every call site. This open-coded pattern requires manual unlocking on every return path, which spreads goto out_unlock chains and duplicated unlock statements throughout the code and is an easy place to leak the lock on an error path. Define a scoped guard for the regmap lock in internal.h. The lock and unlock callbacks are chosen at init time (mutex, spinlock, raw spinlock, hwspinlock or none) and return void, so an unconditional DEFINE_GUARD() is sufficient. Convert all lock/unlock users in regmap.c to guard(regmap)() for function-scope critical sections and scoped_guard(regmap, ...) where work must run outside the lock (e.g. regmap_register_patch() calling regmap_async_complete()). This drops every manual unlock and the associated goto out_unlock labels with no functional change. Assisted-by: LLM Signed-off-by: Peng Fan <peng.fan@nxp.com> Link: https://patch.msgid.link/20260924-regmap-lock-guard-v3-1-8a6127223c16@nxp.com Signed-off-by: Mark Brown <broonie@kernel.org>


Author Peng Fan Committer Mark Brown Date Commit Parent 93f51579
+70 -123
2 changed files
+70 -123
2 changed files