regmap: rbtree: Don't bother checking for noop updates
Subsystems (2)
PATCH 1/3 regmap: rbtree: Don't bother checking for noop updates
If we're updating a value in place it's more work to read the value and compare the value with what we're about to set than it is to just write the value into the cache; there are no further operations after writing in the code even though there's an early return here.
Signed-off-by Mark Brown <[email protected]>
--- drivers/base/regmap/regcache-rbtree.c | 5 ----- 1 file changed, 5 deletions(-)
drivers/base/regmap/regcache-rbtree.c +0 -5
@@ -302,7 +302,6 @@ static int regcache_rbtree_write(struct regmap *map, unsigned int reg,struct regcache_rbtree_ctx *rbtree_ctx;struct regcache_rbtree_node *rbnode, *rbnode_tmp;struct rb_node *node; -unsigned int val;unsigned int reg_tmp;unsigned int pos;int i;
@@ -315,10 +314,6 @@ static int regcache_rbtree_write(struct regmap *map, unsigned int reg, rbnode =regcache_rbtree_lookup (map, reg);if (rbnode) { reg_tmp = (reg - rbnode->base_reg) / map->reg_stride; - val =regcache_rbtree_get_register (rbnode, reg_tmp, - map->cache_word_size); -if (val == value) -return 0 ;regcache_rbtree_set_register (rbnode, reg_tmp, value, map->cache_word_size); }else {
Signature · 1 line
1.7.10.4
PATCH 2/3 regmap: cache: Pass the map rather than the word size when updating values
It's more idiomatic to pass the map structure around and this means we can use other bits of information from the map.
Signed-off-by Mark Brown <[email protected]>
--- drivers/base/regmap/internal.h | 8 +++--- drivers/base/regmap/regcache-lzo.c | 6 ++-- drivers/base/regmap/regcache-rbtree.c | 51 ++++++++++++++++----------------- drivers/base/regmap/regcache.c | 18 ++++++------ 4 files changed, 39 insertions(+), 44 deletions(-)
drivers/base/regmap/internal.h +4 -4
@@ -188,10 +188,10 @@ int regcache_write(struct regmap *map, unsigned int reg, unsigned int value);int regcache_sync (struct regmap *map); -unsigned int regcache_get_val (const void *base,unsigned int idx, -unsigned int word_size); -bool regcache_set_val (void *base,unsigned int idx, -unsigned int val,unsigned int word_size); +unsigned int regcache_get_val (struct regmap *map,const void *base, +unsigned int idx); +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);void regmap_async_complete_cb (struct regmap_async *async,int ret);
drivers/base/regmap/regcache-lzo.c +2 -4
@@ -260,8 +260,7 @@ static int regcache_lzo_read(struct regmap *map, ret =regcache_lzo_decompress_cache_block (map, lzo_block);if (ret >=0 )/* fetch the value from the cache */ - *value =regcache_get_val (lzo_block->dst, blkpos, - map->cache_word_size); + *value =regcache_get_val (map, lzo_block->dst, blkpos);kfree (lzo_block->dst);/* restore the pointer and length of the compressed block */
@@ -304,8 +303,7 @@ static int regcache_lzo_write(struct regmap *map, }/* write the new value to the cache */ -if (regcache_set_val (lzo_block->dst, blkpos, value, - map->cache_word_size)) { +if (regcache_set_val (map, lzo_block->dst, blkpos, value)) {kfree (lzo_block->dst); goto out; }
drivers/base/regmap/regcache-rbtree.c +25 -26
115 lines not on this page · raw message
drivers/base/regmap/regcache.c +8 -10
@@ -58,8 +58,7 @@ 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++) { - val =regcache_get_val (map->reg_defaults_raw, - i, map->cache_word_size); + val =regcache_get_val (map, map->reg_defaults_raw, i);if (regmap_volatile (map, i * map->reg_stride))continue ; count++;
@@ -75,8 +74,7 @@ static int regcache_hw_init(struct regmap *map)/* fill the reg_defaults */ map->num_reg_defaults = count;for (i =0 , j =0 ; i < map->num_reg_defaults_raw; i++) { - val =regcache_get_val (map->reg_defaults_raw, - i, map->cache_word_size); + val =regcache_get_val (map, map->reg_defaults_raw, i);if (regmap_volatile (map, i * map->reg_stride))continue ; map->reg_defaults[j].reg = i * map->reg_stride;
@@ -417,10 +415,10 @@ void regcache_cache_bypass(struct regmap *map, bool enable) }EXPORT_SYMBOL_GPL (regcache_cache_bypass); -bool regcache_set_val (void *base,unsigned int idx, -unsigned int val,unsigned int word_size) +bool regcache_set_val (struct regmap *map,void *base,unsigned int idx, +unsigned int val) { -switch (word_size) { +switch (map->cache_word_size) {case 1 : {u8 *cache = base;if (cache[idx] == val)
@@ -448,13 +446,13 @@ bool regcache_set_val(void *base, unsigned int idx,return false; } -unsigned int regcache_get_val (const void *base,unsigned int idx, -unsigned int word_size) +unsigned int regcache_get_val (struct regmap *map,const void *base, +unsigned int idx) {if (!base)return -EINVAL ; -switch (word_size) { +switch (map->cache_word_size) {case 1 : {const u8 *cache = base;return cache[idx];
Signature · 1 line
1.7.10.4
PATCH 3/3 regmap: cache: Use regcache_get_value() to check if we updated
In reply to Mark BrownFactor things out a little.
Signed-off-by Mark Brown <[email protected]>
--- drivers/base/regmap/regcache.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/base/regmap/regcache.c +3 -6
@@ -418,25 +418,22 @@ EXPORT_SYMBOL_GPL(regcache_cache_bypass);bool regcache_set_val (struct regmap *map,void *base,unsigned int idx,unsigned int val) { +if (regcache_get_val (map, base, idx) == val) +return true; +switch (map->cache_word_size) {case 1 : {u8 *cache = base; -if (cache[idx] == val) -return true; cache[idx] = val;break ; }case 2 : {u16 *cache = base; -if (cache[idx] == val) -return true; cache[idx] = val;break ; }case 4 : {u32 *cache = base; -if (cache[idx] == val) -return true; cache[idx] = val;break ; }
Signature · 1 line
1.7.10.4