linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] regmap: Use mas_walk() instead of mas_find()
@ 2023-04-04 19:42 Mark Brown
  2023-04-05 12:25 ` Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Mark Brown @ 2023-04-04 19:42 UTC (permalink / raw)
  To: Liam.Howlett; +Cc: linux-mm, linux-kernel, Mark Brown

Liam recommends using mas_walk() instead of mas_find() for our use case so
let's do that, it avoids some minor overhead associated with being able to
restart the operation which we don't need since we do a simple search.

Suggested-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
Changes in v2:
- Don't set index and last again needlessly.
- Link to v1: https://lore.kernel.org/r/20230403-regmap-maple-walk-fine-v1-1-09512dd51e50@kernel.org
---
 drivers/base/regmap/regcache-maple.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/base/regmap/regcache-maple.c b/drivers/base/regmap/regcache-maple.c
index 497cc708d277..e48f5b0c96cb 100644
--- a/drivers/base/regmap/regcache-maple.c
+++ b/drivers/base/regmap/regcache-maple.c
@@ -22,7 +22,7 @@ static int regcache_maple_read(struct regmap *map,
 
 	rcu_read_lock();
 
-	entry = mas_find(&mas, reg);
+	entry = mas_walk(&mas);
 	if (!entry) {
 		rcu_read_unlock();
 		return -ENOENT;
@@ -47,7 +47,7 @@ static int regcache_maple_write(struct regmap *map, unsigned int reg,
 
 	rcu_read_lock();
 
-	entry = mas_find(&mas, reg);
+	entry = mas_walk(&mas);
 	if (entry) {
 		entry[reg - mas.index] = val;
 		rcu_read_unlock();

---
base-commit: f033c26de5a5734625d2dd1dc196745fae186f1b
change-id: 20230403-regmap-maple-walk-fine-982bbd2dcfe5

Best regards,
-- 
Mark Brown <broonie@kernel.org>



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-04-05 12:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-04 19:42 [PATCH v2] regmap: Use mas_walk() instead of mas_find() Mark Brown
2023-04-05 12:25 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox