[PATCH 2/4] regmap: Allow disabling debugfs via regmap_config

Richard Weinberger posted 4 patches 2 days, 8 hours ago
[PATCH 2/4] regmap: Allow disabling debugfs via regmap_config
Posted by Richard Weinberger 2 days, 8 hours ago
Regmap already disables register access via debugfs as soon as a register
map is used without taking locks.
Go a step further and allow disabling debugfs via regmap_config such that
device drivers can decide on their own whether uncontrolled register access
via debugfs is harmful.

Signed-off-by: Richard Weinberger <richard@nod.at>
---
 drivers/base/regmap/regmap.c | 2 ++
 include/linux/regmap.h       | 3 +++
 2 files changed, 5 insertions(+)

diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index ce9be3989a218..38d7a03aa7637 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -697,6 +697,8 @@ struct regmap *__regmap_init(struct device *dev,
 	if (ret)
 		goto err_map;
 
+	map->debugfs_disable = config->debugfs_disable;
+
 	ret = -EINVAL; /* Later error paths rely on this */
 
 	if (config->disable_locking) {
diff --git a/include/linux/regmap.h b/include/linux/regmap.h
index 55343795644b9..646501a055eba 100644
--- a/include/linux/regmap.h
+++ b/include/linux/regmap.h
@@ -395,6 +395,7 @@ typedef void (*regmap_unlock)(void *);
  *
  * @ranges: Array of configuration entries for virtual address ranges.
  * @num_ranges: Number of range configuration entries.
+ * @debugfs_disable: Disable debugfs access to this register.
  */
 struct regmap_config {
 	const char *name;
@@ -467,6 +468,8 @@ struct regmap_config {
 
 	const struct regmap_range_cfg *ranges;
 	unsigned int num_ranges;
+
+	bool debugfs_disable;
 };
 
 /**
-- 
2.51.0
Re: [PATCH 2/4] regmap: Allow disabling debugfs via regmap_config
Posted by Mark Brown 10 hours ago
On Sat, Nov 29, 2025 at 03:20:40PM +0100, Richard Weinberger wrote:
> Regmap already disables register access via debugfs as soon as a register
> map is used without taking locks.
> Go a step further and allow disabling debugfs via regmap_config such that
> device drivers can decide on their own whether uncontrolled register access
> via debugfs is harmful.

What's the use case for this?  Drivers can already mark registers as
unreadable and precious to stop spurious reads.