From: David Jander <david@protonic.nl>
To: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Cc: Mark Brown <broonie@kernel.org>,
linux-kernel@vger.kernel.org, David Jander <david@protonic.nl>
Subject: [PATCH] drivers: regmap: bugfix in regcache-rbtree.c
Date: Wed, 21 Aug 2013 15:02:35 +0200 [thread overview]
Message-ID: <1377090155-3443-1-git-send-email-david@protonic.nl> (raw)
The functionality of rbtree_ctx->cached_rbnode is broken. Remove it to
avoid hitting the wrong rbnode when locating a register.
rbnode register ranges can overlap, which is not a problem as long as
every lookup for a register returns the same rbnode. Therefor we need
to start searching from the top of the rb-tree _always_.
Signed-off-by: David Jander <david@protonic.nl>
---
drivers/base/regmap/regcache-rbtree.c | 13 -------------
1 file changed, 13 deletions(-)
diff --git a/drivers/base/regmap/regcache-rbtree.c b/drivers/base/regmap/regcache-rbtree.c
index 5c1435c..2f9783f 100644
--- a/drivers/base/regmap/regcache-rbtree.c
+++ b/drivers/base/regmap/regcache-rbtree.c
@@ -35,7 +35,6 @@ struct regcache_rbtree_node {
struct regcache_rbtree_ctx {
struct rb_root root;
- struct regcache_rbtree_node *cached_rbnode;
};
static inline void regcache_rbtree_get_base_top_reg(
@@ -68,21 +67,12 @@ static struct regcache_rbtree_node *regcache_rbtree_lookup(struct regmap *map,
struct regcache_rbtree_node *rbnode;
unsigned int base_reg, top_reg;
- rbnode = rbtree_ctx->cached_rbnode;
- if (rbnode) {
- regcache_rbtree_get_base_top_reg(map, rbnode, &base_reg,
- &top_reg);
- if (reg >= base_reg && reg <= top_reg)
- return rbnode;
- }
-
node = rbtree_ctx->root.rb_node;
while (node) {
rbnode = container_of(node, struct regcache_rbtree_node, node);
regcache_rbtree_get_base_top_reg(map, rbnode, &base_reg,
&top_reg);
if (reg >= base_reg && reg <= top_reg) {
- rbtree_ctx->cached_rbnode = rbnode;
return rbnode;
} else if (reg > top_reg) {
node = node->rb_right;
@@ -209,7 +199,6 @@ static int regcache_rbtree_init(struct regmap *map)
rbtree_ctx = map->cache;
rbtree_ctx->root = RB_ROOT;
- rbtree_ctx->cached_rbnode = NULL;
for (i = 0; i < map->num_reg_defaults; i++) {
ret = regcache_rbtree_write(map,
@@ -392,7 +381,6 @@ static int regcache_rbtree_write(struct regmap *map, unsigned int reg,
value);
if (ret)
return ret;
- rbtree_ctx->cached_rbnode = rbnode_tmp;
return 0;
}
}
@@ -406,7 +394,6 @@ static int regcache_rbtree_write(struct regmap *map, unsigned int reg,
regcache_rbtree_set_register(map, rbnode,
reg - rbnode->base_reg, value);
regcache_rbtree_insert(map, &rbtree_ctx->root, rbnode);
- rbtree_ctx->cached_rbnode = rbnode;
}
return 0;
--
1.8.1.2
next reply other threads:[~2013-08-21 13:24 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-21 13:02 David Jander [this message]
2013-08-21 13:14 ` David Jander
2013-08-21 14:08 ` Mark Brown
2013-08-21 14:24 ` David Jander
2013-08-21 14:41 ` David Jander
2013-08-21 13:32 ` Mark Brown
2013-08-21 14:21 ` David Jander
2013-08-21 14:44 ` Mark Brown
2013-08-21 15:08 ` David Jander
2013-08-21 15:28 ` Mark Brown
2013-08-21 17:03 ` Dimitris Papastamos
2013-08-22 10:04 ` Mark Brown
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=1377090155-3443-1-git-send-email-david@protonic.nl \
--to=david@protonic.nl \
--cc=broonie@kernel.org \
--cc=dp@opensource.wolfsonmicro.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®