From: Ionut Nicu <ioan.nicu.ext@nsn.com>
To: Mark Brown <broonie@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-kernel@vger.kernel.org
Subject: [PATCH 1/3] regmap: flat: use the cache_present bitmap
Date: Fri, 09 Aug 2013 12:09:11 +0200 [thread overview]
Message-ID: <5204BFC7.4090106@nsn.com> (raw)
As opposed to the other regmap cache implementations,
regcache_flat didn't use the cache_present bitmap for
figuring out whether a register was cached or not, nor
did it mark a register as present in the cache when
regcache_flat_write() was called.
This caused incorrect behaviour, such as returning
value 0 for non-volatile registers without first reading
their value from the device and storing it in the cache.
Signed-off-by: Ionut Nicu <ioan.nicu.ext@nsn.com>
---
drivers/base/regmap/regcache-flat.c | 25 ++++++++++++++++++++++---
1 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/drivers/base/regmap/regcache-flat.c b/drivers/base/regmap/regcache-flat.c
index d9762e4..f47278e 100644
--- a/drivers/base/regmap/regcache-flat.c
+++ b/drivers/base/regmap/regcache-flat.c
@@ -16,9 +16,13 @@
#include "internal.h"
+static int regcache_flat_write(struct regmap *map, unsigned int reg,
+ unsigned int value);
+static int regcache_flat_exit(struct regmap *map);
+
static int regcache_flat_init(struct regmap *map)
{
- int i;
+ int i, ret;
unsigned int *cache;
map->cache = kzalloc(sizeof(unsigned int) * (map->max_register + 1),
@@ -28,8 +32,15 @@ static int regcache_flat_init(struct regmap *map)
cache = map->cache;
- for (i = 0; i < map->num_reg_defaults; i++)
- cache[map->reg_defaults[i].reg] = map->reg_defaults[i].def;
+ for (i = 0; i < map->num_reg_defaults; i++) {
+ ret = regcache_flat_write(map,
+ map->reg_defaults[i].reg,
+ map->reg_defaults[i].def);
+ if (ret) {
+ regcache_flat_exit(map);
+ return ret;
+ }
+ }
return 0;
}
@@ -47,6 +58,9 @@ static int regcache_flat_read(struct regmap *map,
{
unsigned int *cache = map->cache;
+ if (!regcache_reg_present(map, reg))
+ return -ENOENT;
+
*value = cache[reg];
return 0;
@@ -56,6 +70,11 @@ static int regcache_flat_write(struct regmap *map, unsigned int reg,
unsigned int value)
{
unsigned int *cache = map->cache;
+ int ret;
+
+ ret = regcache_set_reg_present(map, reg);
+ if (ret < 0)
+ return ret;
cache[reg] = value;
--
1.7.1
next reply other threads:[~2013-08-09 10:09 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-09 10:09 Ionut Nicu [this message]
2013-08-09 11:44 ` [PATCH 1/3] regmap: flat: use the cache_present bitmap Mark Brown
2013-08-09 17:16 ` Ionut Nicu
2013-08-13 7:17 ` Ionut Nicu
2013-08-13 11:06 ` Mark Brown
[not found] ` <5211D68C.1070608@nsn.com>
2013-08-19 11:18 ` Fwd: " Alexander Sverdlin
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=5204BFC7.4090106@nsn.com \
--to=ioan.nicu.ext@nsn.com \
--cc=broonie@kernel.org \
--cc=gregkh@linuxfoundation.org \
--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.