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