diff options
author | Maarten ter Huurne <maarten@treewalker.org> | 2016-07-29 21:42:12 (GMT) |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2016-07-29 22:02:19 (GMT) |
commit | b2c7f5d9c939a37c1ce7f86a642de70e3033ee9e (patch) | |
tree | d7b4086676e639a016c888de22043c6001af4ca3 /drivers/base/regmap | |
parent | efeb1a3ab91dc6bead3b5a522c0ceca1d711feb1 (diff) | |
download | linux-b2c7f5d9c939a37c1ce7f86a642de70e3033ee9e.tar.xz |
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>
Diffstat (limited to 'drivers/base/regmap')
-rw-r--r-- | drivers/base/regmap/regcache.c | 5 |
1 files 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; |