linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Maarten ter Huurne <maarten@treewalker.org>
To: Mark Brown <broonie@kernel.org>
Cc: linux-kernel@vger.kernel.org,
	Maarten ter Huurne <maarten@treewalker.org>
Subject: [PATCH v2] regmap: cache: Fix num_reg_defaults computation from reg_defaults_raw
Date: Fri, 29 Jul 2016 23:42:12 +0200	[thread overview]
Message-ID: <1469828532-21653-1-git-send-email-maarten@treewalker.org> (raw)
In-Reply-To: <1469803603-15862-1-git-send-email-maarten@treewalker.org>

In 3245d460 (regmap: cache: Fall back to register by register read for
cache defaults) non-readable registers are skipped when initializing
reg_defaults, but are still included in num_reg_defaults. So there can
be uninitialized entries at the end of reg_defaults, which can cause
problems when the register cache initializes from the full array.

Fixed it by excluding non-readable registers from the count as well.

Signed-off-by: Maarten ter Huurne <maarten@treewalker.org>
---
 drivers/base/regmap/regcache.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/base/regmap/regcache.c b/drivers/base/regmap/regcache.c
index df7ff729..4e58256 100644
--- a/drivers/base/regmap/regcache.c
+++ b/drivers/base/regmap/regcache.c
@@ -38,10 +38,11 @@ static int regcache_hw_init(struct regmap *map)
 
 	/* calculate the size of reg_defaults */
 	for (count = 0, i = 0; i < map->num_reg_defaults_raw; i++)
-		if (!regmap_volatile(map, i * map->reg_stride))
+		if (regmap_readable(map, i * map->reg_stride) &&
+		    !regmap_volatile(map, i * map->reg_stride))
 			count++;
 
-	/* all registers are volatile, so just bypass */
+	/* all registers are unreadable or volatile, so just bypass */
 	if (!count) {
 		map->cache_bypass = true;
 		return 0;
-- 
2.6.6

  parent reply	other threads:[~2016-07-29 21:42 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-29 14:46 [PATCH] regmap: cache: Fix num_reg_defaults computation from reg_defaults_raw Maarten ter Huurne
2016-07-29 16:42 ` Mark Brown
2016-07-29 21:42 ` Maarten ter Huurne [this message]
2016-07-29 22:17   ` Applied "regmap: cache: Fix num_reg_defaults computation from reg_defaults_raw" to the regmap tree 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=1469828532-21653-1-git-send-email-maarten@treewalker.org \
    --to=maarten@treewalker.org \
    --cc=broonie@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).