mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mark Brown <broonie@opensource.wolfsonmicro.com>
To: linux-kernel@vger.kernel.org
Cc: Mark Brown <broonie@opensource.wolfsonmicro.com>
Subject: [PATCH] regmap: cache: Provide a get address of value operation
Date: Wed, 13 Mar 2013 19:31:42 +0000	[thread overview]
Message-ID: <1363203102-20810-1-git-send-email-broonie@opensource.wolfsonmicro.com> (raw)

Provide a helper to do the size based index into a block of registers and
use it when reading a value.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
 drivers/base/regmap/internal.h |    6 ++++++
 drivers/base/regmap/regcache.c |    4 ++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/base/regmap/internal.h b/drivers/base/regmap/internal.h
index 9fc351f0..54b2fd9 100644
--- a/drivers/base/regmap/internal.h
+++ b/drivers/base/regmap/internal.h
@@ -190,6 +190,12 @@ int regcache_write(struct regmap *map,
 			unsigned int reg, unsigned int value);
 int regcache_sync(struct regmap *map);
 
+static inline void *regcache_get_val_addr(struct regmap *map, const void *base,
+				   unsigned int idx)
+{
+	return base + (map->cache_word_size * idx);
+}
+
 unsigned int regcache_get_val(struct regmap *map, const void *base,
 			      unsigned int idx);
 bool regcache_set_val(struct regmap *map, void *base, unsigned int idx,
diff --git a/drivers/base/regmap/regcache.c b/drivers/base/regmap/regcache.c
index 0f4fb8b..229c804 100644
--- a/drivers/base/regmap/regcache.c
+++ b/drivers/base/regmap/regcache.c
@@ -458,8 +458,8 @@ unsigned int regcache_get_val(struct regmap *map, const void *base,
 
 	/* Use device native format if possible */
 	if (map->format.parse_val)
-		return map->format.parse_val(base +
-					     (map->cache_word_size * idx));
+		return map->format.parse_val(regcache_get_val_addr(map, base,
+								   idx));
 
 	switch (map->cache_word_size) {
 	case 1: {
-- 
1.7.10.4


                 reply	other threads:[~2013-03-13 19:31 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1363203102-20810-1-git-send-email-broonie@opensource.wolfsonmicro.com \
    --to=broonie@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®