linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] regmap: cache: Fix num_reg_defaults computation from reg_defaults_raw
@ 2016-07-29 14:46 Maarten ter Huurne
  2016-07-29 16:42 ` Mark Brown
  2016-07-29 21:42 ` [PATCH v2] " Maarten ter Huurne
  0 siblings, 2 replies; 4+ messages in thread
From: Maarten ter Huurne @ 2016-07-29 14:46 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-kernel, Maarten ter Huurne

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..56e2375 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

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

* Re: [PATCH] regmap: cache: Fix num_reg_defaults computation from reg_defaults_raw
  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 ` [PATCH v2] " Maarten ter Huurne
  1 sibling, 0 replies; 4+ messages in thread
From: Mark Brown @ 2016-07-29 16:42 UTC (permalink / raw)
  To: Maarten ter Huurne; +Cc: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 469 bytes --]

On Fri, Jul 29, 2016 at 04:46:43PM +0200, Maarten ter Huurne wrote:

>  	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))

This seems fine but please use a normal coding style, there's a *huge*
amount of indentation on the second line for some reason.  It should
align with the ( in the if statement.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

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

* [PATCH v2] regmap: cache: Fix num_reg_defaults computation from reg_defaults_raw
  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
  2016-07-29 22:17   ` Applied "regmap: cache: Fix num_reg_defaults computation from reg_defaults_raw" to the regmap tree Mark Brown
  1 sibling, 1 reply; 4+ messages in thread
From: Maarten ter Huurne @ 2016-07-29 21:42 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-kernel, Maarten ter Huurne

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

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

* Applied "regmap: cache: Fix num_reg_defaults computation from reg_defaults_raw" to the regmap tree
  2016-07-29 21:42 ` [PATCH v2] " Maarten ter Huurne
@ 2016-07-29 22:17   ` Mark Brown
  0 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2016-07-29 22:17 UTC (permalink / raw)
  To: Maarten ter Huurne; +Cc: Mark Brown, Mark Brown, linux-kernel

The patch

   regmap: cache: Fix num_reg_defaults computation from reg_defaults_raw

has been applied to the regmap tree at

   git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From b2c7f5d9c939a37c1ce7f86a642de70e3033ee9e Mon Sep 17 00:00:00 2001
From: Maarten ter Huurne <maarten@treewalker.org>
Date: Fri, 29 Jul 2016 23:42:12 +0200
Subject: [PATCH] regmap: cache: Fix num_reg_defaults computation from
 reg_defaults_raw

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>
Signed-off-by: Mark Brown <broonie@kernel.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 df7ff7290821..4e582561e1e7 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.8.1

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

end of thread, other threads:[~2016-07-29 22:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH v2] " Maarten ter Huurne
2016-07-29 22:17   ` Applied "regmap: cache: Fix num_reg_defaults computation from reg_defaults_raw" to the regmap tree Mark Brown

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).