lkml.org 
[lkml]   [2017]   [Dec]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 2/3] regmap: don't create the debugfs entries if locking is disabled
Date
User space can initiate concurrent access to regmap over debugfs and,
if the locking is disabled, we can't protect it. Don't create the
debugfs entries at all in this case.

Suggested-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
---
drivers/base/regmap/internal.h | 2 ++
drivers/base/regmap/regmap-debugfs.c | 5 +++++
drivers/base/regmap/regmap.c | 1 +
3 files changed, 8 insertions(+)

diff --git a/drivers/base/regmap/internal.h b/drivers/base/regmap/internal.h
index 8641183cac2f..e40a8e499d35 100644
--- a/drivers/base/regmap/internal.h
+++ b/drivers/base/regmap/internal.h
@@ -60,6 +60,8 @@ struct regmap {
regmap_lock lock;
regmap_unlock unlock;
void *lock_arg; /* This is passed to lock/unlock functions */
+ bool locking_disabled;
+
gfp_t alloc_flags;

struct device *dev; /* Device we do I/O on */
diff --git a/drivers/base/regmap/regmap-debugfs.c b/drivers/base/regmap/regmap-debugfs.c
index 36ce3511c733..5a45b95ec00a 100644
--- a/drivers/base/regmap/regmap-debugfs.c
+++ b/drivers/base/regmap/regmap-debugfs.c
@@ -529,6 +529,11 @@ void regmap_debugfs_init(struct regmap *map, const char *name)
struct regmap_range_node *range_node;
const char *devname = "dummy";

+ if (map->locking_disabled) {
+ dev_dbg(map->dev, "locking disabled - not creating debugfs entries\n");
+ return;
+ }
+
/* If we don't have the debugfs root yet, postpone init */
if (!regmap_debugfs_root) {
struct regmap_debugfs_node *node;
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index 16a66ba84aef..a2a02ce58824 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -673,6 +673,7 @@ struct regmap *__regmap_init(struct device *dev,
}

if (config->disable_locking) {
+ map->locking_disabled = true;
map->lock = map->unlock = regmap_lock_unlock_none;
} else if (config->lock && config->unlock) {
map->lock = config->lock;
--
2.15.1
\
 
 \ /
  Last update: 2017-12-13 10:29    [W:0.064 / U:1.628 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site