All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bartosz Golaszewski <brgl@bgdev.pl>
To: Mark Brown <broonie@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-kernel@vger.kernel.org,
	Lars-Peter Clausen <lars@metafoo.de>,
	Andy Shevchenko <andy.shevchenko@gmail.com>,
	Bartosz Golaszewski <brgl@bgdev.pl>
Subject: [PATCH 2/3] regmap: don't create the debugfs entries if locking is disabled
Date: Wed, 13 Dec 2017 10:28:11 +0100	[thread overview]
Message-ID: <20171213092812.26472-3-brgl@bgdev.pl> (raw)
In-Reply-To: <20171213092812.26472-1-brgl@bgdev.pl>

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

  parent reply	other threads:[~2017-12-13  9:28 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-13  9:28 [PATCH 0/3] regmap: follow-up for ("regmap: allow to disable all locking mechanisms") Bartosz Golaszewski
2017-12-13  9:28 ` [PATCH 1/3] regmap: rename regmap_lock_unlock_empty() to regmap_lock_unlock_none() Bartosz Golaszewski
2017-12-13  9:28 ` Bartosz Golaszewski [this message]
2017-12-13 14:54   ` [PATCH 2/3] regmap: don't create the debugfs entries if locking is disabled Andy Shevchenko
2017-12-13 14:59     ` Bartosz Golaszewski
2017-12-13 15:39   ` Mark Brown
2017-12-13 15:46     ` Bartosz Golaszewski
2017-12-13 16:00       ` Mark Brown
2017-12-13  9:28 ` [PATCH 3/3] regmap: duplicate the name string stored in regmap Bartosz Golaszewski
2017-12-13  9:32   ` Lars-Peter Clausen
2017-12-13  9:56     ` Bartosz Golaszewski

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=20171213092812.26472-3-brgl@bgdev.pl \
    --to=brgl@bgdev.pl \
    --cc=andy.shevchenko@gmail.com \
    --cc=broonie@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=lars@metafoo.de \
    --cc=linux-kernel@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.