diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2013-03-29 23:18:59 +0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2013-03-30 17:49:17 +0400 |
commit | 78493f2d7b51d6f6d03982cee559c62dfab4c292 (patch) | |
tree | 7b7360e51d4e245a0fa2ac611eecc252ea5030fc /drivers/base/regmap/internal.h | |
parent | 137b833457864091610ca01d7443a67028a2b3ce (diff) | |
download | linux-78493f2d7b51d6f6d03982cee559c62dfab4c292.tar.xz |
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.h | 13 |
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 { void *cache; u32 cache_dirty; + unsigned long *cache_present; + unsigned int cache_present_nbits; + struct reg_default *patch; int patch_regs; @@ -201,6 +204,16 @@ unsigned int regcache_get_val(struct regmap *map, const void *base, bool regcache_set_val(struct regmap *map, void *base, unsigned int idx, unsigned int val); int regcache_lookup_reg(struct regmap *map, unsigned int reg); +int regcache_set_reg_present(struct regmap *map, unsigned int reg); + +static inline bool regcache_reg_present(struct regmap *map, unsigned int reg) +{ + if (!map->cache_present) + return true; + if (reg > map->cache_present_nbits) + return false; + return map->cache_present[BIT_WORD(reg)] & BIT_MASK(reg); +} int _regmap_raw_write(struct regmap *map, unsigned int reg, const void *val, size_t val_len, bool async); |