aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/regmap/internal.h
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2013-03-29 15:18:59 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2013-03-30 09:49:17 -0400
commit78493f2d7b51d6f6d03982cee559c62dfab4c292 (patch)
tree7b7360e51d4e245a0fa2ac611eecc252ea5030fc /drivers/base/regmap/internal.h
parent137b833457864091610ca01d7443a67028a2b3ce (diff)
regmap: cache: Factor out reg_present support from rbtree cache
The idea of maintaining a bitmap of present registers is something that can usefully be used by other cache types that maintain blocks of cached registers so move the code out of the rbtree cache and into the generic regcache code. Refactor the interface slightly as we go to wrap the set bit and enlarge bitmap operations (since we never do one without the other) and make it more robust for reads of uncached registers by bounds checking before we look at the bitmap. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Reviewed-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/base/regmap/internal.h')
-rw-r--r--drivers/base/regmap/internal.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/drivers/base/regmap/internal.h b/drivers/base/regmap/internal.h
index 95d46a5ea7e7..b01fe59fbfe8 100644
--- a/drivers/base/regmap/internal.h
+++ b/drivers/base/regmap/internal.h
@@ -126,6 +126,9 @@ struct regmap {
126 void *cache; 126 void *cache;
127 u32 cache_dirty; 127 u32 cache_dirty;
128 128
129 unsigned long *cache_present;
130 unsigned int cache_present_nbits;
131
129 struct reg_default *patch; 132 struct reg_default *patch;
130 int patch_regs; 133 int patch_regs;
131 134
@@ -201,6 +204,16 @@ unsigned int regcache_get_val(struct regmap *map, const void *base,
201bool regcache_set_val(struct regmap *map, void *base, unsigned int idx, 204bool regcache_set_val(struct regmap *map, void *base, unsigned int idx,
202 unsigned int val); 205 unsigned int val);
203int regcache_lookup_reg(struct regmap *map, unsigned int reg); 206int regcache_lookup_reg(struct regmap *map, unsigned int reg);
207int regcache_set_reg_present(struct regmap *map, unsigned int reg);
208
209static inline bool regcache_reg_present(struct regmap *map, unsigned int reg)
210{
211 if (!map->cache_present)
212 return true;
213 if (reg > map->cache_present_nbits)
214 return false;
215 return map->cache_present[BIT_WORD(reg)] & BIT_MASK(reg);
216}
204 217
205int _regmap_raw_write(struct regmap *map, unsigned int reg, 218int _regmap_raw_write(struct regmap *map, unsigned int reg,
206 const void *val, size_t val_len, bool async); 219 const void *val, size_t val_len, bool async);